about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorStuart Cook <Zalathar@users.noreply.github.com>2025-09-16 10:25:42 +1000
committerGitHub <noreply@github.com>2025-09-16 10:25:42 +1000
commit7cad097408b161837bb4f62adcf07ed7b6870461 (patch)
treeb609473b671a8a14cbc91674069bac70985b3c34 /src
parentf3c395b1181ed9c59ca9dc3888966d70ac8262c6 (diff)
parentbf73aac8cbdfeff983dce44b883993be2ae89151 (diff)
downloadrust-7cad097408b161837bb4f62adcf07ed7b6870461.tar.gz
rust-7cad097408b161837bb4f62adcf07ed7b6870461.zip
Rollup merge of #146601 - Enselic:fix-test-args, r=Mark-Simulacrum
compiletest: Make `./x test --test-args ...` work again

It accidentally broke with  https://github.com/rust-lang/rust/pull/146501. The intention of that PR was to keep existing behavior if `--exact` is not used, but it had a bug. This PR fixes that bug.
Diffstat (limited to 'src')
-rw-r--r--src/tools/compiletest/src/executor.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/tools/compiletest/src/executor.rs b/src/tools/compiletest/src/executor.rs
index 37cc17351d5..c8e13d44573 100644
--- a/src/tools/compiletest/src/executor.rs
+++ b/src/tools/compiletest/src/executor.rs
@@ -295,11 +295,14 @@ fn filter_tests(opts: &Config, tests: Vec<CollectedTest>) -> Vec<CollectedTest>
     let mut filtered = tests;
 
     let matches_filter = |test: &CollectedTest, filter_str: &str| {
-        let filterable_path = test.desc.filterable_path.as_str();
         if opts.filter_exact {
-            filterable_path == filter_str
+            // When `--exact` is used we must use `filterable_path` to get
+            // reasonable filtering behavior.
+            test.desc.filterable_path.as_str() == filter_str
         } else {
-            filterable_path.contains(filter_str)
+            // For compatibility we use the name (which includes the full path)
+            // if `--exact` is not used.
+            test.desc.name.contains(filter_str)
         }
     };