Skip to content

Commit 6d629b0

Browse files
committed
aml_tester: allow running a single test instead of a directory of them
1 parent db0362f commit 6d629b0

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

tools/aml_tester/src/main.rs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,22 @@ fn main() -> std::io::Result<()> {
5656
// Get an initial list of files - may not work correctly on non-UTF8 OsString
5757
let files: Vec<String> = if matches.contains_id("path") {
5858
let dir_path = Path::new(matches.get_one::<String>("path").unwrap());
59-
println!("Running tests in directory: {:?}", dir_path);
60-
fs::read_dir(dir_path)?
61-
.filter_map(|entry| {
62-
if entry.is_ok() {
63-
Some(entry.unwrap().path().to_string_lossy().to_string())
64-
} else {
65-
None
66-
}
67-
})
68-
.collect()
59+
60+
if std::fs::metadata(&dir_path).unwrap().is_dir() {
61+
println!("Running tests in directory: {:?}", dir_path);
62+
fs::read_dir(dir_path)?
63+
.filter_map(|entry| {
64+
if entry.is_ok() {
65+
Some(entry.unwrap().path().to_string_lossy().to_string())
66+
} else {
67+
None
68+
}
69+
})
70+
.collect()
71+
} else {
72+
println!("Running single test: {:?}", dir_path);
73+
vec![dir_path.to_string_lossy().to_string()]
74+
}
6975
} else {
7076
matches.get_many::<String>("files").unwrap_or_default().map(|name| name.to_string()).collect()
7177
};

0 commit comments

Comments
 (0)