about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-05-14 22:00:16 +0200
committerGitHub <noreply@github.com>2019-05-14 22:00:16 +0200
commit3b4234a175347a6d9d555ac0ee56212b1296c8b7 (patch)
treeb5a167d4c590c8d989da3a8b77af256b0ab81264 /src
parentb4c340e4bb246572029d235e46850faa9823d312 (diff)
parentb470d48c8a58a6cd91a14e5ba6387f424da6c5db (diff)
downloadrust-3b4234a175347a6d9d555ac0ee56212b1296c8b7.tar.gz
rust-3b4234a175347a6d9d555ac0ee56212b1296c8b7.zip
Rollup merge of #60719 - varkor:xpy-test-folder, r=Mark-Simulacrum
Allow subdirectories to be tested by x.py test

Fixes https://github.com/rust-lang/rust/issues/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.
Diffstat (limited to 'src')
-rw-r--r--src/bootstrap/test.rs15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs
index 9867113e48f..7826ac94718 100644
--- a/src/bootstrap/test.rs
+++ b/src/bootstrap/test.rs
@@ -1184,8 +1184,19 @@ impl Step for Compiletest {
                     Err(_) => p,
                 }
             })
-            .filter(|p| p.starts_with(suite_path) && p.is_file())
-            .map(|p| p.strip_prefix(suite_path).unwrap().to_str().unwrap())
+            .filter(|p| p.starts_with(suite_path) && (p.is_dir() || p.is_file()))
+            .filter_map(|p| {
+                // Since test suite paths are themselves directories, if we don't
+                // specify a directory or file, we'll get an empty string here
+                // (the result of the test suite directory without its suite prefix).
+                // Therefore, we need to filter these out, as only the first --test-args
+                // flag is respected, so providing an empty --test-args conflicts with
+                // any following it.
+                match p.strip_prefix(suite_path).ok().and_then(|p| p.to_str()) {
+                    Some(s) if s != "" => Some(s),
+                    _ => None,
+                }
+            })
             .collect();
 
         test_args.append(&mut builder.config.cmd.test_args());