{"record":{"id":"c1f5e352a0c37fee","repo":"rust-lang/mdBook","slug":"one-or-more-tests-failed","errorCode":null,"errorMessage":"One or more tests failed","messagePattern":"One or more tests failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/mdbook-driver/src/mdbook.rs","lineNumber":337,"sourceCode":"\n                debug!(\"running {:?}\", cmd);\n                let output = cmd\n                    .output()\n                    .with_context(|| \"failed to execute `rustdoc`\")?;\n\n                if !output.status.success() {\n                    failed = true;\n                    eprintln!(\n                        \"ERROR rustdoc returned an error:\\n\\\n                        \\n--- stdout\\n{}\\n--- stderr\\n{}\",\n                        String::from_utf8_lossy(&output.stdout),\n                        String::from_utf8_lossy(&output.stderr)\n                    );\n                }\n            }\n        }\n        if failed {\n            bail!(\"One or more tests failed\");\n        }\n        if let Some(chapter) = chapter {\n            if !chapter_found {\n                bail!(\"Chapter not found: {}\", chapter);\n            }\n        }\n        Ok(())\n    }\n\n    /// The logic for determining where a backend should put its build\n    /// artefacts.\n    ///\n    /// If there is only 1 renderer, put it in the directory pointed to by the\n    /// `build.build_dir` key in [`Config`]. If there is more than one then the\n    /// renderer gets its own directory within the main build dir.\n    ///\n    /// i.e. If there were only one renderer (in this case, the HTML renderer):\n    ///","sourceCodeStart":319,"sourceCodeEnd":355,"githubUrl":"https://github.com/rust-lang/mdBook/blob/dc21064fc21d955a0e1f67e65e336883c3e5260b/crates/mdbook-driver/src/mdbook.rs#L319-L355","documentation":"MDBook::test_chapter() runs each Rust code block (mdbook test) via the rustdoc test runner and tracks failures; if any test failed it bails with this summary error after printing per-test output to stderr.","triggerScenarios":"Any doctest/code block in the book that fails compilation or assertions during `mdbook test`; interpreter non-zero exit recorded in the test runner.","commonSituations":"Code examples that drifted from the actual library API after a dependency upgrade; code blocks missing edition attributes; non-deterministic examples.","solutions":["Fix the failing code blocks listed in the test output above this error","Re-run with verbose output to see the exact failing chapter/test","Pin example code to the documented API or mark non-testable blocks with `text`/`ignore` annotations"],"exampleFix":"// before (book code block)\n```rust\nlet x = lib::old_api();\n```\n// after\n```rust\nlet x = lib::new_api();\n```","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if let Err(e) = book.test(&[], None, chapter) {\n    eprintln!(\"test run failed: {e}; see failing code blocks above\");\n    std::process::exit(1);\n}","preventionTips":["Keep doctest code blocks compiling against your crate's current API","Mark non-executable snippets as ```text or ```rust,ignore","Run `mdbook test` in CI on every API change"],"tags":["testing","rustdoc"],"backgroundTag":"test-failure","analyzedSha":"dc21064fc21d955a0e1f67e65e336883c3e5260b","analyzedAt":"2026-09-01T10:15:12.134Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}