Skip to content

Commit 388265e

Browse files
committed
Normalize away paths in the test output
1 parent 6d8ad4f commit 388265e

File tree

2 files changed

+30
-10
lines changed

2 files changed

+30
-10
lines changed

tests/integration.rs

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,33 @@ fn run(name: &str, mode: Mode) -> Result<()> {
3737
config.stderr_filter("in [0-9\\.]+s", "");
3838
config.stderr_filter("( Running [^(]+).*", "$1");
3939
config.stderr_filter(" Compiling .*\n", "");
40+
config.stderr_filter(
41+
&std::path::Path::new(path)
42+
.canonicalize()
43+
.unwrap()
44+
.parent()
45+
.unwrap()
46+
.display()
47+
.to_string(),
48+
"$$DIR",
49+
);
50+
config.stderr_filter("[0-9a-f]+\\.rmeta", "$$HASH.rmeta");
4051

4152
run_tests_generic(config, |path| {
42-
let fail = path.parent().unwrap().file_name().unwrap().to_str().unwrap().ends_with("-fail");
43-
path.ends_with("Cargo.toml") && path.parent().unwrap().parent().unwrap() == root_dir && match mode {
44-
Mode::Pass => !fail,
45-
Mode::Panic => unreachable!(),
46-
Mode::Fail { .. } => fail,
47-
}
53+
let fail = path
54+
.parent()
55+
.unwrap()
56+
.file_name()
57+
.unwrap()
58+
.to_str()
59+
.unwrap()
60+
.ends_with("-fail");
61+
path.ends_with("Cargo.toml")
62+
&& path.parent().unwrap().parent().unwrap() == root_dir
63+
&& match mode {
64+
Mode::Pass => !fail,
65+
Mode::Panic => unreachable!(),
66+
Mode::Fail { .. } => fail,
67+
}
4868
})
4969
}

tests/integrations/basic-fail/Cargo.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ tests/actual_tests/bad_pattern.rs ... FAILED
77
tests/actual_tests/foomp.rs ... FAILED
88

99
tests/actual_tests/bad_pattern.rs FAILED:
10-
command: "rustc" "--error-format=json" "--edition=2021" "--extern" "basic_fail=/home/ubuntu/crates/ui_test/$DIR/../../../target/debug/deps/libbasic_fail-8603f4ccb2fe730c.rmeta" "-L" "/home/ubuntu/crates/ui_test/$DIR/../../../target/debug" "-L" "/home/ubuntu/crates/ui_test/$DIR/../../../target/debug/deps" "tests/actual_tests/bad_pattern.rs"
10+
command: "rustc" "--error-format=json" "--edition=2021" "--extern" "basic_fail=$DIR/$DIR/../../../target/debug/deps/libbasic_fail-$HASH.rmeta" "-L" "$DIR/$DIR/../../../target/debug/deps" "-L" "$DIR/$DIR/../../../target/debug" "tests/actual_tests/bad_pattern.rs"
1111

1212
substring `miesmätsched types` not found in stderr output
1313
expected because of pattern here: tests/actual_tests/bad_pattern.rs:5
@@ -25,7 +25,7 @@ error[E0308]: mismatched types
2525
| arguments to this function are incorrect
2626
|
2727
note: function defined here
28-
--> /home/ubuntu/crates/ui_test/$DIR/src/lib.rs:1:8
28+
--> $DIR/$DIR/src/lib.rs:1:8
2929
|
3030
1 | pub fn add(left: usize, right: usize) -> usize {
3131
| ^^^
@@ -37,7 +37,7 @@ For more information about this error, try `rustc --explain E0308`.
3737

3838

3939
tests/actual_tests/foomp.rs FAILED:
40-
command: "rustc" "--error-format=json" "--edition=2021" "--extern" "basic_fail=/home/ubuntu/crates/ui_test/$DIR/../../../target/debug/deps/libbasic_fail-8603f4ccb2fe730c.rmeta" "-L" "/home/ubuntu/crates/ui_test/$DIR/../../../target/debug" "-L" "/home/ubuntu/crates/ui_test/$DIR/../../../target/debug/deps" "tests/actual_tests/foomp.rs"
40+
command: "rustc" "--error-format=json" "--edition=2021" "--extern" "basic_fail=$DIR/$DIR/../../../target/debug/deps/libbasic_fail-$HASH.rmeta" "-L" "$DIR/$DIR/../../../target/debug/deps" "-L" "$DIR/$DIR/../../../target/debug" "tests/actual_tests/foomp.rs"
4141

4242
actual output differed from expected tests/actual_tests/foomp.stderr
4343
Diff < left / right > :
@@ -75,7 +75,7 @@ error[E0308]: mismatched types
7575
| arguments to this function are incorrect
7676
|
7777
note: function defined here
78-
--> /home/ubuntu/crates/ui_test/$DIR/src/lib.rs:1:8
78+
--> $DIR/$DIR/src/lib.rs:1:8
7979
|
8080
1 | pub fn add(left: usize, right: usize) -> usize {
8181
| ^^^

0 commit comments

Comments
 (0)