Skip to content

Commit c3a7d36

Browse files
committed
Support regexes in custom normalization in UI tests
1 parent 3fe1d9c commit c3a7d36

21 files changed

+48
-35
lines changed

src/Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/test/ui/changing-crates.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
// aux-build:changing-crates-a1.rs
1515
// aux-build:changing-crates-b.rs
1616
// aux-build:changing-crates-a2.rs
17+
// normalize-stderr-test: "(crate `(\w+)`:) .*" -> "$1 $$PATH_$2"
1718

1819
extern crate a;
1920
extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on

src/test/ui/changing-crates.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error[E0460]: found possibly newer version of crate `a` which `b` depends on
2-
--> $DIR/changing-crates.rs:19:1
2+
--> $DIR/changing-crates.rs:20:1
33
|
4-
19 | extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on
4+
20 | extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on
55
| ^^^^^^^^^^^^^^^
66
|
77
= note: perhaps that crate needs to be recompiled?
88
= note: the following crate versions were found:
9-
crate `a`: /?/C:/msys64/home/we/rust/build/x86_64-pc-windows-gnu/test/ui/changing-crates.stage1-x86_64-pc-windows-gnu.aux/a.dll
10-
crate `b`: /?/C:/msys64/home/we/rust/build/x86_64-pc-windows-gnu/test/ui/changing-crates.stage1-x86_64-pc-windows-gnu.aux/b.dll
9+
crate `a`: $PATH_a
10+
crate `b`: $PATH_b
1111

1212
error: aborting due to previous error
1313

src/test/ui/svh-change-lit.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
// aux-build:svh-a-base.rs
1515
// aux-build:svh-b.rs
1616
// aux-build:svh-a-change-lit.rs
17+
// normalize-stderr-test: "(crate `(\w+)`:) .*" -> "$1 $$PATH_$2"
1718

1819
extern crate a;
1920
extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on

src/test/ui/svh-change-lit.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error[E0460]: found possibly newer version of crate `a` which `b` depends on
2-
--> $DIR/svh-change-lit.rs:19:1
2+
--> $DIR/svh-change-lit.rs:20:1
33
|
4-
19 | extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on
4+
20 | extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on
55
| ^^^^^^^^^^^^^^^
66
|
77
= note: perhaps that crate needs to be recompiled?
88
= note: the following crate versions were found:
9-
crate `a`: /?/C:/msys64/home/we/rust/build/x86_64-pc-windows-gnu/test/ui/svh-change-lit.stage1-x86_64-pc-windows-gnu.aux/a.dll
10-
crate `b`: /?/C:/msys64/home/we/rust/build/x86_64-pc-windows-gnu/test/ui/svh-change-lit.stage1-x86_64-pc-windows-gnu.aux/b.dll
9+
crate `a`: $PATH_a
10+
crate `b`: $PATH_b
1111

1212
error: aborting due to previous error
1313

src/test/ui/svh-change-significant-cfg.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
// aux-build:svh-a-base.rs
1515
// aux-build:svh-b.rs
1616
// aux-build:svh-a-change-significant-cfg.rs
17+
// normalize-stderr-test: "(crate `(\w+)`:) .*" -> "$1 $$PATH_$2"
1718

1819
extern crate a;
1920
extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error[E0460]: found possibly newer version of crate `a` which `b` depends on
2-
--> $DIR/svh-change-significant-cfg.rs:19:1
2+
--> $DIR/svh-change-significant-cfg.rs:20:1
33
|
4-
19 | extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on
4+
20 | extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on
55
| ^^^^^^^^^^^^^^^
66
|
77
= note: perhaps that crate needs to be recompiled?
88
= note: the following crate versions were found:
9-
crate `a`: /?/C:/msys64/home/we/rust/build/x86_64-pc-windows-gnu/test/ui/svh-change-significant-cfg.stage1-x86_64-pc-windows-gnu.aux/a.dll
10-
crate `b`: /?/C:/msys64/home/we/rust/build/x86_64-pc-windows-gnu/test/ui/svh-change-significant-cfg.stage1-x86_64-pc-windows-gnu.aux/b.dll
9+
crate `a`: $PATH_a
10+
crate `b`: $PATH_b
1111

1212
error: aborting due to previous error
1313

src/test/ui/svh-change-trait-bound.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
// aux-build:svh-a-base.rs
1515
// aux-build:svh-b.rs
1616
// aux-build:svh-a-change-trait-bound.rs
17+
// normalize-stderr-test: "(crate `(\w+)`:) .*" -> "$1 $$PATH_$2"
1718

1819
extern crate a;
1920
extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error[E0460]: found possibly newer version of crate `a` which `b` depends on
2-
--> $DIR/svh-change-trait-bound.rs:19:1
2+
--> $DIR/svh-change-trait-bound.rs:20:1
33
|
4-
19 | extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on
4+
20 | extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on
55
| ^^^^^^^^^^^^^^^
66
|
77
= note: perhaps that crate needs to be recompiled?
88
= note: the following crate versions were found:
9-
crate `a`: /?/C:/msys64/home/we/rust/build/x86_64-pc-windows-gnu/test/ui/svh-change-trait-bound.stage1-x86_64-pc-windows-gnu.aux/a.dll
10-
crate `b`: /?/C:/msys64/home/we/rust/build/x86_64-pc-windows-gnu/test/ui/svh-change-trait-bound.stage1-x86_64-pc-windows-gnu.aux/b.dll
9+
crate `a`: $PATH_a
10+
crate `b`: $PATH_b
1111

1212
error: aborting due to previous error
1313

src/test/ui/svh-change-type-arg.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
// aux-build:svh-a-base.rs
1515
// aux-build:svh-b.rs
1616
// aux-build:svh-a-change-type-arg.rs
17+
// normalize-stderr-test: "(crate `(\w+)`:) .*" -> "$1 $$PATH_$2"
1718

1819
extern crate a;
1920
extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error[E0460]: found possibly newer version of crate `a` which `b` depends on
2-
--> $DIR/svh-change-type-arg.rs:19:1
2+
--> $DIR/svh-change-type-arg.rs:20:1
33
|
4-
19 | extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on
4+
20 | extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on
55
| ^^^^^^^^^^^^^^^
66
|
77
= note: perhaps that crate needs to be recompiled?
88
= note: the following crate versions were found:
9-
crate `a`: /?/C:/msys64/home/we/rust/build/x86_64-pc-windows-gnu/test/ui/svh-change-type-arg.stage1-x86_64-pc-windows-gnu.aux/a.dll
10-
crate `b`: /?/C:/msys64/home/we/rust/build/x86_64-pc-windows-gnu/test/ui/svh-change-type-arg.stage1-x86_64-pc-windows-gnu.aux/b.dll
9+
crate `a`: $PATH_a
10+
crate `b`: $PATH_b
1111

1212
error: aborting due to previous error
1313

src/test/ui/svh-change-type-ret.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
// aux-build:svh-a-base.rs
1515
// aux-build:svh-b.rs
1616
// aux-build:svh-a-change-type-ret.rs
17+
// normalize-stderr-test: "(crate `(\w+)`:) .*" -> "$1 $$PATH_$2"
1718

1819
extern crate a;
1920
extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error[E0460]: found possibly newer version of crate `a` which `b` depends on
2-
--> $DIR/svh-change-type-ret.rs:19:1
2+
--> $DIR/svh-change-type-ret.rs:20:1
33
|
4-
19 | extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on
4+
20 | extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on
55
| ^^^^^^^^^^^^^^^
66
|
77
= note: perhaps that crate needs to be recompiled?
88
= note: the following crate versions were found:
9-
crate `a`: /?/C:/msys64/home/we/rust/build/x86_64-pc-windows-gnu/test/ui/svh-change-type-ret.stage1-x86_64-pc-windows-gnu.aux/a.dll
10-
crate `b`: /?/C:/msys64/home/we/rust/build/x86_64-pc-windows-gnu/test/ui/svh-change-type-ret.stage1-x86_64-pc-windows-gnu.aux/b.dll
9+
crate `a`: $PATH_a
10+
crate `b`: $PATH_b
1111

1212
error: aborting due to previous error
1313

src/test/ui/svh-change-type-static.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
// aux-build:svh-a-base.rs
1515
// aux-build:svh-b.rs
1616
// aux-build:svh-a-change-type-static.rs
17+
// normalize-stderr-test: "(crate `(\w+)`:) .*" -> "$1 $$PATH_$2"
1718

1819
extern crate a;
1920
extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error[E0460]: found possibly newer version of crate `a` which `b` depends on
2-
--> $DIR/svh-change-type-static.rs:19:1
2+
--> $DIR/svh-change-type-static.rs:20:1
33
|
4-
19 | extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on
4+
20 | extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on
55
| ^^^^^^^^^^^^^^^
66
|
77
= note: perhaps that crate needs to be recompiled?
88
= note: the following crate versions were found:
9-
crate `a`: /?/C:/msys64/home/we/rust/build/x86_64-pc-windows-gnu/test/ui/svh-change-type-static.stage1-x86_64-pc-windows-gnu.aux/a.dll
10-
crate `b`: /?/C:/msys64/home/we/rust/build/x86_64-pc-windows-gnu/test/ui/svh-change-type-static.stage1-x86_64-pc-windows-gnu.aux/b.dll
9+
crate `a`: $PATH_a
10+
crate `b`: $PATH_b
1111

1212
error: aborting due to previous error
1313

src/test/ui/svh-use-trait.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
// aux-build:svh-uta-base.rs
1515
// aux-build:svh-utb.rs
1616
// aux-build:svh-uta-change-use-trait.rs
17+
// normalize-stderr-test: "(crate `(\w+)`:) .*" -> "$1 $$PATH_$2"
1718

1819
//! "compile-fail/svh-uta-trait.rs" is checking that we detect a
1920
//! change from `use foo::TraitB` to use `foo::TraitB` in the hash

src/test/ui/svh-use-trait.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error[E0460]: found possibly newer version of crate `uta` which `utb` depends on
2-
--> $DIR/svh-use-trait.rs:24:1
2+
--> $DIR/svh-use-trait.rs:25:1
33
|
4-
24 | extern crate utb; //~ ERROR: found possibly newer version of crate `uta` which `utb` depends
4+
25 | extern crate utb; //~ ERROR: found possibly newer version of crate `uta` which `utb` depends
55
| ^^^^^^^^^^^^^^^^^
66
|
77
= note: perhaps that crate needs to be recompiled?
88
= note: the following crate versions were found:
9-
crate `uta`: /?/C:/msys64/home/we/rust/build/x86_64-pc-windows-gnu/test/ui/svh-use-trait.stage1-x86_64-pc-windows-gnu.aux/uta.dll
10-
crate `utb`: /?/C:/msys64/home/we/rust/build/x86_64-pc-windows-gnu/test/ui/svh-use-trait.stage1-x86_64-pc-windows-gnu.aux/utb.dll
9+
crate `uta`: $PATH_uta
10+
crate `utb`: $PATH_utb
1111

1212
error: aborting due to previous error
1313

src/test/ui/transmute/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// normalize-stderr-32bit: "&str (64 bits)" -> "&str ($STR bits)"
12-
// normalize-stderr-64bit: "&str (128 bits)" -> "&str ($STR bits)"
11+
// normalize-stderr-32bit: "&str \(64 bits\)" -> "&str ($$STR bits)"
12+
// normalize-stderr-64bit: "&str \(128 bits\)" -> "&str ($$STR bits)"
1313

1414

1515

src/tools/compiletest/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ env_logger = { version = "0.4", default-features = false }
99
filetime = "0.1"
1010
getopts = "0.2"
1111
log = "0.3"
12+
regex = "0.2"
1213
rustc-serialize = "0.3"
1314

1415
[target.'cfg(unix)'.dependencies]

src/tools/compiletest/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ extern crate libc;
2222
#[macro_use]
2323
extern crate log;
2424
extern crate rustc_serialize;
25+
extern crate regex;
2526
extern crate test;
2627

2728
use std::env;

src/tools/compiletest/src/runtest.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use json;
2020
use header::TestProps;
2121
use test::TestPaths;
2222
use util::logv;
23+
use regex::Regex;
2324

2425
use std::collections::HashMap;
2526
use std::collections::HashSet;
@@ -2677,7 +2678,8 @@ impl<'test> TestCx<'test> {
26772678
.replace("\r\n", "\n") // normalize for linebreaks on windows
26782679
.replace("\t", "\\t"); // makes tabs visible
26792680
for rule in custom_rules {
2680-
normalized = normalized.replace(&rule.0, &rule.1);
2681+
let re = Regex::new(&rule.0).expect("bad regex in custom normalization rule");
2682+
normalized = re.replace_all(&normalized, &rule.1[..]).into_owned();
26812683
}
26822684
normalized
26832685
}

0 commit comments

Comments
 (0)