Migrate missing theme to BookTest
This commit is contained in:
parent
909bd1c54e
commit
10fae8596c
6 changed files with 29 additions and 16 deletions
|
|
@ -357,22 +357,6 @@ fn failure_on_missing_theme_directory() {
|
||||||
let md = MDBook::load(temp.path()).unwrap();
|
let md = MDBook::load(temp.path()).unwrap();
|
||||||
let got = md.build();
|
let got = md.build();
|
||||||
assert!(got.is_ok());
|
assert!(got.is_ok());
|
||||||
|
|
||||||
// 3. Pointing to a non-existent directory should fail
|
|
||||||
let temp = DummyBook::new().build().unwrap();
|
|
||||||
let book_toml = r#"
|
|
||||||
[book]
|
|
||||||
title = "implicit"
|
|
||||||
src = "src"
|
|
||||||
|
|
||||||
[output.html]
|
|
||||||
theme = "./non-existent-directory"
|
|
||||||
"#;
|
|
||||||
|
|
||||||
write_file(temp.path(), "book.toml", book_toml.as_bytes()).unwrap();
|
|
||||||
let md = MDBook::load(temp.path()).unwrap();
|
|
||||||
let got = md.build();
|
|
||||||
assert!(got.is_err());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ mod rendering;
|
||||||
#[cfg(feature = "search")]
|
#[cfg(feature = "search")]
|
||||||
mod search;
|
mod search;
|
||||||
mod test;
|
mod test;
|
||||||
|
mod theme;
|
||||||
|
|
||||||
mod prelude {
|
mod prelude {
|
||||||
pub use crate::book_test::BookTest;
|
pub use crate::book_test::BookTest;
|
||||||
|
|
|
||||||
19
tests/testsuite/theme.rs
Normal file
19
tests/testsuite/theme.rs
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
//! Tests for theme handling.
|
||||||
|
|
||||||
|
use crate::prelude::*;
|
||||||
|
|
||||||
|
// Checks what happens if the theme directory is missing.
|
||||||
|
#[test]
|
||||||
|
fn missing_theme() {
|
||||||
|
BookTest::from_dir("theme/missing_theme")
|
||||||
|
.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: theme dir [ROOT]/./non-existent-directory does not exist
|
||||||
|
|
||||||
|
"#]]);
|
||||||
|
});
|
||||||
|
}
|
||||||
5
tests/testsuite/theme/missing_theme/book.toml
Normal file
5
tests/testsuite/theme/missing_theme/book.toml
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
[book]
|
||||||
|
title = "missing_theme"
|
||||||
|
|
||||||
|
[output.html]
|
||||||
|
theme = "./non-existent-directory"
|
||||||
3
tests/testsuite/theme/missing_theme/src/SUMMARY.md
Normal file
3
tests/testsuite/theme/missing_theme/src/SUMMARY.md
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
# Summary
|
||||||
|
|
||||||
|
- [Chapter 1](./chapter_1.md)
|
||||||
1
tests/testsuite/theme/missing_theme/src/chapter_1.md
Normal file
1
tests/testsuite/theme/missing_theme/src/chapter_1.md
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
# Chapter 1
|
||||||
Loading…
Add table
Reference in a new issue