about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2025-05-25 15:11:48 +0200
committerGitHub <noreply@github.com>2025-05-25 15:11:48 +0200
commitc747b7da6cd4d7e9eee1e28e8fd20537a6218abd (patch)
treefe31ec0673ede7ee4f4dc657f2072e8e81595dc3
parentd72bc29a33ee695e73cc6d85ba9b20d38067c0ce (diff)
parent4350fd170e0ada52c210a05166663ece65d39b37 (diff)
downloadrust-c747b7da6cd4d7e9eee1e28e8fd20537a6218abd.tar.gz
rust-c747b7da6cd4d7e9eee1e28e8fd20537a6218abd.zip
Rollup merge of #141508 - xtexx:gh-104200, r=onur-ozkan
bootstrap: clippy: set TESTNAME based on given paths

This addresses #104200 by setting the TESTNAME environment variable automatically based on the paths from run configs, marking a selected set of UI tests to be run.

Note that this does not filter out other unit tests using #[test].
-rw-r--r--src/bootstrap/src/core/build_steps/test.rs19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs
index 27791825aa0..acd6fc47705 100644
--- a/src/bootstrap/src/core/build_steps/test.rs
+++ b/src/bootstrap/src/core/build_steps/test.rs
@@ -739,7 +739,7 @@ impl Step for Clippy {
     const DEFAULT: bool = false;
 
     fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
-        run.path("src/tools/clippy")
+        run.suite_path("src/tools/clippy/tests").path("src/tools/clippy")
     }
 
     fn make_run(run: RunConfig<'_>) {
@@ -783,6 +783,23 @@ impl Step for Clippy {
         let host_libs = builder.stage_out(compiler, Mode::ToolRustc).join(builder.cargo_dir());
         cargo.env("HOST_LIBS", host_libs);
 
+        // Collect paths of tests to run
+        'partially_test: {
+            let paths = &builder.config.paths[..];
+            let mut test_names = Vec::new();
+            for path in paths {
+                if let Some(path) =
+                    helpers::is_valid_test_suite_arg(path, "src/tools/clippy/tests", builder)
+                {
+                    test_names.push(path);
+                } else if path.ends_with("src/tools/clippy") {
+                    // When src/tools/clippy is called directly, all tests should be run.
+                    break 'partially_test;
+                }
+            }
+            cargo.env("TESTNAME", test_names.join(","));
+        }
+
         cargo.add_rustc_lib_path(builder);
         let cargo = prepare_cargo_test(cargo, &[], &[], host, builder);