Skip to content

Commit 09db96b

Browse files
committed
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].
1 parent 5af801b commit 09db96b

File tree

1 file changed

+21
-1
lines changed
  • src/bootstrap/src/core/build_steps

1 file changed

+21
-1
lines changed

src/bootstrap/src/core/build_steps/test.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ impl Step for Clippy {
739739
const DEFAULT: bool = false;
740740

741741
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
742-
run.path("src/tools/clippy")
742+
run.suite_path("src/tools/clippy/tests").path("src/tools/clippy")
743743
}
744744

745745
fn make_run(run: RunConfig<'_>) {
@@ -783,6 +783,26 @@ impl Step for Clippy {
783783
let host_libs = builder.stage_out(compiler, Mode::ToolRustc).join(builder.cargo_dir());
784784
cargo.env("HOST_LIBS", host_libs);
785785

786+
// Collect paths of tests to run
787+
let paths = match &builder.config.cmd {
788+
Subcommand::Test { .. } => &builder.config.paths[..],
789+
_ => &[],
790+
};
791+
'partially_test: {
792+
let mut test_names = Vec::new();
793+
for path in paths {
794+
if let Some(path) =
795+
helpers::is_valid_test_suite_arg(path, "src/tools/clippy/tests", builder)
796+
{
797+
test_names.push(path);
798+
} else if path.ends_with("src/tools/clippy") {
799+
// When src/tools/clippy is called directly, all tests should be run.
800+
break 'partially_test;
801+
}
802+
}
803+
cargo.env("TESTNAME", test_names.join(","));
804+
}
805+
786806
cargo.add_rustc_lib_path(builder);
787807
let cargo = prepare_cargo_test(cargo, &[], &[], host, builder);
788808

0 commit comments

Comments
 (0)