diff --git a/tests/rendered_output.rs b/tests/rendered_output.rs index 4f4ccd9a..cef61ac9 100644 --- a/tests/rendered_output.rs +++ b/tests/rendered_output.rs @@ -375,31 +375,6 @@ fn failure_on_missing_theme_directory() { assert!(got.is_err()); } -#[cfg(feature = "search")] -mod search { - use crate::dummy_book::DummyBook; - use mdbook::utils::fs::write_file; - use mdbook::MDBook; - - #[test] - fn chapter_settings_validation_error() { - let temp = DummyBook::new().build().unwrap(); - let book_toml = r#" - [book] - title = "Search Test" - - [output.html.search.chapter] - "does-not-exist" = { enable = false } - "#; - write_file(temp.path(), "book.toml", book_toml.as_bytes()).unwrap(); - let md = MDBook::load(temp.path()).unwrap(); - let err = md.build().unwrap_err(); - assert!(format!("{err:?}").contains( - "[output.html.search.chapter] key `does-not-exist` does not match any chapter paths" - )); - } -} - #[test] fn custom_fonts() { // Tests to ensure custom fonts are copied as expected. diff --git a/tests/testsuite/search.rs b/tests/testsuite/search.rs index b7e31212..d7e142a9 100644 --- a/tests/testsuite/search.rs +++ b/tests/testsuite/search.rs @@ -125,3 +125,17 @@ fn with_no_source_path() { book.book.sections.push(BookItem::Chapter(chapter)); book.build().unwrap(); } + +// Checks that invalid settings in search chapter is rejected. +#[test] +fn chapter_settings_validation_error() { + BookTest::from_dir("search/chapter_settings_validation_error").run("build", |cmd| { + cmd.expect_failure().expect_stderr(str![[r#" +[TIMESTAMP] [INFO] (mdbook::book): Book building has started +[TIMESTAMP] [INFO] (mdbook::book): Running the html backend +[TIMESTAMP] [ERROR] (mdbook::utils): Error: Rendering failed +[TIMESTAMP] [ERROR] (mdbook::utils): [TAB]Caused By: [output.html.search.chapter] key `does-not-exist` does not match any chapter paths + +"#]]); + }); +} diff --git a/tests/testsuite/search/chapter_settings_validation_error/book.toml b/tests/testsuite/search/chapter_settings_validation_error/book.toml new file mode 100644 index 00000000..e1a18d65 --- /dev/null +++ b/tests/testsuite/search/chapter_settings_validation_error/book.toml @@ -0,0 +1,5 @@ +[book] +title = "Search Test" + +[output.html.search.chapter] +"does-not-exist" = { enable = false } diff --git a/tests/testsuite/search/chapter_settings_validation_error/src/SUMMARY.md b/tests/testsuite/search/chapter_settings_validation_error/src/SUMMARY.md new file mode 100644 index 00000000..e69de29b