From f6c11d12e050d1163e5dc9eba7ee76c4c1547ddd Mon Sep 17 00:00:00 2001 From: Gabor Szabo Date: Sun, 24 Aug 2025 09:49:43 +0300 Subject: [PATCH] add test: invalid table at the top level config --- tests/testsuite/config.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/testsuite/config.rs b/tests/testsuite/config.rs index df0a3013..bc9681cb 100644 --- a/tests/testsuite/config.rs +++ b/tests/testsuite/config.rs @@ -128,6 +128,31 @@ fn bad_config_top_level() { unknown field `foo`, expected one of `book`, `build`, `rust`, `output`, `preprocessor` +"#]]); + }); +} + +// An invalid table at the top level. +#[test] +fn bad_config_top_level_table() { + BookTest::init(|_| {}) + .change_file( + "book.toml", + "[other]\n\ + foo = 123", + ) + .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 1, column 2 + | +1 | [other] + | ^^^^^ +unknown field `other`, expected one of `book`, `build`, `rust`, `output`, `preprocessor` + + "#]]); }); }