diff --git a/tests/custom_preprocessors.rs b/tests/custom_preprocessors.rs index 49e934f1..6baa5db9 100644 --- a/tests/custom_preprocessors.rs +++ b/tests/custom_preprocessors.rs @@ -28,31 +28,3 @@ fn example_doesnt_support_not_supported() { assert_eq!(got, false); } - -#[test] -fn ask_the_preprocessor_to_blow_up() { - let dummy_book = DummyBook::new(); - let temp = dummy_book.build().unwrap(); - let mut md = MDBook::load(temp.path()).unwrap(); - md.with_preprocessor(example()); - - md.config - .set("preprocessor.nop-preprocessor.blow-up", true) - .unwrap(); - - let got = md.build(); - - assert!(got.is_err()); - let error_message = got.err().unwrap().to_string(); - let status = if cfg!(windows) { - "exit code: 1" - } else { - "exit status: 1" - }; - assert_eq!( - error_message, - format!( - r#"The "nop-preprocessor" preprocessor exited unsuccessfully with {status} status"# - ) - ); -} diff --git a/tests/testsuite/preprocessor.rs b/tests/testsuite/preprocessor.rs index 8b87926b..4c620c3a 100644 --- a/tests/testsuite/preprocessor.rs +++ b/tests/testsuite/preprocessor.rs @@ -52,3 +52,19 @@ fn nop_preprocessor() { "#]]); }); } + +// Failing preprocessor generates an error. +#[test] +fn failing_preprocessor() { + BookTest::from_dir("preprocessor/failing_preprocessor") + .run("build", |cmd| { + cmd.expect_failure() + .expect_stdout(str![[""]]) + .expect_stderr(str![[r#" +[TIMESTAMP] [INFO] (mdbook::book): Book building has started +Boom!!1! +[TIMESTAMP] [ERROR] (mdbook::utils): Error: The "nop-preprocessor" preprocessor exited unsuccessfully with [EXIT_STATUS]: 1 status + +"#]]); + }); +} diff --git a/tests/testsuite/preprocessor/failing_preprocessor/book.toml b/tests/testsuite/preprocessor/failing_preprocessor/book.toml new file mode 100644 index 00000000..f281ae0d --- /dev/null +++ b/tests/testsuite/preprocessor/failing_preprocessor/book.toml @@ -0,0 +1,4 @@ +[preprocessor.nop-preprocessor] +command = "cargo run --quiet --example nop-preprocessor --" +blow-up = true + diff --git a/tests/testsuite/preprocessor/failing_preprocessor/src/SUMMARY.md b/tests/testsuite/preprocessor/failing_preprocessor/src/SUMMARY.md new file mode 100644 index 00000000..e69de29b