diff --git a/tests/rendered_output.rs b/tests/rendered_output.rs index cc22e650..696de857 100644 --- a/tests/rendered_output.rs +++ b/tests/rendered_output.rs @@ -305,38 +305,3 @@ fn summary_with_markdown_formatting() { "# <escaped tag>\n" ); } - -#[test] -fn custom_fonts() { - // Tests to ensure custom fonts are copied as expected. - let actual_files = |path: &Path| -> Vec { - let mut actual: Vec<_> = path - .read_dir() - .unwrap() - .map(|entry| entry.unwrap().file_name().into_string().unwrap()) - .collect(); - actual.sort(); - actual - }; - let has_fonts_css = |path: &Path| -> bool { - let contents = fs::read_to_string(path.join("book/index.html")).unwrap(); - contents.contains("fonts/fonts.css") - }; - - // copy-fonts=false with fonts theme - let temp = TempFileBuilder::new().prefix("mdbook").tempdir().unwrap(); - let p = temp.path(); - MDBook::init(p).build().unwrap(); - write_file(&p.join("theme/fonts"), "fonts.css", b"/*custom*/").unwrap(); - write_file(&p.join("theme/fonts"), "myfont.woff", b"").unwrap(); - let config = Config::from_str("output.html.copy-fonts = false").unwrap(); - MDBook::load_with_config(p, config) - .unwrap() - .build() - .unwrap(); - assert!(has_fonts_css(p)); - assert_eq!( - actual_files(&p.join("book/fonts")), - &["fonts.css", "myfont.woff"] - ); -} diff --git a/tests/testsuite/theme.rs b/tests/testsuite/theme.rs index f4b0c7b7..245952f5 100644 --- a/tests/testsuite/theme.rs +++ b/tests/testsuite/theme.rs @@ -170,3 +170,24 @@ fn copy_fonts_false_with_empty_fonts_css() { .check_file_doesnt_contain("book/index.html", "fonts.css") .check_file_list("book/fonts", str![[""]]); } + +// copy-fonts=false, fonts.css has contents +#[test] +fn copy_fonts_false_with_fonts_css() { + BookTest::from_dir("theme/copy_fonts_false_with_fonts_css") + .run("build", |cmd| { + cmd.expect_stderr(str![[r#" +[TIMESTAMP] [INFO] (mdbook::book): Book building has started +[TIMESTAMP] [INFO] (mdbook::book): Running the html backend + +"#]]); + }) + .check_file_contains("book/index.html", "fonts.css") + .check_file_list( + "book/fonts", + str![[r#" +book/fonts/fonts.css +book/fonts/myfont.woff +"#]], + ); +} diff --git a/tests/testsuite/theme/copy_fonts_false_with_fonts_css/book.toml b/tests/testsuite/theme/copy_fonts_false_with_fonts_css/book.toml new file mode 100644 index 00000000..e4929c83 --- /dev/null +++ b/tests/testsuite/theme/copy_fonts_false_with_fonts_css/book.toml @@ -0,0 +1,2 @@ +[output.html] +copy-fonts = false diff --git a/tests/testsuite/theme/copy_fonts_false_with_fonts_css/src/SUMMARY.md b/tests/testsuite/theme/copy_fonts_false_with_fonts_css/src/SUMMARY.md new file mode 100644 index 00000000..655a0ded --- /dev/null +++ b/tests/testsuite/theme/copy_fonts_false_with_fonts_css/src/SUMMARY.md @@ -0,0 +1 @@ +- [Intro](index.md) diff --git a/tests/testsuite/theme/copy_fonts_false_with_fonts_css/theme/fonts/fonts.css b/tests/testsuite/theme/copy_fonts_false_with_fonts_css/theme/fonts/fonts.css new file mode 100644 index 00000000..b94b7f50 --- /dev/null +++ b/tests/testsuite/theme/copy_fonts_false_with_fonts_css/theme/fonts/fonts.css @@ -0,0 +1 @@ +/*custom*/ diff --git a/tests/testsuite/theme/copy_fonts_false_with_fonts_css/theme/fonts/myfont.woff b/tests/testsuite/theme/copy_fonts_false_with_fonts_css/theme/fonts/myfont.woff new file mode 100644 index 00000000..e69de29b