From bf3c46cfc9dbe677ae801f0459cea5b8e5e5a178 Mon Sep 17 00:00:00 2001 From: varkor Date: Sat, 11 May 2019 00:42:29 +0100 Subject: [PATCH 1/2] Allow subdirectories to be tested by x.py test --- src/bootstrap/test.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index a3d96836aad..3847a2a1e46 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -1184,8 +1184,13 @@ 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| { + 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()); From b470d48c8a58a6cd91a14e5ba6387f424da6c5db Mon Sep 17 00:00:00 2001 From: varkor Date: Tue, 14 May 2019 09:42:32 +0100 Subject: [PATCH 2/2] Add comment --- src/bootstrap/test.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index 3847a2a1e46..f1bb318651a 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -1186,6 +1186,12 @@ impl Step for Compiletest { }) .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,