Migrate book_with_a_reserved_filename_does_not_build to BookTest
This commit is contained in:
parent
adcea9b3b9
commit
3706ddc5cc
5 changed files with 20 additions and 18 deletions
|
|
@ -405,24 +405,6 @@ fn example_book_can_build() {
|
||||||
md.build().unwrap();
|
md.build().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn book_with_a_reserved_filename_does_not_build() {
|
|
||||||
let tmp_dir = TempFileBuilder::new().prefix("mdBook").tempdir().unwrap();
|
|
||||||
let src_path = tmp_dir.path().join("src");
|
|
||||||
fs::create_dir(&src_path).unwrap();
|
|
||||||
|
|
||||||
let summary_path = src_path.join("SUMMARY.md");
|
|
||||||
let print_path = src_path.join("print.md");
|
|
||||||
|
|
||||||
fs::File::create(print_path).unwrap();
|
|
||||||
let mut summary_file = fs::File::create(summary_path).unwrap();
|
|
||||||
writeln!(summary_file, "[print](print.md)").unwrap();
|
|
||||||
|
|
||||||
let md = MDBook::load(tmp_dir.path()).unwrap();
|
|
||||||
let got = md.build();
|
|
||||||
assert!(got.is_err());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn by_default_mdbook_use_index_preprocessor_to_convert_readme_to_index() {
|
fn by_default_mdbook_use_index_preprocessor_to_convert_readme_to_index() {
|
||||||
let temp = DummyBook::new().build().unwrap();
|
let temp = DummyBook::new().build().unwrap();
|
||||||
|
|
|
||||||
|
|
@ -39,3 +39,17 @@ fn create_missing() {
|
||||||
test.load_book();
|
test.load_book();
|
||||||
assert!(test.dir.join("src/chapter_1.md").exists());
|
assert!(test.dir.join("src/chapter_1.md").exists());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Checks that it fails if the summary has a reserved filename.
|
||||||
|
#[test]
|
||||||
|
fn no_reserved_filename() {
|
||||||
|
BookTest::from_dir("build/no_reserved_filename").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: print.md is reserved for internal use
|
||||||
|
|
||||||
|
"#]]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
|
||||||
2
tests/testsuite/build/no_reserved_filename/book.toml
Normal file
2
tests/testsuite/build/no_reserved_filename/book.toml
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
[book]
|
||||||
|
title = "no_reserved_filename"
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
# Summary
|
||||||
|
|
||||||
|
- [Print](print.md)
|
||||||
1
tests/testsuite/build/no_reserved_filename/src/print.md
Normal file
1
tests/testsuite/build/no_reserved_filename/src/print.md
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
# Print
|
||||||
Loading…
Add table
Reference in a new issue