ui_test: support multiple filters

This commit is contained in:
Ralf Jung 2022-05-30 10:27:41 +02:00
parent 065ff89e33
commit e37dfa6d91
3 changed files with 10 additions and 8 deletions

View File

@ -47,7 +47,8 @@ fn run_tests(mode: Mode, path: &str, target: Option<String>) {
(true, true) => panic!("cannot use MIRI_BLESS and MIRI_SKIP_UI_CHECKS at the same time"), (true, true) => panic!("cannot use MIRI_BLESS and MIRI_SKIP_UI_CHECKS at the same time"),
}; };
let path_filter = std::env::args().skip(1).next(); // Pass on all arguments as filters.
let path_filter = std::env::args().skip(1);
let config = Config { let config = Config {
args: flags, args: flags,
@ -56,7 +57,7 @@ fn run_tests(mode: Mode, path: &str, target: Option<String>) {
stdout_filters: STDOUT.clone(), stdout_filters: STDOUT.clone(),
root_dir: PathBuf::from(path), root_dir: PathBuf::from(path),
mode, mode,
path_filter, path_filter: path_filter.collect(),
program: miri_path(), program: miri_path(),
output_conflict_handling, output_conflict_handling,
}; };

View File

@ -30,8 +30,8 @@ pub struct Config {
pub mode: Mode, pub mode: Mode,
pub program: PathBuf, pub program: PathBuf,
pub output_conflict_handling: OutputConflictHandling, pub output_conflict_handling: OutputConflictHandling,
/// Only run tests with this string in their path/name /// Only run tests with one of these strings in their path/name
pub path_filter: Option<String>, pub path_filter: Vec<String>,
} }
#[derive(Debug)] #[derive(Debug)]
@ -77,12 +77,13 @@ pub fn run_tests(config: Config) {
if !path.extension().map(|ext| ext == "rs").unwrap_or(false) { if !path.extension().map(|ext| ext == "rs").unwrap_or(false) {
continue; continue;
} }
if let Some(path_filter) = &config.path_filter { if !config.path_filter.is_empty() {
if !path.display().to_string().contains(path_filter) { let path_display = path.display().to_string();
if !config.path_filter.iter().any(|filter| path_display.contains(filter)) {
ignored.fetch_add(1, Ordering::Relaxed); ignored.fetch_add(1, Ordering::Relaxed);
eprintln!( eprintln!(
"{} .. {}", "{} .. {}",
path.display(), path_display,
"ignored (command line filter)".yellow() "ignored (command line filter)".yellow()
); );
continue; continue;

View File

@ -10,7 +10,7 @@ fn config() -> Config {
stdout_filters: vec![], stdout_filters: vec![],
root_dir: PathBuf::from("."), root_dir: PathBuf::from("."),
mode: Mode::Fail, mode: Mode::Fail,
path_filter: None, path_filter: vec![],
program: PathBuf::from("cake"), program: PathBuf::from("cake"),
output_conflict_handling: OutputConflictHandling::Error, output_conflict_handling: OutputConflictHandling::Error,
} }