From 82a7df41a68818907e9bc6515258f6e04a0cd5bb Mon Sep 17 00:00:00 2001 From: Gabor Szabo Date: Sun, 24 Aug 2025 09:54:59 +0300 Subject: [PATCH] add test: invalid field in the top level rust table in config --- tests/testsuite/config.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/testsuite/config.rs b/tests/testsuite/config.rs index df0a3013b1..d895510ea0 100644 --- a/tests/testsuite/config.rs +++ b/tests/testsuite/config.rs @@ -154,6 +154,31 @@ fn bad_config_in_book_table() { unknown field `foo`, expected one of `title`, `authors`, `description`, `src`, `language`, `text-direction` +"#]]); + }); +} + +// An invalid key in the main rust table. +#[test] +fn bad_config_in_rust_table() { + BookTest::init(|_| {}) + .change_file( + "book.toml", + "[rust]\n\ + title = \"bad-config\"\n", + ) + .run("build", |cmd| { + cmd.expect_failure() + .expect_stdout(str![[""]]) + .expect_stderr(str![[r#" +[TIMESTAMP] [ERROR] (mdbook_core::utils): Error: Invalid configuration file +[TIMESTAMP] [ERROR] (mdbook_core::utils): [TAB]Caused By: TOML parse error at line 2, column 1 + | +2 | title = "bad-config" + | ^^^^^ +unknown field `title`, expected `edition` + + "#]]); }); }