Migrate empty theme to BookTest
This commit is contained in:
parent
10fae8596c
commit
25b9acc321
5 changed files with 22 additions and 35 deletions
|
|
@ -324,41 +324,6 @@ fn summary_with_markdown_formatting() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Ensure building fails if `[output.html].theme` points to a non-existent directory
|
|
||||||
#[test]
|
|
||||||
fn failure_on_missing_theme_directory() {
|
|
||||||
// 1. Using default theme should work
|
|
||||||
let temp = DummyBook::new().build().unwrap();
|
|
||||||
let book_toml = r#"
|
|
||||||
[book]
|
|
||||||
title = "implicit"
|
|
||||||
src = "src"
|
|
||||||
"#;
|
|
||||||
|
|
||||||
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_ok());
|
|
||||||
|
|
||||||
// 2. Pointing to a normal directory should work
|
|
||||||
let temp = DummyBook::new().build().unwrap();
|
|
||||||
let created = fs::create_dir(temp.path().join("theme-directory"));
|
|
||||||
assert!(created.is_ok());
|
|
||||||
let book_toml = r#"
|
|
||||||
[book]
|
|
||||||
title = "implicit"
|
|
||||||
src = "src"
|
|
||||||
|
|
||||||
[output.html]
|
|
||||||
theme = "./theme-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_ok());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn custom_fonts() {
|
fn custom_fonts() {
|
||||||
// Tests to ensure custom fonts are copied as expected.
|
// Tests to ensure custom fonts are copied as expected.
|
||||||
|
|
|
||||||
|
|
@ -17,3 +17,16 @@ cmd.expect_failure()
|
||||||
"#]]);
|
"#]]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Checks what happens if the theme directory is empty.
|
||||||
|
#[test]
|
||||||
|
fn empty_theme() {
|
||||||
|
BookTest::from_dir("theme/empty_theme").run("build", |cmd| {
|
||||||
|
std::fs::create_dir(cmd.dir.join("theme")).unwrap();
|
||||||
|
cmd.expect_stderr(str![[r#"
|
||||||
|
[TIMESTAMP] [INFO] (mdbook::book): Book building has started
|
||||||
|
[TIMESTAMP] [INFO] (mdbook::book): Running the html backend
|
||||||
|
|
||||||
|
"#]]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
|
||||||
5
tests/testsuite/theme/empty_theme/book.toml
Normal file
5
tests/testsuite/theme/empty_theme/book.toml
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
[book]
|
||||||
|
title = "empty_theme"
|
||||||
|
|
||||||
|
[output.html]
|
||||||
|
theme = "./theme"
|
||||||
3
tests/testsuite/theme/empty_theme/src/SUMMARY.md
Normal file
3
tests/testsuite/theme/empty_theme/src/SUMMARY.md
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
# Summary
|
||||||
|
|
||||||
|
- [Chapter 1](./chapter_1.md)
|
||||||
1
tests/testsuite/theme/empty_theme/src/chapter_1.md
Normal file
1
tests/testsuite/theme/empty_theme/src/chapter_1.md
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
# Chapter 1
|
||||||
Loading…
Add table
Reference in a new issue