about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-02-15 19:18:41 +0000
committerbors <bors@rust-lang.org>2021-02-15 19:18:41 +0000
commit87c682a06ef03274d03cd3555c7e8ece6c447d45 (patch)
treecc4203af65ae9963a2b6cd5ca1606d3c5bd92880
parent2f19f5f0d71833d450f8290bb154c3572ac58d9d (diff)
parent7226291025e6a367e60365fa1653999d240777b4 (diff)
downloadrust-87c682a06ef03274d03cd3555c7e8ece6c447d45.tar.gz
rust-87c682a06ef03274d03cd3555c7e8ece6c447d45.zip
Auto merge of #6743 - rust-lang:update-compiletest, r=Manishearth
Upgrade compiletest-rs to 0.6 and tester to 0.9

These updates allow us to specify multiple testnames for `TESTNAME` by
providing a comma separated list of testnames.

The new version of compiletest-rs also includes `bless` support, but is
not enabled with this PR.

cc #5394

changelog: none
-rw-r--r--Cargo.toml4
-rw-r--r--doc/adding_lints.md3
-rw-r--r--tests/compile-test.rs16
3 files changed, 13 insertions, 10 deletions
diff --git a/Cargo.toml b/Cargo.toml
index e7755c46eb8..ea32a8edd1f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -37,8 +37,8 @@ tempfile = { version = "3.1.0", optional = true }
 
 [dev-dependencies]
 cargo_metadata = "0.12"
-compiletest_rs = { version = "0.5.0", features = ["tmp"] }
-tester = "0.7"
+compiletest_rs = { version = "0.6.0", features = ["tmp"] }
+tester = "0.9"
 clippy-mini-macro-test = { version = "0.2", path = "mini-macro" }
 serde = { version = "1.0", features = ["derive"] }
 derive-new = "0.5"
diff --git a/doc/adding_lints.md b/doc/adding_lints.md
index 8fd1dea9aee..e12e75d4a2b 100644
--- a/doc/adding_lints.md
+++ b/doc/adding_lints.md
@@ -108,6 +108,9 @@ should only commit files changed by `cargo dev bless` for the
 specific lint you are creating/editing. Note that if the generated files are
 empty, they should be removed.
 
+Note that you can run multiple test files by specifying a comma separated list:
+`TESTNAME=foo_functions,test2,test3`.
+
 ### Cargo lints
 
 For cargo lints, the process of testing differs in that we are interested in
diff --git a/tests/compile-test.rs b/tests/compile-test.rs
index c0b40add109..0594663786c 100644
--- a/tests/compile-test.rs
+++ b/tests/compile-test.rs
@@ -66,8 +66,8 @@ fn third_party_crates() -> String {
 fn default_config() -> compiletest::Config {
     let mut config = compiletest::Config::default();
 
-    if let Ok(name) = env::var("TESTNAME") {
-        config.filter = Some(name);
+    if let Ok(filters) = env::var("TESTNAME") {
+        config.filters = filters.split(',').map(std::string::ToString::to_string).collect();
     }
 
     if let Some(path) = option_env!("RUSTC_LIB_PATH") {
@@ -167,7 +167,7 @@ fn run_ui_toml(config: &mut compiletest::Config) {
 fn run_ui_cargo(config: &mut compiletest::Config) {
     fn run_tests(
         config: &compiletest::Config,
-        filter: &Option<String>,
+        filters: &[String],
         mut tests: Vec<tester::TestDescAndFn>,
     ) -> Result<bool, io::Error> {
         let mut result = true;
@@ -181,9 +181,10 @@ fn run_ui_cargo(config: &mut compiletest::Config) {
 
             // Use the filter if provided
             let dir_path = dir.path();
-            match &filter {
-                Some(name) if !dir_path.ends_with(name) => continue,
-                _ => {},
+            for filter in filters {
+                if !dir_path.ends_with(filter) {
+                    continue;
+                }
             }
 
             for case in fs::read_dir(&dir_path)? {
@@ -243,8 +244,7 @@ fn run_ui_cargo(config: &mut compiletest::Config) {
 
     let current_dir = env::current_dir().unwrap();
     let conf_dir = var("CLIPPY_CONF_DIR").unwrap_or_default();
-    let filter = env::var("TESTNAME").ok();
-    let res = run_tests(&config, &filter, tests);
+    let res = run_tests(&config, &config.filters, tests);
     env::set_current_dir(current_dir).unwrap();
     set_var("CLIPPY_CONF_DIR", conf_dir);