Skip to content

Commit df64a22

Browse files
committed
Add normalization to compiletest so it doesn't need to be specified everywhere
1 parent b3f733e commit df64a22

File tree

55 files changed

+65
-87
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+65
-87
lines changed

src/tools/compiletest/src/runtest.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2413,6 +2413,11 @@ impl<'test> TestCx<'test> {
24132413
})
24142414
.into_owned();
24152415

2416+
// Normalize thread IDs in panic messages
2417+
normalized = static_regex!(r"thread '(?P<name>.*?)' \(0x[[:xdigit:]]+\) panicked")
2418+
.replace_all(&normalized, "thread '$name' (tid) panicked")
2419+
.into_owned();
2420+
24162421
normalized = normalized.replace("\t", "\\t"); // makes tabs visible
24172422

24182423
// Remove test annotations like `//~ ERROR text` from the output,
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11

22
running 1 test
3-
test $DIR/edition-2024-error-output.rs - (line 12) ... FAILED
3+
test $DIR/edition-2024-error-output.rs - (line 13) ... FAILED
44

55
failures:
66

7-
---- $DIR/edition-2024-error-output.rs - (line 12) stdout ----
7+
---- $DIR/edition-2024-error-output.rs - (line 13) stdout ----
88
Test executable failed (exit status: 101).
99

1010
stderr:
1111

12-
thread 'main' panicked at $TMP:6:1:
12+
thread 'main' (tid) panicked at $TMP:6:1:
1313
assertion `left == right` failed
1414
left: 4
1515
right: 5
@@ -18,7 +18,7 @@ note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
1818

1919

2020
failures:
21-
$DIR/edition-2024-error-output.rs - (line 12)
21+
$DIR/edition-2024-error-output.rs - (line 13)
2222

2323
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
2424

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11

22
running 2 tests
3-
test $DIR/failed-doctest-output.rs - OtherStruct (line 25) ... FAILED
4-
test $DIR/failed-doctest-output.rs - SomeStruct (line 15) ... FAILED
3+
test $DIR/failed-doctest-output.rs - OtherStruct (line 26) ... FAILED
4+
test $DIR/failed-doctest-output.rs - SomeStruct (line 16) ... FAILED
55

66
failures:
77

8-
---- $DIR/failed-doctest-output.rs - OtherStruct (line 25) stdout ----
8+
---- $DIR/failed-doctest-output.rs - OtherStruct (line 26) stdout ----
99
error[E0425]: cannot find value `no` in this scope
10-
--> $DIR/failed-doctest-output.rs:26:1
10+
--> $DIR/failed-doctest-output.rs:27:1
1111
|
1212
LL | no
1313
| ^^ not found in this scope
@@ -16,7 +16,7 @@ error: aborting due to 1 previous error
1616

1717
For more information about this error, try `rustc --explain E0425`.
1818
Couldn't compile the test.
19-
---- $DIR/failed-doctest-output.rs - SomeStruct (line 15) stdout ----
19+
---- $DIR/failed-doctest-output.rs - SomeStruct (line 16) stdout ----
2020
Test executable failed (exit status: 101).
2121

2222
stdout:
@@ -27,15 +27,15 @@ stderr:
2727
stderr 1
2828
stderr 2
2929

30-
thread 'main' panicked at $DIR/failed-doctest-output.rs:7:1:
30+
thread 'main' (tid) panicked at $DIR/failed-doctest-output.rs:7:1:
3131
oh no
3232
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
3333

3434

3535

3636
failures:
37-
$DIR/failed-doctest-output.rs - OtherStruct (line 25)
38-
$DIR/failed-doctest-output.rs - SomeStruct (line 15)
37+
$DIR/failed-doctest-output.rs - OtherStruct (line 26)
38+
$DIR/failed-doctest-output.rs - SomeStruct (line 16)
3939

4040
test result: FAILED. 0 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
4141

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

22
running 3 tests
3-
test $DIR/stdout-and-stderr.rs - (line 15) ... FAILED
4-
test $DIR/stdout-and-stderr.rs - (line 20) ... FAILED
5-
test $DIR/stdout-and-stderr.rs - (line 24) ... FAILED
3+
test $DIR/stdout-and-stderr.rs - (line 16) ... FAILED
4+
test $DIR/stdout-and-stderr.rs - (line 21) ... FAILED
5+
test $DIR/stdout-and-stderr.rs - (line 25) ... FAILED
66

77
failures:
88

9-
---- $DIR/stdout-and-stderr.rs - (line 15) stdout ----
9+
---- $DIR/stdout-and-stderr.rs - (line 16) stdout ----
1010
Test executable failed (exit status: 101).
1111

1212
stdout:
1313
######## from a DOC TEST ########
1414

1515
stderr:
1616

17-
thread 'main' panicked at $TMP:7:1:
17+
thread 'main' (tid) panicked at $TMP:7:1:
1818
assertion `left == right` failed
1919
left: "doc"
2020
right: "test"
2121
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
2222

2323

24-
---- $DIR/stdout-and-stderr.rs - (line 20) stdout ----
24+
---- $DIR/stdout-and-stderr.rs - (line 21) stdout ----
2525
Test executable failed (exit status: 101).
2626

2727
stderr:
2828

29-
thread 'main' panicked at $TMP:15:1:
29+
thread 'main' (tid) panicked at $TMP:15:1:
3030
assertion `left == right` failed
3131
left: "doc"
3232
right: "test"
3333
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
3434

3535

36-
---- $DIR/stdout-and-stderr.rs - (line 24) stdout ----
36+
---- $DIR/stdout-and-stderr.rs - (line 25) stdout ----
3737
Test executable failed (exit status: 1).
3838

3939

4040
failures:
41-
$DIR/stdout-and-stderr.rs - (line 15)
42-
$DIR/stdout-and-stderr.rs - (line 20)
43-
$DIR/stdout-and-stderr.rs - (line 24)
41+
$DIR/stdout-and-stderr.rs - (line 16)
42+
$DIR/stdout-and-stderr.rs - (line 21)
43+
$DIR/stdout-and-stderr.rs - (line 25)
4444

4545
test result: FAILED. 0 passed; 3 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
4646

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

22
running 1 test
3-
test remapped_path/remap-path-prefix-failed-doctest-output.rs - SomeStruct (line 11) ... FAILED
3+
test remapped_path/remap-path-prefix-failed-doctest-output.rs - SomeStruct (line 12) ... FAILED
44

55
failures:
66

7-
---- remapped_path/remap-path-prefix-failed-doctest-output.rs - SomeStruct (line 11) stdout ----
7+
---- remapped_path/remap-path-prefix-failed-doctest-output.rs - SomeStruct (line 12) stdout ----
88
Test executable failed (exit status: 101).
99

1010
stderr:
1111

12-
thread 'main' panicked at remapped_path/remap-path-prefix-failed-doctest-output.rs:3:1:
12+
thread 'main' (0x5119f2) panicked at remapped_path/remap-path-prefix-failed-doctest-output.rs:3:1:
1313
oh no
1414
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
1515

1616

1717

1818
failures:
19-
remapped_path/remap-path-prefix-failed-doctest-output.rs - SomeStruct (line 11)
19+
remapped_path/remap-path-prefix-failed-doctest-output.rs - SomeStruct (line 12)
2020

2121
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
2222

tests/ui/backtrace/synchronized-panic-handler.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
//@ exec-env:RUST_BACKTRACE=0
55
//@ needs-threads
66
//@ needs-unwind
7-
//@ normalize-stderr: "(thread '.*') \(0x[[:xdigit:]]+\)" -> "$1 (tid)"
87

98
use std::thread;
109
const PANIC_MESSAGE: &str = "oops oh no woe is me";
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

2-
thread '<unnamed>' (tid) panicked at $DIR/synchronized-panic-handler.rs:13:5:
2+
thread '<unnamed>' (tid) panicked at $DIR/synchronized-panic-handler.rs:12:5:
33
oops oh no woe is me
44
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
55

6-
thread '<unnamed>' (tid) panicked at $DIR/synchronized-panic-handler.rs:13:5:
6+
thread '<unnamed>' (tid) panicked at $DIR/synchronized-panic-handler.rs:12:5:
77
oops oh no woe is me

tests/ui/extern/extern-types-field-offset.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//@ run-fail
22
//@ check-run-results
33
//@ exec-env:RUST_BACKTRACE=0
4-
//@ normalize-stderr: "(thread '.*') \(0x[[:xdigit:]]+\)" -> "$1 (tid)"
54
//@ normalize-stderr: "(core/src/panicking\.rs):[0-9]+:[0-9]+" -> "$1:$$LINE:$$COL"
65

76
#![feature(extern_types)]

tests/ui/extern/extern-types-size_of_val.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//@ run-fail
22
//@ check-run-results
33
//@ exec-env:RUST_BACKTRACE=0
4-
//@ normalize-stderr: "(thread '.*') \(0x[[:xdigit:]]+\)" -> "$1 (tid)"
54
//@ normalize-stderr: "(core/src/panicking\.rs):[0-9]+:[0-9]+" -> "$1:$$LINE:$$COL"
65
//@ revisions: size align
76
#![feature(extern_types)]

tests/ui/hygiene/panic-location.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//@ run-fail
22
//@ check-run-results
33
//@ exec-env:RUST_BACKTRACE=0
4-
//@ normalize-stderr: "(thread '.*') \(0x[[:xdigit:]]+\)" -> "$1 (tid)"
54
//@ normalize-stderr: ".rs:\d+:\d+" -> ".rs:LL:CC"
65

76
// Regression test for issue #70963

0 commit comments

Comments
 (0)