about summary refs log tree commit diff
path: root/src/tools
diff options
context:
space:
mode:
authorTakayuki Maeda <takoyaki0316@gmail.com>2023-11-19 04:14:41 +0900
committerGitHub <noreply@github.com>2023-11-19 04:14:41 +0900
commitb82532765c93eb74e6fbc3bc96fa7cd23c1ef4b7 (patch)
treecdee8745b57d9b52c14f101b0ec598c604b00058 /src/tools
parent9e84f6d86aea014dd3b361b6f80384bf06660d6b (diff)
parent05322162abf3cc5bb66848b37af82d6442486a48 (diff)
downloadrust-b82532765c93eb74e6fbc3bc96fa7cd23c1ef4b7.tar.gz
rust-b82532765c93eb74e6fbc3bc96fa7cd23c1ef4b7.zip
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` .
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/suggest-tests/src/lib.rs16
-rw-r--r--src/tools/suggest-tests/src/static_suggestions.rs31
2 files changed, 30 insertions, 17 deletions
diff --git a/src/tools/suggest-tests/src/lib.rs b/src/tools/suggest-tests/src/lib.rs
index 44cd3c7f6a8..1c1d9d0333d 100644
--- a/src/tools/suggest-tests/src/lib.rs
+++ b/src/tools/suggest-tests/src/lib.rs
@@ -33,13 +33,15 @@ pub fn get_suggestions<T: AsRef<str>>(modified_files: &[T]) -> Vec<Suggestion> {
     let mut suggestions = Vec::new();
 
     // static suggestions
-    for sug in STATIC_SUGGESTIONS.iter() {
-        let glob = Pattern::new(&sug.0).expect("Found invalid glob pattern!");
-
-        for file in modified_files {
-            if glob.matches(file.as_ref()) {
-                suggestions.extend_from_slice(&sug.1);
-            }
+    for (globs, sugs) in STATIC_SUGGESTIONS.iter() {
+        let globs = globs
+            .iter()
+            .map(|glob| Pattern::new(glob).expect("Found invalid glob pattern!"))
+            .collect::<Vec<_>>();
+        let matches_some_glob = |file: &str| globs.iter().any(|glob| glob.matches(file));
+
+        if modified_files.iter().map(AsRef::as_ref).any(matches_some_glob) {
+            suggestions.extend_from_slice(sugs);
         }
     }
 
diff --git a/src/tools/suggest-tests/src/static_suggestions.rs b/src/tools/suggest-tests/src/static_suggestions.rs
index a84e78254f2..fbd265ea42a 100644
--- a/src/tools/suggest-tests/src/static_suggestions.rs
+++ b/src/tools/suggest-tests/src/static_suggestions.rs
@@ -2,23 +2,34 @@ use crate::{sug, Suggestion};
 
 // FIXME: perhaps this could use `std::lazy` when it is stablizied
 macro_rules! static_suggestions {
-    ($( $glob:expr => [ $( $suggestion:expr ),* ] ),*) => {
-        pub(crate) const STATIC_SUGGESTIONS: ::once_cell::unsync::Lazy<Vec<(&'static str, Vec<Suggestion>)>>
-            = ::once_cell::unsync::Lazy::new(|| vec![ $( ($glob, vec![ $($suggestion),* ]) ),*]);
+    ($( [ $( $glob:expr ),* $(,)? ] => [ $( $suggestion:expr ),* $(,)? ] ),* $(,)? ) => {
+        pub(crate) const STATIC_SUGGESTIONS: ::once_cell::unsync::Lazy<Vec<(Vec<&'static str>, Vec<Suggestion>)>>
+            = ::once_cell::unsync::Lazy::new(|| vec![ $( (vec![ $($glob),* ], vec![ $($suggestion),* ]) ),*]);
     }
 }
 
 static_suggestions! {
-    "*.md" => [
-        sug!("test", 0, ["linkchecker"])
+    ["*.md"] => [
+        sug!("test", 0, ["linkchecker"]),
     ],
 
-    "compiler/*" => [
+    ["compiler/*"] => [
         sug!("check"),
-        sug!("test", 1, ["tests/ui", "tests/run-make"])
+        sug!("test", 1, ["tests/ui", "tests/run-make"]),
     ],
 
-    "src/librustdoc/*" => [
-        sug!("test", 1, ["rustdoc"])
-    ]
+    ["compiler/rustc_mir_transform/*"] => [
+        sug!("test", 1, ["mir-opt"]),
+    ],
+
+    [
+        "compiler/rustc_mir_transform/src/coverage/*",
+        "compiler/rustc_codegen_llvm/src/coverageinfo/*",
+    ] => [
+        sug!("test", 1, ["coverage"]),
+    ],
+
+    ["src/librustdoc/*"] => [
+        sug!("test", 1, ["rustdoc"]),
+    ],
 }