Skip to content

Commit 77e8ad3

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 77e8ad3

File tree

1 file changed

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

1 file changed

+18
-1
lines changed

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

Lines changed: 18 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,23 @@ 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+
'partially_test: {
788+
let paths = &builder.config.paths[..];
789+
let mut test_names = Vec::new();
790+
for path in paths {
791+
if let Some(path) =
792+
helpers::is_valid_test_suite_arg(path, "src/tools/clippy/tests", builder)
793+
{
794+
test_names.push(path);
795+
} else if path.ends_with("src/tools/clippy") {
796+
// When src/tools/clippy is called directly, all tests should be run.
797+
break 'partially_test;
798+
}
799+
}
800+
cargo.env("TESTNAME", test_names.join(","));
801+
}
802+
786803
cargo.add_rustc_lib_path(builder);
787804
let cargo = prepare_cargo_test(cargo, &[], &[], host, builder);
788805

0 commit comments

Comments
 (0)