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,
|
skip_tests: bool,
|
||||||
match_tests: Option<Vec<String>>,
|
match_tests: Option<Vec<String>>,
|
||||||
verbose: bool,
|
verbose: bool,
|
||||||
|
exact_match: bool,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let options = Options {
|
let options = Options {
|
||||||
code_gen_mode: if skip_tests {
|
code_gen_mode: if skip_tests {
|
||||||
|
@ -162,6 +163,7 @@ where
|
||||||
CodeGenMode::Test {
|
CodeGenMode::Test {
|
||||||
match_tests,
|
match_tests,
|
||||||
verbose,
|
verbose,
|
||||||
|
exact_match,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -202,6 +204,7 @@ where
|
||||||
CodeGenMode::Test {
|
CodeGenMode::Test {
|
||||||
match_tests,
|
match_tests,
|
||||||
verbose,
|
verbose,
|
||||||
|
exact_match,
|
||||||
} => {
|
} => {
|
||||||
let tests =
|
let tests =
|
||||||
self.collect_scripts(verbose, |def| matches!(def, Definition::Test(..)))?;
|
self.collect_scripts(verbose, |def| matches!(def, Definition::Test(..)))?;
|
||||||
|
@ -210,7 +213,7 @@ where
|
||||||
self.event_listener.handle_event(Event::RunningTests);
|
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
|
let errors: Vec<Error> = results
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -696,6 +699,7 @@ where
|
||||||
&self,
|
&self,
|
||||||
scripts: Vec<Script>,
|
scripts: Vec<Script>,
|
||||||
match_tests: Option<Vec<String>>,
|
match_tests: Option<Vec<String>>,
|
||||||
|
exact_match: bool,
|
||||||
) -> Vec<EvalInfo> {
|
) -> Vec<EvalInfo> {
|
||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
|
|
||||||
|
@ -730,20 +734,29 @@ where
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|script| -> bool {
|
.filter(|script| -> bool {
|
||||||
match_tests.iter().any(|(match_module, match_names)| {
|
match_tests.iter().any(|(match_module, match_names)| {
|
||||||
if *match_module == script.module {
|
let matches_name = || {
|
||||||
if let Some(match_names) = match_names {
|
matches!(match_names, Some(match_names) if match_names
|
||||||
match_names
|
|
||||||
.iter()
|
.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 {
|
} else {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
} else if match_names.is_some() && match_module == &"" {
|
||||||
|
matches_name()
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// !matches!(&match_tests, Some(search_str) if !path.contains(search_str))
|
|
||||||
})
|
})
|
||||||
.collect::<Vec<Script>>()
|
.collect::<Vec<Script>>()
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -6,6 +6,7 @@ pub enum CodeGenMode {
|
||||||
Test {
|
Test {
|
||||||
match_tests: Option<Vec<String>>,
|
match_tests: Option<Vec<String>>,
|
||||||
verbose: bool,
|
verbose: bool,
|
||||||
|
exact_match: bool,
|
||||||
},
|
},
|
||||||
Build(bool),
|
Build(bool),
|
||||||
NoOp,
|
NoOp,
|
||||||
|
|
|
@ -14,9 +14,16 @@ pub struct Args {
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
debug: bool,
|
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)]
|
#[clap(short, long)]
|
||||||
match_tests: Option<Vec<String>>,
|
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(
|
pub fn exec(
|
||||||
|
@ -25,9 +32,10 @@ pub fn exec(
|
||||||
skip_tests,
|
skip_tests,
|
||||||
debug,
|
debug,
|
||||||
match_tests,
|
match_tests,
|
||||||
|
exact_match,
|
||||||
}: Args,
|
}: Args,
|
||||||
) -> miette::Result<()> {
|
) -> miette::Result<()> {
|
||||||
crate::with_project(directory, |p| {
|
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