Copy copy-fonts=false no theme to BookTest

This commit is contained in:
Eric Huss 2025-04-22 11:12:30 -07:00
parent c2c37705e7
commit 9a1f983e65
4 changed files with 21 additions and 13 deletions

View file

@ -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();

View file

@ -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![[""]]);
}

View file

@ -0,0 +1,2 @@
[output.html]
copy-fonts = false

View file

@ -0,0 +1 @@
- [Intro](index.md)