Skip to content

Commit 0ad6d49

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 8989165 commit 0ad6d49

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
@@ -744,7 +744,7 @@ impl Step for Clippy {
744744
const DEFAULT: bool = false;
745745

746746
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
747-
run.path("src/tools/clippy")
747+
run.suite_path("src/tools/clippy/tests").path("src/tools/clippy")
748748
}
749749

750750
fn make_run(run: RunConfig<'_>) {
@@ -788,6 +788,26 @@ impl Step for Clippy {
788788
let host_libs = builder.stage_out(compiler, Mode::ToolRustc).join(builder.cargo_dir());
789789
cargo.env("HOST_LIBS", host_libs);
790790

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

0 commit comments

Comments
 (0)