Skip to content

Commit 25b9acc

Browse files
committed
Migrate empty theme to BookTest
1 parent 10fae85 commit 25b9acc

File tree

5 files changed

+22
-35
lines changed

5 files changed

+22
-35
lines changed

tests/rendered_output.rs

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -324,41 +324,6 @@ fn summary_with_markdown_formatting() {
324324
);
325325
}
326326

327-
/// Ensure building fails if `[output.html].theme` points to a non-existent directory
328-
#[test]
329-
fn failure_on_missing_theme_directory() {
330-
// 1. Using default theme should work
331-
let temp = DummyBook::new().build().unwrap();
332-
let book_toml = r#"
333-
[book]
334-
title = "implicit"
335-
src = "src"
336-
"#;
337-
338-
write_file(temp.path(), "book.toml", book_toml.as_bytes()).unwrap();
339-
let md = MDBook::load(temp.path()).unwrap();
340-
let got = md.build();
341-
assert!(got.is_ok());
342-
343-
// 2. Pointing to a normal directory should work
344-
let temp = DummyBook::new().build().unwrap();
345-
let created = fs::create_dir(temp.path().join("theme-directory"));
346-
assert!(created.is_ok());
347-
let book_toml = r#"
348-
[book]
349-
title = "implicit"
350-
src = "src"
351-
352-
[output.html]
353-
theme = "./theme-directory"
354-
"#;
355-
356-
write_file(temp.path(), "book.toml", book_toml.as_bytes()).unwrap();
357-
let md = MDBook::load(temp.path()).unwrap();
358-
let got = md.build();
359-
assert!(got.is_ok());
360-
}
361-
362327
#[test]
363328
fn custom_fonts() {
364329
// Tests to ensure custom fonts are copied as expected.

tests/testsuite/theme.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,16 @@ cmd.expect_failure()
1717
"#]]);
1818
});
1919
}
20+
21+
// Checks what happens if the theme directory is empty.
22+
#[test]
23+
fn empty_theme() {
24+
BookTest::from_dir("theme/empty_theme").run("build", |cmd| {
25+
std::fs::create_dir(cmd.dir.join("theme")).unwrap();
26+
cmd.expect_stderr(str![[r#"
27+
[TIMESTAMP] [INFO] (mdbook::book): Book building has started
28+
[TIMESTAMP] [INFO] (mdbook::book): Running the html backend
29+
30+
"#]]);
31+
});
32+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[book]
2+
title = "empty_theme"
3+
4+
[output.html]
5+
theme = "./theme"
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)