diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index c1beb453acc..c7d2e52e620 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -260,7 +260,7 @@ fn run_test(test: &str, cratename: &str, filename: &FileName, line: usize, let old = io::set_panic(Some(box Sink(data.clone()))); let _bomb = Bomb(data.clone(), old.unwrap_or(box io::stdout())); - let (libdir, outdir) = driver::spawn_thread_pool(sessopts, |sessopts| { + let (libdir, outdir, compile_result) = driver::spawn_thread_pool(sessopts, |sessopts| { let codemap = Lrc::new(CodeMap::new_doctest( sessopts.file_path_mapping(), filename.clone(), line as isize - line_offset as isize )); @@ -314,29 +314,29 @@ fn run_test(test: &str, cratename: &str, filename: &FileName, line: usize, Err(_) | Ok(Err(CompileIncomplete::Errored(_))) => Err(()) }; - match (compile_result, compile_fail) { - (Ok(()), true) => { - panic!("test compiled while it wasn't supposed to") - } - (Ok(()), false) => {} - (Err(()), true) => { - if error_codes.len() > 0 { - let out = String::from_utf8(data.lock().unwrap().to_vec()).unwrap(); - error_codes.retain(|err| !out.contains(err)); - } - } - (Err(()), false) => { - panic!("couldn't compile the test") - } - } - - if error_codes.len() > 0 { - panic!("Some expected error codes were not found: {:?}", error_codes); - } - - (libdir, outdir) + (libdir, outdir, compile_result) }); + match (compile_result, compile_fail) { + (Ok(()), true) => { + panic!("test compiled while it wasn't supposed to") + } + (Ok(()), false) => {} + (Err(()), true) => { + if error_codes.len() > 0 { + let out = String::from_utf8(data.lock().unwrap().to_vec()).unwrap(); + error_codes.retain(|err| !out.contains(err)); + } + } + (Err(()), false) => { + panic!("couldn't compile the test") + } + } + + if error_codes.len() > 0 { + panic!("Some expected error codes were not found: {:?}", error_codes); + } + if no_run { return } // Run the code! diff --git a/src/test/rustdoc-ui/failed-doctest-output.rs b/src/test/rustdoc-ui/failed-doctest-output.rs index 587a5def2dd..21d3d94714a 100644 --- a/src/test/rustdoc-ui/failed-doctest-output.rs +++ b/src/test/rustdoc-ui/failed-doctest-output.rs @@ -17,3 +17,8 @@ /// panic!("oh no"); /// ``` pub struct SomeStruct; + +/// ``` +/// no +/// ``` +pub struct OtherStruct; diff --git a/src/test/rustdoc-ui/failed-doctest-output.stdout b/src/test/rustdoc-ui/failed-doctest-output.stdout index 78cc0370d31..08522d80225 100644 --- a/src/test/rustdoc-ui/failed-doctest-output.stdout +++ b/src/test/rustdoc-ui/failed-doctest-output.stdout @@ -1,9 +1,20 @@ -running 1 test +running 2 tests +test src/test/rustdoc-ui/failed-doctest-output.rs - OtherStruct (line 21) ... FAILED test src/test/rustdoc-ui/failed-doctest-output.rs - SomeStruct (line 16) ... FAILED failures: +---- src/test/rustdoc-ui/failed-doctest-output.rs - OtherStruct (line 21) stdout ---- +error[E0425]: cannot find value `no` in this scope + --> src/test/rustdoc-ui/failed-doctest-output.rs:22:1 + | +3 | no + | ^^ not found in this scope + +thread 'src/test/rustdoc-ui/failed-doctest-output.rs - OtherStruct (line 21)' panicked at 'couldn't compile the test', librustdoc/test.rs:332:13 +note: Run with `RUST_BACKTRACE=1` for a backtrace. + ---- src/test/rustdoc-ui/failed-doctest-output.rs - SomeStruct (line 16) stdout ---- thread 'src/test/rustdoc-ui/failed-doctest-output.rs - SomeStruct (line 16)' panicked at 'test executable failed: @@ -11,11 +22,11 @@ thread 'main' panicked at 'oh no', src/test/rustdoc-ui/failed-doctest-output.rs: note: Run with `RUST_BACKTRACE=1` for a backtrace. ', librustdoc/test.rs:367:17 -note: Run with `RUST_BACKTRACE=1` for a backtrace. failures: + src/test/rustdoc-ui/failed-doctest-output.rs - OtherStruct (line 21) src/test/rustdoc-ui/failed-doctest-output.rs - SomeStruct (line 16) -test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out +test result: FAILED. 0 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out