mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-25 05:14:27 +00:00
report doctest compile failures correctly
This commit is contained in:
parent
33654195a1
commit
41e7ac16c4
@ -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 old = io::set_panic(Some(box Sink(data.clone())));
|
||||||
let _bomb = Bomb(data.clone(), old.unwrap_or(box io::stdout()));
|
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(
|
let codemap = Lrc::new(CodeMap::new_doctest(
|
||||||
sessopts.file_path_mapping(), filename.clone(), line as isize - line_offset as isize
|
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(())
|
Err(_) | Ok(Err(CompileIncomplete::Errored(_))) => Err(())
|
||||||
};
|
};
|
||||||
|
|
||||||
match (compile_result, compile_fail) {
|
(libdir, outdir, compile_result)
|
||||||
(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)
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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 }
|
if no_run { return }
|
||||||
|
|
||||||
// Run the code!
|
// Run the code!
|
||||||
|
@ -17,3 +17,8 @@
|
|||||||
/// panic!("oh no");
|
/// panic!("oh no");
|
||||||
/// ```
|
/// ```
|
||||||
pub struct SomeStruct;
|
pub struct SomeStruct;
|
||||||
|
|
||||||
|
/// ```
|
||||||
|
/// no
|
||||||
|
/// ```
|
||||||
|
pub struct OtherStruct;
|
||||||
|
@ -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
|
test src/test/rustdoc-ui/failed-doctest-output.rs - SomeStruct (line 16) ... FAILED
|
||||||
|
|
||||||
failures:
|
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 ----
|
---- 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:
|
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.
|
note: Run with `RUST_BACKTRACE=1` for a backtrace.
|
||||||
|
|
||||||
', librustdoc/test.rs:367:17
|
', librustdoc/test.rs:367:17
|
||||||
note: Run with `RUST_BACKTRACE=1` for a backtrace.
|
|
||||||
|
|
||||||
|
|
||||||
failures:
|
failures:
|
||||||
|
src/test/rustdoc-ui/failed-doctest-output.rs - OtherStruct (line 21)
|
||||||
src/test/rustdoc-ui/failed-doctest-output.rs - SomeStruct (line 16)
|
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
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user