From 9a1f983e65e990cbe3586d961b90dac20d7b7102 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Tue, 22 Apr 2025 11:12:30 -0700 Subject: [PATCH] Copy copy-fonts=false no theme to BookTest --- tests/rendered_output.rs | 13 ------------- tests/testsuite/theme.rs | 18 ++++++++++++++++++ .../theme/copy_fonts_false_no_theme/book.toml | 2 ++ .../copy_fonts_false_no_theme/src/SUMMARY.md | 1 + 4 files changed, 21 insertions(+), 13 deletions(-) create mode 100644 tests/testsuite/theme/copy_fonts_false_no_theme/book.toml create mode 100644 tests/testsuite/theme/copy_fonts_false_no_theme/src/SUMMARY.md diff --git a/tests/rendered_output.rs b/tests/rendered_output.rs index 20a91825..12b07ad7 100644 --- a/tests/rendered_output.rs +++ b/tests/rendered_output.rs @@ -323,19 +323,6 @@ fn custom_fonts() { contents.contains("fonts/fonts.css") }; - // copy-fonts=false, no theme - // This should generate a deprecation warning. - let temp = TempFileBuilder::new().prefix("mdbook").tempdir().unwrap(); - let p = temp.path(); - MDBook::init(p).build().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!(!p.join("book/fonts").exists()); - // copy-fonts=false with empty fonts.css let temp = TempFileBuilder::new().prefix("mdbook").tempdir().unwrap(); let p = temp.path(); diff --git a/tests/testsuite/theme.rs b/tests/testsuite/theme.rs index 9cab6e57..9916c4d2 100644 --- a/tests/testsuite/theme.rs +++ b/tests/testsuite/theme.rs @@ -137,3 +137,21 @@ book/fonts/myfont.woff "#]], ); } + +// copy-fonts=false, no theme, deprecated +#[test] +fn copy_fonts_false_no_theme() { + BookTest::from_dir("theme/copy_fonts_false_no_theme") + .run("build", |cmd| { + cmd.expect_stderr(str![[r#" +[TIMESTAMP] [INFO] (mdbook::book): Book building has started +[TIMESTAMP] [INFO] (mdbook::book): Running the html backend +[TIMESTAMP] [WARN] (mdbook::renderer::html_handlebars::static_files): output.html.copy-fonts is deprecated. +This book appears to have copy-fonts=false in book.toml without a fonts.css file. +Add an empty `theme/fonts/fonts.css` file to squelch this warning. + +"#]]); + }) + .check_file_doesnt_contain("book/index.html", "fonts.css") + .check_file_list("book/fonts", str![[""]]); +} diff --git a/tests/testsuite/theme/copy_fonts_false_no_theme/book.toml b/tests/testsuite/theme/copy_fonts_false_no_theme/book.toml new file mode 100644 index 00000000..e4929c83 --- /dev/null +++ b/tests/testsuite/theme/copy_fonts_false_no_theme/book.toml @@ -0,0 +1,2 @@ +[output.html] +copy-fonts = false diff --git a/tests/testsuite/theme/copy_fonts_false_no_theme/src/SUMMARY.md b/tests/testsuite/theme/copy_fonts_false_no_theme/src/SUMMARY.md new file mode 100644 index 00000000..655a0ded --- /dev/null +++ b/tests/testsuite/theme/copy_fonts_false_no_theme/src/SUMMARY.md @@ -0,0 +1 @@ +- [Intro](index.md)