Skip to content

Commit 10fae85

Browse files
committed
Migrate missing theme to BookTest
1 parent 909bd1c commit 10fae85

File tree

6 files changed

+29
-16
lines changed

6 files changed

+29
-16
lines changed

tests/rendered_output.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -357,22 +357,6 @@ fn failure_on_missing_theme_directory() {
357357
let md = MDBook::load(temp.path()).unwrap();
358358
let got = md.build();
359359
assert!(got.is_ok());
360-
361-
// 3. Pointing to a non-existent directory should fail
362-
let temp = DummyBook::new().build().unwrap();
363-
let book_toml = r#"
364-
[book]
365-
title = "implicit"
366-
src = "src"
367-
368-
[output.html]
369-
theme = "./non-existent-directory"
370-
"#;
371-
372-
write_file(temp.path(), "book.toml", book_toml.as_bytes()).unwrap();
373-
let md = MDBook::load(temp.path()).unwrap();
374-
let got = md.build();
375-
assert!(got.is_err());
376360
}
377361

378362
#[test]

tests/testsuite/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ mod rendering;
1818
#[cfg(feature = "search")]
1919
mod search;
2020
mod test;
21+
mod theme;
2122

2223
mod prelude {
2324
pub use crate::book_test::BookTest;

tests/testsuite/theme.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//! Tests for theme handling.
2+
3+
use crate::prelude::*;
4+
5+
// Checks what happens if the theme directory is missing.
6+
#[test]
7+
fn missing_theme() {
8+
BookTest::from_dir("theme/missing_theme")
9+
.run("build", |cmd| {
10+
cmd.expect_failure()
11+
.expect_stderr(str![[r#"
12+
[TIMESTAMP] [INFO] (mdbook::book): Book building has started
13+
[TIMESTAMP] [INFO] (mdbook::book): Running the html backend
14+
[TIMESTAMP] [ERROR] (mdbook::utils): Error: Rendering failed
15+
[TIMESTAMP] [ERROR] (mdbook::utils): [TAB]Caused By: theme dir [ROOT]/./non-existent-directory does not exist
16+
17+
"#]]);
18+
});
19+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[book]
2+
title = "missing_theme"
3+
4+
[output.html]
5+
theme = "./non-existent-directory"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Summary
2+
3+
- [Chapter 1](./chapter_1.md)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Chapter 1

0 commit comments

Comments
 (0)