Skip to content

Commit 3b4234a

Browse files
authored
Rollup merge of rust-lang#60719 - varkor:xpy-test-folder, r=Mark-Simulacrum
Allow subdirectories to be tested by x.py test Fixes rust-lang#60718. As far as I can tell, multiple `--test-args` flags are ignored (only the first is respected), so if you specify a subdirectory, you won't also be able to filter using `--test-args`. If you don't specify a subdirectory, `--test-args` will continue working as usual, so this is strictly an improvement on the current state of affairs.
2 parents b4c340e + b470d48 commit 3b4234a

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/bootstrap/test.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,8 +1184,19 @@ impl Step for Compiletest {
11841184
Err(_) => p,
11851185
}
11861186
})
1187-
.filter(|p| p.starts_with(suite_path) && p.is_file())
1188-
.map(|p| p.strip_prefix(suite_path).unwrap().to_str().unwrap())
1187+
.filter(|p| p.starts_with(suite_path) && (p.is_dir() || p.is_file()))
1188+
.filter_map(|p| {
1189+
// Since test suite paths are themselves directories, if we don't
1190+
// specify a directory or file, we'll get an empty string here
1191+
// (the result of the test suite directory without its suite prefix).
1192+
// Therefore, we need to filter these out, as only the first --test-args
1193+
// flag is respected, so providing an empty --test-args conflicts with
1194+
// any following it.
1195+
match p.strip_prefix(suite_path).ok().and_then(|p| p.to_str()) {
1196+
Some(s) if s != "" => Some(s),
1197+
_ => None,
1198+
}
1199+
})
11891200
.collect();
11901201

11911202
test_args.append(&mut builder.config.cmd.test_args());

0 commit comments

Comments
 (0)