From f482aeaca3f2791dd47b0978a6bb92579190fd6f Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Mon, 21 Apr 2025 19:35:35 -0700 Subject: [PATCH] Migrate missing_optional_backends_are_not_fatal to BookTest --- tests/alternative_backends.rs | 6 ------ tests/testsuite/renderer.rs | 14 ++++++++++++++ .../renderer/missing_optional_not_fatal/book.toml | 4 ++++ .../missing_optional_not_fatal/src/SUMMARY.md | 0 4 files changed, 18 insertions(+), 6 deletions(-) create mode 100644 tests/testsuite/renderer/missing_optional_not_fatal/book.toml create mode 100644 tests/testsuite/renderer/missing_optional_not_fatal/src/SUMMARY.md diff --git a/tests/alternative_backends.rs b/tests/alternative_backends.rs index 6410f9da..85f0360d 100644 --- a/tests/alternative_backends.rs +++ b/tests/alternative_backends.rs @@ -6,12 +6,6 @@ use std::fs; use std::path::Path; use tempfile::{Builder as TempFileBuilder, TempDir}; -#[test] -fn missing_optional_backends_are_not_fatal() { - let (md, _temp) = dummy_book_with_backend("missing", "trduyvbhijnorgevfuhn", true); - assert!(md.build().is_ok()); -} - #[test] fn alternate_backend_with_arguments() { let (md, _temp) = dummy_book_with_backend("arguments", "echo Hello World!", false); diff --git a/tests/testsuite/renderer.rs b/tests/testsuite/renderer.rs index 8732a6c6..e53a920f 100644 --- a/tests/testsuite/renderer.rs +++ b/tests/testsuite/renderer.rs @@ -91,3 +91,17 @@ fn missing_renderer() { "#]]); }); } + +// Optional missing is not an error. +#[test] +fn missing_optional_not_fatal() { + BookTest::from_dir("renderer/missing_optional_not_fatal").run("build", |cmd| { + cmd.expect_stdout(str![[""]]).expect_stderr(str![[r#" +[TIMESTAMP] [INFO] (mdbook::book): Book building has started +[TIMESTAMP] [INFO] (mdbook::book): Running the missing backend +[TIMESTAMP] [INFO] (mdbook::renderer): Invoking the "missing" renderer +[TIMESTAMP] [WARN] (mdbook::renderer): The command `trduyvbhijnorgevfuhn` for backend `missing` was not found, but was marked as optional. + +"#]]); + }); +} diff --git a/tests/testsuite/renderer/missing_optional_not_fatal/book.toml b/tests/testsuite/renderer/missing_optional_not_fatal/book.toml new file mode 100644 index 00000000..79a7ceba --- /dev/null +++ b/tests/testsuite/renderer/missing_optional_not_fatal/book.toml @@ -0,0 +1,4 @@ +[output.missing] +command = "trduyvbhijnorgevfuhn" +optional = true + diff --git a/tests/testsuite/renderer/missing_optional_not_fatal/src/SUMMARY.md b/tests/testsuite/renderer/missing_optional_not_fatal/src/SUMMARY.md new file mode 100644 index 00000000..e69de29b