@@ -129,6 +129,9 @@ mod __doctest_mod {{
129129
130130 pub static BINARY_PATH: OnceLock<PathBuf> = OnceLock::new();
131131 pub const RUN_OPTION: &str = \" RUSTDOC_DOCTEST_RUN_NB_TEST\" ;
132+ pub const SHOULD_PANIC_DISABLED: bool = (
133+ cfg!(target_family = \" wasm\" ) || cfg!(target_os = \" zkvm\" )
134+ ) && !cfg!(target_os = \" emscripten\" );
132135
133136 #[allow(unused)]
134137 pub fn doctest_path() -> Option<&'static PathBuf> {{
@@ -266,13 +269,14 @@ fn main() {returns_result} {{
266269 )
267270 . unwrap ( ) ;
268271 }
272+ let should_panic = scraped_test. langstr . should_panic ;
269273 let not_running = ignore || scraped_test. no_run ( opts) ;
270274 writeln ! (
271275 output_merged_tests,
272276 "
273277mod {test_id} {{
274278pub const TEST: test::TestDescAndFn = test::TestDescAndFn::new_doctest(
275- {test_name:?}, {ignore}, {file:?}, {line}, {no_run}, false,
279+ {test_name:?}, {ignore} || ({should_panic} && crate::__doctest_mod::SHOULD_PANIC_DISABLED) , {file:?}, {line}, {no_run}, false,
276280test::StaticTestFn(
277281 || {{{runner}}},
278282));
@@ -288,13 +292,14 @@ test::StaticTestFn(
288292 } else {
289293 format!(
290294 "
291- if let Some(bin_path) = crate::__doctest_mod::doctest_path() {{
295+ if {should_panic} && crate::__doctest_mod::SHOULD_PANIC_DISABLED {{
296+ test::assert_test_result(Ok::<(), String>(()))
297+ }} else if let Some(bin_path) = crate::__doctest_mod::doctest_path() {{
292298 test::assert_test_result(crate::__doctest_mod::doctest_runner(bin_path, {id}, {should_panic}))
293299}} else {{
294300 test::assert_test_result(doctest_bundle::{test_id}::__main_fn())
295301}}
296302" ,
297- should_panic = scraped_test. langstr. should_panic,
298303 )
299304 } ,
300305 )
0 commit comments