diff --git a/tests/rendered_output.rs b/tests/rendered_output.rs index 04c789d5..ec5b1ecf 100644 --- a/tests/rendered_output.rs +++ b/tests/rendered_output.rs @@ -348,20 +348,6 @@ fn check_link_target_fallback() { ); } -/// Ensure building fails if `create-missing` is false and one of the files does -/// not exist. -#[test] -fn failure_on_missing_file() { - let temp = DummyBook::new().build().unwrap(); - fs::remove_file(temp.path().join("src").join("intro.md")).unwrap(); - - let mut cfg = Config::default(); - cfg.build.create_missing = false; - - let got = MDBook::load_with_config(temp.path(), cfg); - assert!(got.is_err()); -} - /// Ensure a missing file is created if `create-missing` is true. #[test] fn create_missing_file_with_config() { diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs index 1f75199c..9c5d9d65 100644 --- a/tests/testsuite/build.rs +++ b/tests/testsuite/build.rs @@ -16,3 +16,16 @@ fn basic_build() { "#]]); }); } + +// Ensure building fails if `create-missing` is false and one of the files does +// not exist. +#[test] +fn failure_on_missing_file() { + BookTest::from_dir("build/missing_file").run("build", |cmd| { + cmd.expect_failure().expect_stderr(str![[r#" +[TIMESTAMP] [ERROR] (mdbook::utils): Error: Chapter file not found, ./chapter_1.md +[TIMESTAMP] [ERROR] (mdbook::utils): [TAB]Caused By: [NOT_FOUND] + +"#]]); + }); +} diff --git a/tests/testsuite/build/missing_file/book.toml b/tests/testsuite/build/missing_file/book.toml new file mode 100644 index 00000000..67e5e5f3 --- /dev/null +++ b/tests/testsuite/build/missing_file/book.toml @@ -0,0 +1,5 @@ +[book] +title = "missing_file" + +[build] +create-missing = false diff --git a/tests/testsuite/build/missing_file/src/SUMMARY.md b/tests/testsuite/build/missing_file/src/SUMMARY.md new file mode 100644 index 00000000..7390c828 --- /dev/null +++ b/tests/testsuite/build/missing_file/src/SUMMARY.md @@ -0,0 +1,3 @@ +# Summary + +- [Chapter 1](./chapter_1.md)