Add tests for with_renderer and with_preprocessor collisions
This adds tests with with_renderer and with_preprocessor are used with extensions that have the same name.
This commit is contained in:
parent
0f0d1f3377
commit
25c47ed0bc
3 changed files with 51 additions and 1 deletions
|
|
@ -22,7 +22,8 @@ enum StatusCode {
|
||||||
pub struct BookTest {
|
pub struct BookTest {
|
||||||
/// The temp directory where the test should perform its work.
|
/// The temp directory where the test should perform its work.
|
||||||
pub dir: PathBuf,
|
pub dir: PathBuf,
|
||||||
assert: snapbox::Assert,
|
/// Snapshot assertion support.
|
||||||
|
pub assert: snapbox::Assert,
|
||||||
/// This indicates whether or not the book has been built.
|
/// This indicates whether or not the book has been built.
|
||||||
built: bool,
|
built: bool,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -180,3 +180,27 @@ fn missing_optional_not_fatal() {
|
||||||
"#]]);
|
"#]]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// with_preprocessor of an existing name.
|
||||||
|
#[test]
|
||||||
|
fn with_preprocessor_same_name() {
|
||||||
|
let mut test = BookTest::init(|_| {});
|
||||||
|
test.change_file(
|
||||||
|
"book.toml",
|
||||||
|
"[preprocessor.dummy]\n\
|
||||||
|
command = 'mdbook-preprocessor-does-not-exist'\n",
|
||||||
|
);
|
||||||
|
let spy: Arc<Mutex<Inner>> = Default::default();
|
||||||
|
let mut book = test.load_book();
|
||||||
|
book.with_preprocessor(Spy(Arc::clone(&spy)));
|
||||||
|
let err = book.build().unwrap_err();
|
||||||
|
test.assert.eq(
|
||||||
|
format!("{err:?}"),
|
||||||
|
str![[r#"
|
||||||
|
Unable to run the preprocessor `dummy`
|
||||||
|
|
||||||
|
Caused by:
|
||||||
|
[NOT_FOUND]
|
||||||
|
"#]],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -241,3 +241,28 @@ fn relative_command_path() {
|
||||||
})
|
})
|
||||||
.check_file("book/output", "test");
|
.check_file("book/output", "test");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// with_renderer of an existing name.
|
||||||
|
#[test]
|
||||||
|
fn with_renderer_same_name() {
|
||||||
|
let mut test = BookTest::init(|_| {});
|
||||||
|
test.change_file(
|
||||||
|
"book.toml",
|
||||||
|
"[output.dummy]\n\
|
||||||
|
command = 'mdbook-renderer-does-not-exist'\n",
|
||||||
|
);
|
||||||
|
let spy: Arc<Mutex<Inner>> = Default::default();
|
||||||
|
let mut book = test.load_book();
|
||||||
|
book.with_renderer(Spy(Arc::clone(&spy)));
|
||||||
|
let err = book.build().unwrap_err();
|
||||||
|
test.assert.eq(
|
||||||
|
format!("{err:?}"),
|
||||||
|
str![[r#"
|
||||||
|
Rendering failed
|
||||||
|
|
||||||
|
Caused by:
|
||||||
|
0: Unable to run the backend `dummy`
|
||||||
|
1: [NOT_FOUND]
|
||||||
|
"#]],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue