forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#60549 - euclio:doctest-panic-messages, r=Gu…
…illaumeGomez do not print panic message on doctest failures This PR cleans up rustdoc test output by silently unwinding on failure instead of using `panic!`. It also improves the clarity and consistency of the output on test failure, and adds test cases for failure modes that were previously untested.
- Loading branch information
Showing
10 changed files
with
224 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// FIXME: if/when the output of the test harness can be tested on its own, this test should be | ||
// adapted to use that, and that normalize line can go away | ||
|
||
// compile-flags:--test | ||
// normalize-stdout-test: "src/test/rustdoc-ui" -> "$$DIR" | ||
// failure-status: 101 | ||
|
||
/// ```compile_fail | ||
/// println!("Hello"); | ||
/// ``` | ||
pub struct Foo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
running 1 test | ||
test $DIR/failed-doctest-compile-fail.rs - Foo (line 8) ... FAILED | ||
|
||
failures: | ||
|
||
---- $DIR/failed-doctest-compile-fail.rs - Foo (line 8) stdout ---- | ||
Test compiled successfully, but it's marked `compile_fail`. | ||
|
||
failures: | ||
$DIR/failed-doctest-compile-fail.rs - Foo (line 8) | ||
|
||
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// FIXME: if/when the output of the test harness can be tested on its own, this test should be | ||
// adapted to use that, and that normalize line can go away | ||
|
||
// compile-flags:--test | ||
// normalize-stdout-test: "src/test/rustdoc-ui" -> "$$DIR" | ||
// failure-status: 101 | ||
|
||
/// ```compile_fail,E0004 | ||
/// let x: () = 5i32; | ||
/// ``` | ||
pub struct Foo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
running 1 test | ||
test $DIR/failed-doctest-missing-codes.rs - Foo (line 8) ... FAILED | ||
|
||
failures: | ||
|
||
---- $DIR/failed-doctest-missing-codes.rs - Foo (line 8) stdout ---- | ||
error[E0308]: mismatched types | ||
--> $DIR/failed-doctest-missing-codes.rs:9:13 | ||
| | ||
3 | let x: () = 5i32; | ||
| ^^^^ expected (), found i32 | ||
| | ||
= note: expected type `()` | ||
found type `i32` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0308`. | ||
Some expected error codes were not found: ["E0004"] | ||
|
||
failures: | ||
$DIR/failed-doctest-missing-codes.rs - Foo (line 8) | ||
|
||
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,39 @@ | ||
|
||
running 2 tests | ||
test $DIR/failed-doctest-output.rs - OtherStruct (line 17) ... FAILED | ||
test $DIR/failed-doctest-output.rs - SomeStruct (line 11) ... FAILED | ||
test $DIR/failed-doctest-output.rs - OtherStruct (line 20) ... FAILED | ||
test $DIR/failed-doctest-output.rs - SomeStruct (line 10) ... FAILED | ||
|
||
failures: | ||
|
||
---- $DIR/failed-doctest-output.rs - OtherStruct (line 17) stdout ---- | ||
---- $DIR/failed-doctest-output.rs - OtherStruct (line 20) stdout ---- | ||
error[E0425]: cannot find value `no` in this scope | ||
--> $DIR/failed-doctest-output.rs:18:1 | ||
--> $DIR/failed-doctest-output.rs:21:1 | ||
| | ||
3 | no | ||
| ^^ not found in this scope | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0425`. | ||
thread '$DIR/failed-doctest-output.rs - OtherStruct (line 17)' panicked at 'couldn't compile the test', src/librustdoc/test.rs:320:13 | ||
Couldn't compile the test. | ||
---- $DIR/failed-doctest-output.rs - SomeStruct (line 10) stdout ---- | ||
Test executable failed (exit code 101). | ||
|
||
stdout: | ||
stdout 1 | ||
stdout 2 | ||
|
||
stderr: | ||
stderr 1 | ||
stderr 2 | ||
thread 'main' panicked at 'oh no', $DIR/failed-doctest-output.rs:7:1 | ||
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace. | ||
|
||
---- $DIR/failed-doctest-output.rs - SomeStruct (line 11) stdout ---- | ||
thread '$DIR/failed-doctest-output.rs - SomeStruct (line 11)' panicked at 'test executable failed: | ||
|
||
thread 'main' panicked at 'oh no', $DIR/failed-doctest-output.rs:3:1 | ||
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace. | ||
|
||
', src/librustdoc/test.rs:342:17 | ||
|
||
|
||
failures: | ||
$DIR/failed-doctest-output.rs - OtherStruct (line 17) | ||
$DIR/failed-doctest-output.rs - SomeStruct (line 11) | ||
$DIR/failed-doctest-output.rs - OtherStruct (line 20) | ||
$DIR/failed-doctest-output.rs - SomeStruct (line 10) | ||
|
||
test result: FAILED. 0 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// FIXME: if/when the output of the test harness can be tested on its own, this test should be | ||
// adapted to use that, and that normalize line can go away | ||
|
||
// compile-flags:--test | ||
// normalize-stdout-test: "src/test/rustdoc-ui" -> "$$DIR" | ||
// failure-status: 101 | ||
|
||
/// ```should_panic | ||
/// println!("Hello, world!"); | ||
/// ``` | ||
pub struct Foo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
running 1 test | ||
test $DIR/failed-doctest-should-panic.rs - Foo (line 8) ... FAILED | ||
|
||
failures: | ||
|
||
---- $DIR/failed-doctest-should-panic.rs - Foo (line 8) stdout ---- | ||
Test executable succeeded, but it's marked `should_panic`. | ||
|
||
failures: | ||
$DIR/failed-doctest-should-panic.rs - Foo (line 8) | ||
|
||
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters