From 4350fd170e0ada52c210a05166663ece65d39b37 Mon Sep 17 00:00:00 2001 From: xtex Date: Sat, 24 May 2025 23:43:39 +0800 Subject: [PATCH] bootstrap: clippy: set TESTNAME based on given paths This addresses issue 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]. --- src/bootstrap/src/core/build_steps/test.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 27791825aa0f6..acd6fc477055d 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);