Skip to content

Commit dae1df6

Browse files
committed
Fix test case for windows
1 parent 898ff01 commit dae1df6

File tree

3 files changed

+70
-0
lines changed

3 files changed

+70
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// only-windows
2+
// There's a parallel generic version of this test for POSIXy platforms.
3+
4+
// Issue #51162: A failed doctest was not printing its stdout/stderr
5+
// FIXME: if/when the output of the test harness can be tested on its own, this test should be
6+
// adapted to use that, and that normalize line can go away
7+
8+
// compile-flags:--test --test-args --test-threads=1
9+
// rustc-env:RUST_BACKTRACE=0
10+
// normalize-stdout-test: "src/test/rustdoc-ui" -> "$$DIR"
11+
// normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME"
12+
// failure-status: 101
13+
14+
// doctest fails at runtime
15+
/// ```
16+
/// println!("stdout 1");
17+
/// eprintln!("stderr 1");
18+
/// println!("stdout 2");
19+
/// eprintln!("stderr 2");
20+
/// panic!("oh no");
21+
/// ```
22+
pub struct SomeStruct;
23+
24+
// doctest fails at compile time
25+
/// ```
26+
/// no
27+
/// ```
28+
pub struct OtherStruct;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
2+
running 2 tests
3+
test $DIR/failed-doctest-output.rs - OtherStruct (line 22) ... FAILED
4+
test $DIR/failed-doctest-output.rs - SomeStruct (line 12) ... FAILED
5+
6+
failures:
7+
8+
---- $DIR/failed-doctest-output.rs - OtherStruct (line 22) stdout ----
9+
error[E0425]: cannot find value `no` in this scope
10+
--> $DIR/failed-doctest-output.rs:23:1
11+
|
12+
LL | no
13+
| ^^ not found in this scope
14+
15+
error: aborting due to previous error
16+
17+
For more information about this error, try `rustc --explain E0425`.
18+
Couldn't compile the test.
19+
---- $DIR/failed-doctest-output.rs - SomeStruct (line 12) stdout ----
20+
Test executable failed (exit code: 101).
21+
22+
stdout:
23+
stdout 1
24+
stdout 2
25+
26+
stderr:
27+
stderr 1
28+
stderr 2
29+
thread 'main' panicked at 'oh no', $DIR/failed-doctest-output.rs:7:1
30+
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
31+
32+
33+
34+
failures:
35+
$DIR/failed-doctest-output.rs - OtherStruct (line 22)
36+
$DIR/failed-doctest-output.rs - SomeStruct (line 12)
37+
38+
test result: FAILED. 0 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
39+

src/test/rustdoc-ui/failed-doctest-output.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// ignore-windows
2+
// There's a parallel version of this test for Windows.
3+
14
// Issue #51162: A failed doctest was not printing its stdout/stderr
25
// FIXME: if/when the output of the test harness can be tested on its own, this test should be
36
// adapted to use that, and that normalize line can go away

0 commit comments

Comments
 (0)