Migrate ask_the_preprocessor_to_blow_up to BookTest
This commit is contained in:
parent
fca149a52c
commit
d815b0cc52
4 changed files with 20 additions and 28 deletions
|
|
@ -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"#
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
"#]]);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
[preprocessor.nop-preprocessor]
|
||||
command = "cargo run --quiet --example nop-preprocessor --"
|
||||
blow-up = true
|
||||
|
||||
Loading…
Add table
Reference in a new issue