@@ -129,6 +129,9 @@ mod __doctest_mod {{
129
129
130
130
pub static BINARY_PATH: OnceLock<PathBuf> = OnceLock::new();
131
131
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\" );
132
135
133
136
#[allow(unused)]
134
137
pub fn doctest_path() -> Option<&'static PathBuf> {{
@@ -266,13 +269,14 @@ fn main() {returns_result} {{
266
269
)
267
270
. unwrap ( ) ;
268
271
}
272
+ let should_panic = scraped_test. langstr . should_panic ;
269
273
let not_running = ignore || scraped_test. no_run ( opts) ;
270
274
writeln ! (
271
275
output_merged_tests,
272
276
"
273
277
mod {test_id} {{
274
278
pub 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,
276
280
test::StaticTestFn(
277
281
|| {{{runner}}},
278
282
));
@@ -288,13 +292,14 @@ test::StaticTestFn(
288
292
} else {
289
293
format!(
290
294
"
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() {{
292
298
test::assert_test_result(crate::__doctest_mod::doctest_runner(bin_path, {id}, {should_panic}))
293
299
}} else {{
294
300
test::assert_test_result(doctest_bundle::{test_id}::__main_fn())
295
301
}}
296
302
" ,
297
- should_panic = scraped_test. langstr. should_panic,
298
303
)
299
304
} ,
300
305
)
0 commit comments