feat(check): change some logic around and add --exact-match
This commit is contained in:
parent
9002ea263f
commit
99ec0ff6b0
|
@ -154,6 +154,7 @@ where
|
|||
skip_tests: bool,
|
||||
match_tests: Option<Vec<String>>,
|
||||
verbose: bool,
|
||||
exact_match: bool,
|
||||
) -> Result<(), Error> {
|
||||
let options = Options {
|
||||
code_gen_mode: if skip_tests {
|
||||
|
@ -162,6 +163,7 @@ where
|
|||
CodeGenMode::Test {
|
||||
match_tests,
|
||||
verbose,
|
||||
exact_match,
|
||||
}
|
||||
},
|
||||
};
|
||||
|
@ -202,6 +204,7 @@ where
|
|||
CodeGenMode::Test {
|
||||
match_tests,
|
||||
verbose,
|
||||
exact_match,
|
||||
} => {
|
||||
let tests =
|
||||
self.collect_scripts(verbose, |def| matches!(def, Definition::Test(..)))?;
|
||||
|
@ -210,7 +213,7 @@ where
|
|||
self.event_listener.handle_event(Event::RunningTests);
|
||||
}
|
||||
|
||||
let results = self.eval_scripts(tests, match_tests);
|
||||
let results = self.eval_scripts(tests, match_tests, exact_match);
|
||||
|
||||
let errors: Vec<Error> = results
|
||||
.iter()
|
||||
|
@ -696,6 +699,7 @@ where
|
|||
&self,
|
||||
scripts: Vec<Script>,
|
||||
match_tests: Option<Vec<String>>,
|
||||
exact_match: bool,
|
||||
) -> Vec<EvalInfo> {
|
||||
use rayon::prelude::*;
|
||||
|
||||
|
@ -730,20 +734,29 @@ where
|
|||
.into_iter()
|
||||
.filter(|script| -> bool {
|
||||
match_tests.iter().any(|(match_module, match_names)| {
|
||||
if *match_module == script.module {
|
||||
if let Some(match_names) = match_names {
|
||||
match_names
|
||||
let matches_name = || {
|
||||
matches!(match_names, Some(match_names) if match_names
|
||||
.iter()
|
||||
.any(|name| name == &script.name || script.name.contains(name))
|
||||
.any(|name| if exact_match {
|
||||
name == &script.name
|
||||
} else {
|
||||
script.name.contains(name)
|
||||
}
|
||||
))
|
||||
};
|
||||
|
||||
if *match_module == script.module || script.module.contains(match_module) {
|
||||
if match_names.is_some() {
|
||||
matches_name()
|
||||
} else {
|
||||
true
|
||||
}
|
||||
} else if match_names.is_some() && match_module == &"" {
|
||||
matches_name()
|
||||
} else {
|
||||
false
|
||||
}
|
||||
})
|
||||
|
||||
// !matches!(&match_tests, Some(search_str) if !path.contains(search_str))
|
||||
})
|
||||
.collect::<Vec<Script>>()
|
||||
} else {
|
||||
|
|
|
@ -6,6 +6,7 @@ pub enum CodeGenMode {
|
|||
Test {
|
||||
match_tests: Option<Vec<String>>,
|
||||
verbose: bool,
|
||||
exact_match: bool,
|
||||
},
|
||||
Build(bool),
|
||||
NoOp,
|
||||
|
|
|
@ -14,9 +14,16 @@ pub struct Args {
|
|||
#[clap(long)]
|
||||
debug: bool,
|
||||
|
||||
/// Only run tests if their path + name match the given string
|
||||
/// Only run tests if they match any of these strings.
|
||||
/// You can match a module with `-m aiken/list` or `-m list`.
|
||||
/// You can match a test with `-m "aiken/list.{map}"` or `-m "aiken/option.{flatten_1}"`
|
||||
#[clap(short, long)]
|
||||
match_tests: Option<Vec<String>>,
|
||||
|
||||
/// This is meant to be used with `--match-tests`.
|
||||
/// It forces test names to match exactly
|
||||
#[clap(short, long)]
|
||||
exact_match: bool,
|
||||
}
|
||||
|
||||
pub fn exec(
|
||||
|
@ -25,9 +32,10 @@ pub fn exec(
|
|||
skip_tests,
|
||||
debug,
|
||||
match_tests,
|
||||
exact_match,
|
||||
}: Args,
|
||||
) -> miette::Result<()> {
|
||||
crate::with_project(directory, |p| {
|
||||
p.check(skip_tests, match_tests.clone(), debug)
|
||||
p.check(skip_tests, match_tests.clone(), debug, exact_match)
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue