Migrate copy-fonts=false empty fonts.css to BookTest

This commit is contained in:
Eric Huss 2025-04-22 11:13:03 -07:00
parent 9a1f983e65
commit bdd16e25fa
5 changed files with 18 additions and 13 deletions

View file

@ -323,19 +323,6 @@ fn custom_fonts() {
contents.contains("fonts/fonts.css")
};
// copy-fonts=false with empty fonts.css
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"").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 fonts theme
let temp = TempFileBuilder::new().prefix("mdbook").tempdir().unwrap();
let p = temp.path();

View file

@ -155,3 +155,18 @@ 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![[""]]);
}
// copy-fonts=false, empty fonts.css
#[test]
fn copy_fonts_false_with_empty_fonts_css() {
BookTest::from_dir("theme/copy_fonts_false_with_empty_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_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)