Skip to content

Commit b825327

Browse files
authored
Rollup merge of #117961 - Zalathar:suggest, r=Mark-Simulacrum
Add `x suggest` entries for testing `mir-opt` and `coverage` The `x suggest` subcommand uses git to find paths that have been modified, and uses those paths to suggest relevant test suites to run. This PR adds suggestions for `x test mir-opt` and `x test coverage` .
2 parents 9e84f6d + 0532216 commit b825327

File tree

2 files changed

+30
-17
lines changed

2 files changed

+30
-17
lines changed

src/tools/suggest-tests/src/lib.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,15 @@ pub fn get_suggestions<T: AsRef<str>>(modified_files: &[T]) -> Vec<Suggestion> {
3333
let mut suggestions = Vec::new();
3434

3535
// static suggestions
36-
for sug in STATIC_SUGGESTIONS.iter() {
37-
let glob = Pattern::new(&sug.0).expect("Found invalid glob pattern!");
38-
39-
for file in modified_files {
40-
if glob.matches(file.as_ref()) {
41-
suggestions.extend_from_slice(&sug.1);
42-
}
36+
for (globs, sugs) in STATIC_SUGGESTIONS.iter() {
37+
let globs = globs
38+
.iter()
39+
.map(|glob| Pattern::new(glob).expect("Found invalid glob pattern!"))
40+
.collect::<Vec<_>>();
41+
let matches_some_glob = |file: &str| globs.iter().any(|glob| glob.matches(file));
42+
43+
if modified_files.iter().map(AsRef::as_ref).any(matches_some_glob) {
44+
suggestions.extend_from_slice(sugs);
4345
}
4446
}
4547

src/tools/suggest-tests/src/static_suggestions.rs

+21-10
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,34 @@ use crate::{sug, Suggestion};
22

33
// FIXME: perhaps this could use `std::lazy` when it is stablizied
44
macro_rules! static_suggestions {
5-
($( $glob:expr => [ $( $suggestion:expr ),* ] ),*) => {
6-
pub(crate) const STATIC_SUGGESTIONS: ::once_cell::unsync::Lazy<Vec<(&'static str, Vec<Suggestion>)>>
7-
= ::once_cell::unsync::Lazy::new(|| vec![ $( ($glob, vec![ $($suggestion),* ]) ),*]);
5+
($( [ $( $glob:expr ),* $(,)? ] => [ $( $suggestion:expr ),* $(,)? ] ),* $(,)? ) => {
6+
pub(crate) const STATIC_SUGGESTIONS: ::once_cell::unsync::Lazy<Vec<(Vec<&'static str>, Vec<Suggestion>)>>
7+
= ::once_cell::unsync::Lazy::new(|| vec![ $( (vec![ $($glob),* ], vec![ $($suggestion),* ]) ),*]);
88
}
99
}
1010

1111
static_suggestions! {
12-
"*.md" => [
13-
sug!("test", 0, ["linkchecker"])
12+
["*.md"] => [
13+
sug!("test", 0, ["linkchecker"]),
1414
],
1515

16-
"compiler/*" => [
16+
["compiler/*"] => [
1717
sug!("check"),
18-
sug!("test", 1, ["tests/ui", "tests/run-make"])
18+
sug!("test", 1, ["tests/ui", "tests/run-make"]),
1919
],
2020

21-
"src/librustdoc/*" => [
22-
sug!("test", 1, ["rustdoc"])
23-
]
21+
["compiler/rustc_mir_transform/*"] => [
22+
sug!("test", 1, ["mir-opt"]),
23+
],
24+
25+
[
26+
"compiler/rustc_mir_transform/src/coverage/*",
27+
"compiler/rustc_codegen_llvm/src/coverageinfo/*",
28+
] => [
29+
sug!("test", 1, ["coverage"]),
30+
],
31+
32+
["src/librustdoc/*"] => [
33+
sug!("test", 1, ["rustdoc"]),
34+
],
2435
}

0 commit comments

Comments
 (0)