Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 2fd8d1c

Browse files
Add/update rustdoc-ui tests to check new merged doctests
1 parent 7ec3cab commit 2fd8d1c

8 files changed

+42
-9
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// FIXME: if/when the output of the test harness can be tested on its own, this test should be
2+
// adapted to use that, and that normalize line can go away
3+
4+
//@ compile-flags:--test --edition 2021
5+
//@ normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR"
6+
//@ normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME"
7+
//@ failure-status: 101
8+
9+
/// ```should_panic
10+
/// println!("Hello, world!");
11+
/// ```
12+
pub struct Foo;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
running 1 test
3+
test $DIR/failed-doctest-should-panic-2021.rs - Foo (line 9) ... FAILED
4+
5+
failures:
6+
7+
---- $DIR/failed-doctest-should-panic-2021.rs - Foo (line 9) stdout ----
8+
Test executable succeeded, but it's marked `should_panic`.
9+
10+
failures:
11+
$DIR/failed-doctest-should-panic-2021.rs - Foo (line 9)
12+
13+
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
14+

tests/rustdoc-ui/doctest/failed-doctest-should-panic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// FIXME: if/when the output of the test harness can be tested on its own, this test should be
22
// adapted to use that, and that normalize line can go away
33

4-
//@ compile-flags:--test
4+
//@ compile-flags:--test -Z unstable-options --edition 2024
55
//@ normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR"
66
//@ normalize-stdout-test: "finished in \d+\.\d+s" -> "finished in $$TIME"
77
//@ failure-status: 101

tests/rustdoc-ui/doctest/failed-doctest-should-panic.stdout

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11

22
running 1 test
3-
test $DIR/failed-doctest-should-panic.rs - Foo (line 9) ... FAILED
3+
test $DIR/failed-doctest-should-panic.rs - Foo (line 9) - should panic ... FAILED
44

55
failures:
66

77
---- $DIR/failed-doctest-should-panic.rs - Foo (line 9) stdout ----
8-
Test executable succeeded, but it's marked `should_panic`.
8+
Hello, world!
9+
note: test did not panic as expected
910

1011
failures:
1112
$DIR/failed-doctest-should-panic.rs - Foo (line 9)

tests/rustdoc-ui/doctest/wrong-ast-2024.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//@ compile-flags:--test --test-args=--test-threads=1 -Zunstable-options --edition 2024
22
//@ normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR"
33
//@ normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME"
4-
//@ normalize-stdout-test "wrong-ast.rs:\d+:\d+" -> "wrong-ast.rs:$$LINE:$$COL"
4+
//@ normalize-stdout-test ".rs:\d+:\d+" -> ".rs:$$LINE:$$COL"
55
//@ failure-status: 101
66

77
/// ```

tests/rustdoc-ui/doctest/wrong-ast-2024.stdout

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11

2+
running 1 test
3+
test $DIR/wrong-ast-2024.rs - three (line 17) - should panic ... ok
4+
5+
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
6+
7+
28
running 2 tests
39
test $DIR/wrong-ast-2024.rs - one (line 7) ... FAILED
410
test $DIR/wrong-ast-2024.rs - two (line 12) ... FAILED
@@ -7,18 +13,18 @@ failures:
713

814
---- $DIR/wrong-ast-2024.rs - one (line 7) stdout ----
915
error[E0758]: unterminated block comment
10-
--> $DIR/wrong-ast-2024.rs:8:1
16+
--> $DIR/wrong-ast-2024.rs:$LINE:$COL
1117
|
1218
LL | /* plop
13-
| ^^^^^^^^
19+
| ^^^^^^^
1420

1521
error: aborting due to 1 previous error
1622

1723
For more information about this error, try `rustc --explain E0758`.
1824
Couldn't compile the test.
1925
---- $DIR/wrong-ast-2024.rs - two (line 12) stdout ----
2026
error: unexpected closing delimiter: `}`
21-
--> $DIR/wrong-ast-2024.rs:13:1
27+
--> $DIR/wrong-ast-2024.rs:$LINE:$COL
2228
|
2329
LL | } mod __doctest_1 { fn main() {
2430
| ^ unexpected closing delimiter

tests/rustdoc-ui/doctest/wrong-ast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//@ compile-flags:--test --test-args=--test-threads=1
22
//@ normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR"
33
//@ normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME"
4-
//@ normalize-stdout-test "wrong-ast.rs:\d+:\d+" -> "wrong-ast.rs:$$LINE:$$COL"
4+
//@ normalize-stdout-test ".rs:\d+:\d+" -> ".rs:$$LINE:$$COL"
55
//@ failure-status: 101
66

77
/// ```

tests/rustdoc-ui/doctest/wrong-ast.stdout

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ error[E0758]: unterminated block comment
1111
--> $DIR/wrong-ast.rs:$LINE:$COL
1212
|
1313
LL | /* plop
14-
| ^^^^^^^^
14+
| ^^^^^^^
1515

1616
error: aborting due to 1 previous error
1717

0 commit comments

Comments
 (0)