diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2017-12-11 02:08:34 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2017-12-14 23:26:40 +0300 |
| commit | c3a7d36c6e2da097f705525fc6bf7726360601f5 (patch) | |
| tree | 3d8e8f32ada45e6312c5530237d5ec3c3e4842fd | |
| parent | 3fe1d9c52445cb5cbb5bd9424ec1f8d6cc65a29f (diff) | |
| download | rust-c3a7d36c6e2da097f705525fc6bf7726360601f5.tar.gz rust-c3a7d36c6e2da097f705525fc6bf7726360601f5.zip | |
Support regexes in custom normalization in UI tests
| -rw-r--r-- | src/Cargo.lock | 1 | ||||
| -rw-r--r-- | src/test/ui/changing-crates.rs | 1 | ||||
| -rw-r--r-- | src/test/ui/changing-crates.stderr | 8 | ||||
| -rw-r--r-- | src/test/ui/svh-change-lit.rs | 1 | ||||
| -rw-r--r-- | src/test/ui/svh-change-lit.stderr | 8 | ||||
| -rw-r--r-- | src/test/ui/svh-change-significant-cfg.rs | 1 | ||||
| -rw-r--r-- | src/test/ui/svh-change-significant-cfg.stderr | 8 | ||||
| -rw-r--r-- | src/test/ui/svh-change-trait-bound.rs | 1 | ||||
| -rw-r--r-- | src/test/ui/svh-change-trait-bound.stderr | 8 | ||||
| -rw-r--r-- | src/test/ui/svh-change-type-arg.rs | 1 | ||||
| -rw-r--r-- | src/test/ui/svh-change-type-arg.stderr | 8 | ||||
| -rw-r--r-- | src/test/ui/svh-change-type-ret.rs | 1 | ||||
| -rw-r--r-- | src/test/ui/svh-change-type-ret.stderr | 8 | ||||
| -rw-r--r-- | src/test/ui/svh-change-type-static.rs | 1 | ||||
| -rw-r--r-- | src/test/ui/svh-change-type-static.stderr | 8 | ||||
| -rw-r--r-- | src/test/ui/svh-use-trait.rs | 1 | ||||
| -rw-r--r-- | src/test/ui/svh-use-trait.stderr | 8 | ||||
| -rw-r--r-- | src/test/ui/transmute/main.rs | 4 | ||||
| -rw-r--r-- | src/tools/compiletest/Cargo.toml | 1 | ||||
| -rw-r--r-- | src/tools/compiletest/src/main.rs | 1 | ||||
| -rw-r--r-- | src/tools/compiletest/src/runtest.rs | 4 |
21 files changed, 48 insertions, 35 deletions
diff --git a/src/Cargo.lock b/src/Cargo.lock index 27e7438ddfd..00f556bf0b2 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -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)", ] diff --git a/src/test/ui/changing-crates.rs b/src/test/ui/changing-crates.rs index 80a2998f3cd..5963a58a2d2 100644 --- a/src/test/ui/changing-crates.rs +++ b/src/test/ui/changing-crates.rs @@ -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 diff --git a/src/test/ui/changing-crates.stderr b/src/test/ui/changing-crates.stderr index e6c054183cb..50287fa3fde 100644 --- a/src/test/ui/changing-crates.stderr +++ b/src/test/ui/changing-crates.stderr @@ -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 diff --git a/src/test/ui/svh-change-lit.rs b/src/test/ui/svh-change-lit.rs index a4262eaff19..c529873e732 100644 --- a/src/test/ui/svh-change-lit.rs +++ b/src/test/ui/svh-change-lit.rs @@ -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 diff --git a/src/test/ui/svh-change-lit.stderr b/src/test/ui/svh-change-lit.stderr index 08c4809479e..94e845c527c 100644 --- a/src/test/ui/svh-change-lit.stderr +++ b/src/test/ui/svh-change-lit.stderr @@ -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 diff --git a/src/test/ui/svh-change-significant-cfg.rs b/src/test/ui/svh-change-significant-cfg.rs index 32ec6260362..ad51cbc5ec8 100644 --- a/src/test/ui/svh-change-significant-cfg.rs +++ b/src/test/ui/svh-change-significant-cfg.rs @@ -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 diff --git a/src/test/ui/svh-change-significant-cfg.stderr b/src/test/ui/svh-change-significant-cfg.stderr index 57c636d4aa5..d2744771ec7 100644 --- a/src/test/ui/svh-change-significant-cfg.stderr +++ b/src/test/ui/svh-change-significant-cfg.stderr @@ -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 diff --git a/src/test/ui/svh-change-trait-bound.rs b/src/test/ui/svh-change-trait-bound.rs index 0069d930a2d..ae17ff3feb7 100644 --- a/src/test/ui/svh-change-trait-bound.rs +++ b/src/test/ui/svh-change-trait-bound.rs @@ -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 diff --git a/src/test/ui/svh-change-trait-bound.stderr b/src/test/ui/svh-change-trait-bound.stderr index 40fb5aeaf14..e272f399f79 100644 --- a/src/test/ui/svh-change-trait-bound.stderr +++ b/src/test/ui/svh-change-trait-bound.stderr @@ -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 diff --git a/src/test/ui/svh-change-type-arg.rs b/src/test/ui/svh-change-type-arg.rs index e6685eb5260..5b796a3f5c0 100644 --- a/src/test/ui/svh-change-type-arg.rs +++ b/src/test/ui/svh-change-type-arg.rs @@ -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 diff --git a/src/test/ui/svh-change-type-arg.stderr b/src/test/ui/svh-change-type-arg.stderr index 654d73d7085..d94dd5e522e 100644 --- a/src/test/ui/svh-change-type-arg.stderr +++ b/src/test/ui/svh-change-type-arg.stderr @@ -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 diff --git a/src/test/ui/svh-change-type-ret.rs b/src/test/ui/svh-change-type-ret.rs index e5f833b9652..88bf146760f 100644 --- a/src/test/ui/svh-change-type-ret.rs +++ b/src/test/ui/svh-change-type-ret.rs @@ -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 diff --git a/src/test/ui/svh-change-type-ret.stderr b/src/test/ui/svh-change-type-ret.stderr index c71c0288d8f..4484faabbf4 100644 --- a/src/test/ui/svh-change-type-ret.stderr +++ b/src/test/ui/svh-change-type-ret.stderr @@ -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 diff --git a/src/test/ui/svh-change-type-static.rs b/src/test/ui/svh-change-type-static.rs index c374d26298c..c9a167c5a02 100644 --- a/src/test/ui/svh-change-type-static.rs +++ b/src/test/ui/svh-change-type-static.rs @@ -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 diff --git a/src/test/ui/svh-change-type-static.stderr b/src/test/ui/svh-change-type-static.stderr index 05cc02d1323..24c5acbf6f2 100644 --- a/src/test/ui/svh-change-type-static.stderr +++ b/src/test/ui/svh-change-type-static.stderr @@ -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 diff --git a/src/test/ui/svh-use-trait.rs b/src/test/ui/svh-use-trait.rs index ff79a7ad6a0..3a87f6bfc77 100644 --- a/src/test/ui/svh-use-trait.rs +++ b/src/test/ui/svh-use-trait.rs @@ -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 diff --git a/src/test/ui/svh-use-trait.stderr b/src/test/ui/svh-use-trait.stderr index b12d173b6cb..e695d60e2a1 100644 --- a/src/test/ui/svh-use-trait.stderr +++ b/src/test/ui/svh-use-trait.stderr @@ -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 diff --git a/src/test/ui/transmute/main.rs b/src/test/ui/transmute/main.rs index ab448de656e..285b079cf96 100644 --- a/src/test/ui/transmute/main.rs +++ b/src/test/ui/transmute/main.rs @@ -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)" diff --git a/src/tools/compiletest/Cargo.toml b/src/tools/compiletest/Cargo.toml index 6fc9423a413..494c57b161f 100644 --- a/src/tools/compiletest/Cargo.toml +++ b/src/tools/compiletest/Cargo.toml @@ -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] diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs index fac3b71f82c..8546289fdec 100644 --- a/src/tools/compiletest/src/main.rs +++ b/src/tools/compiletest/src/main.rs @@ -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; diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 74da774c6d5..06e79855416 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -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 } |
