Support regexes in custom normalization in UI tests

This commit is contained in:
Vadim Petrochenkov 2017-12-11 02:08:34 +03:00
parent 3fe1d9c524
commit c3a7d36c6e
21 changed files with 48 additions and 35 deletions

1
src/Cargo.lock generated
View File

@ -375,6 +375,7 @@ dependencies = [
"libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
]

View File

@ -14,6 +14,7 @@
// aux-build:changing-crates-a1.rs
// aux-build:changing-crates-b.rs
// aux-build:changing-crates-a2.rs
// normalize-stderr-test: "(crate `(\w+)`:) .*" -> "$1 $$PATH_$2"
extern crate a;
extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on

View File

@ -1,13 +1,13 @@
error[E0460]: found possibly newer version of crate `a` which `b` depends on
--> $DIR/changing-crates.rs:19:1
--> $DIR/changing-crates.rs:20:1
|
19 | extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on
20 | extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on
| ^^^^^^^^^^^^^^^
|
= note: perhaps that crate needs to be recompiled?
= note: the following crate versions were found:
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
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
crate `a`: $PATH_a
crate `b`: $PATH_b
error: aborting due to previous error

View File

@ -14,6 +14,7 @@
// aux-build:svh-a-base.rs
// aux-build:svh-b.rs
// aux-build:svh-a-change-lit.rs
// normalize-stderr-test: "(crate `(\w+)`:) .*" -> "$1 $$PATH_$2"
extern crate a;
extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on

View File

@ -1,13 +1,13 @@
error[E0460]: found possibly newer version of crate `a` which `b` depends on
--> $DIR/svh-change-lit.rs:19:1
--> $DIR/svh-change-lit.rs:20:1
|
19 | extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on
20 | extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on
| ^^^^^^^^^^^^^^^
|
= note: perhaps that crate needs to be recompiled?
= note: the following crate versions were found:
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
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
crate `a`: $PATH_a
crate `b`: $PATH_b
error: aborting due to previous error

View File

@ -14,6 +14,7 @@
// aux-build:svh-a-base.rs
// aux-build:svh-b.rs
// aux-build:svh-a-change-significant-cfg.rs
// normalize-stderr-test: "(crate `(\w+)`:) .*" -> "$1 $$PATH_$2"
extern crate a;
extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on

View File

@ -1,13 +1,13 @@
error[E0460]: found possibly newer version of crate `a` which `b` depends on
--> $DIR/svh-change-significant-cfg.rs:19:1
--> $DIR/svh-change-significant-cfg.rs:20:1
|
19 | extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on
20 | extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on
| ^^^^^^^^^^^^^^^
|
= note: perhaps that crate needs to be recompiled?
= note: the following crate versions were found:
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
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
crate `a`: $PATH_a
crate `b`: $PATH_b
error: aborting due to previous error

View File

@ -14,6 +14,7 @@
// aux-build:svh-a-base.rs
// aux-build:svh-b.rs
// aux-build:svh-a-change-trait-bound.rs
// normalize-stderr-test: "(crate `(\w+)`:) .*" -> "$1 $$PATH_$2"
extern crate a;
extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on

View File

@ -1,13 +1,13 @@
error[E0460]: found possibly newer version of crate `a` which `b` depends on
--> $DIR/svh-change-trait-bound.rs:19:1
--> $DIR/svh-change-trait-bound.rs:20:1
|
19 | extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on
20 | extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on
| ^^^^^^^^^^^^^^^
|
= note: perhaps that crate needs to be recompiled?
= note: the following crate versions were found:
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
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
crate `a`: $PATH_a
crate `b`: $PATH_b
error: aborting due to previous error

View File

@ -14,6 +14,7 @@
// aux-build:svh-a-base.rs
// aux-build:svh-b.rs
// aux-build:svh-a-change-type-arg.rs
// normalize-stderr-test: "(crate `(\w+)`:) .*" -> "$1 $$PATH_$2"
extern crate a;
extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on

View File

@ -1,13 +1,13 @@
error[E0460]: found possibly newer version of crate `a` which `b` depends on
--> $DIR/svh-change-type-arg.rs:19:1
--> $DIR/svh-change-type-arg.rs:20:1
|
19 | extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on
20 | extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on
| ^^^^^^^^^^^^^^^
|
= note: perhaps that crate needs to be recompiled?
= note: the following crate versions were found:
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
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
crate `a`: $PATH_a
crate `b`: $PATH_b
error: aborting due to previous error

View File

@ -14,6 +14,7 @@
// aux-build:svh-a-base.rs
// aux-build:svh-b.rs
// aux-build:svh-a-change-type-ret.rs
// normalize-stderr-test: "(crate `(\w+)`:) .*" -> "$1 $$PATH_$2"
extern crate a;
extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on

View File

@ -1,13 +1,13 @@
error[E0460]: found possibly newer version of crate `a` which `b` depends on
--> $DIR/svh-change-type-ret.rs:19:1
--> $DIR/svh-change-type-ret.rs:20:1
|
19 | extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on
20 | extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on
| ^^^^^^^^^^^^^^^
|
= note: perhaps that crate needs to be recompiled?
= note: the following crate versions were found:
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
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
crate `a`: $PATH_a
crate `b`: $PATH_b
error: aborting due to previous error

View File

@ -14,6 +14,7 @@
// aux-build:svh-a-base.rs
// aux-build:svh-b.rs
// aux-build:svh-a-change-type-static.rs
// normalize-stderr-test: "(crate `(\w+)`:) .*" -> "$1 $$PATH_$2"
extern crate a;
extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on

View File

@ -1,13 +1,13 @@
error[E0460]: found possibly newer version of crate `a` which `b` depends on
--> $DIR/svh-change-type-static.rs:19:1
--> $DIR/svh-change-type-static.rs:20:1
|
19 | extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on
20 | extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on
| ^^^^^^^^^^^^^^^
|
= note: perhaps that crate needs to be recompiled?
= note: the following crate versions were found:
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
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
crate `a`: $PATH_a
crate `b`: $PATH_b
error: aborting due to previous error

View File

@ -14,6 +14,7 @@
// aux-build:svh-uta-base.rs
// aux-build:svh-utb.rs
// aux-build:svh-uta-change-use-trait.rs
// normalize-stderr-test: "(crate `(\w+)`:) .*" -> "$1 $$PATH_$2"
//! "compile-fail/svh-uta-trait.rs" is checking that we detect a
//! change from `use foo::TraitB` to use `foo::TraitB` in the hash

View File

@ -1,13 +1,13 @@
error[E0460]: found possibly newer version of crate `uta` which `utb` depends on
--> $DIR/svh-use-trait.rs:24:1
--> $DIR/svh-use-trait.rs:25:1
|
24 | extern crate utb; //~ ERROR: found possibly newer version of crate `uta` which `utb` depends
25 | extern crate utb; //~ ERROR: found possibly newer version of crate `uta` which `utb` depends
| ^^^^^^^^^^^^^^^^^
|
= note: perhaps that crate needs to be recompiled?
= note: the following crate versions were found:
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
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
crate `uta`: $PATH_uta
crate `utb`: $PATH_utb
error: aborting due to previous error

View File

@ -8,8 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// normalize-stderr-32bit: "&str (64 bits)" -> "&str ($STR bits)"
// normalize-stderr-64bit: "&str (128 bits)" -> "&str ($STR bits)"
// normalize-stderr-32bit: "&str \(64 bits\)" -> "&str ($$STR bits)"
// normalize-stderr-64bit: "&str \(128 bits\)" -> "&str ($$STR bits)"

View File

@ -9,6 +9,7 @@ env_logger = { version = "0.4", default-features = false }
filetime = "0.1"
getopts = "0.2"
log = "0.3"
regex = "0.2"
rustc-serialize = "0.3"
[target.'cfg(unix)'.dependencies]

View File

@ -22,6 +22,7 @@ extern crate libc;
#[macro_use]
extern crate log;
extern crate rustc_serialize;
extern crate regex;
extern crate test;
use std::env;

View File

@ -20,6 +20,7 @@ use json;
use header::TestProps;
use test::TestPaths;
use util::logv;
use regex::Regex;
use std::collections::HashMap;
use std::collections::HashSet;
@ -2677,7 +2678,8 @@ impl<'test> TestCx<'test> {
.replace("\r\n", "\n") // normalize for linebreaks on windows
.replace("\t", "\\t"); // makes tabs visible
for rule in custom_rules {
normalized = normalized.replace(&rule.0, &rule.1);
let re = Regex::new(&rule.0).expect("bad regex in custom normalization rule");
normalized = re.replace_all(&normalized, &rule.1[..]).into_owned();
}
normalized
}