Don't rebuild books in tests

This fixes an issue where the `check` methods would inadvertently
rebuild the books if the `mdbook build` command is run. Normally this
isn't too much of an issue unless the `build` command is run with
options that affect the output.
This commit is contained in:
Eric Huss 2025-08-11 19:21:03 -07:00
parent 4a2d3a7e85
commit 824e2a7681

View file

@ -230,6 +230,12 @@ impl BookTest {
};
f(&mut cmd);
cmd.run();
// Ensure that `built` gets set if a build command is used so that all
// the `check` methods do not overwrite the contents of what was just
// built.
if cmd.args.first().map(String::as_str) == Some("build") {
self.built = true
}
self
}