mirror of
https://github.com/nushell/nushell
synced 2025-01-14 06:04:09 +00:00
test-runner: Add option to exclude single test and module (#9611)
# Description This PR adds two additional flags to the test runner `--exclude` and `--exclude-module` which as the name suggests allow to exclude tests from a run The now options only support a single test / module to exclude. # User-Facing Changes # Tests + Formatting # After Submitting
This commit is contained in:
parent
544c46e0e4
commit
fbc1408913
1 changed files with 9 additions and 9 deletions
|
@ -298,10 +298,12 @@ def run-tests-for-module [
|
||||||
# * after-each - function to run after every test case. Receives the context record just like the test cases
|
# * after-each - function to run after every test case. Receives the context record just like the test cases
|
||||||
# * after-all - function to run after all test cases have been executed. Receives the global context record
|
# * after-all - function to run after all test cases have been executed. Receives the global context record
|
||||||
export def run-tests [
|
export def run-tests [
|
||||||
--path: path, # Path to look for tests. Default: current directory.
|
--path: path, # Path to look for tests. Default: current directory.
|
||||||
--module: string, # Test module to run. Default: all test modules found.
|
--module: string, # Test module to run. Default: all test modules found.
|
||||||
--test: string, # Individual test to run. Default: all test command found in the files.
|
--test: string, # Individual test to run. Default: all test command found in the files.
|
||||||
--list, # list the selected tests without running them.
|
--exclude: string, # Individual test to exclude. Default: no tests are excluded
|
||||||
|
--exclude-module: string, # Test module to exclude. Default: No modules are excluded
|
||||||
|
--list, # list the selected tests without running them.
|
||||||
] {
|
] {
|
||||||
|
|
||||||
let module_search_pattern = ('**' | path join ({
|
let module_search_pattern = ('**' | path join ({
|
||||||
|
@ -345,15 +347,13 @@ export def run-tests [
|
||||||
}
|
}
|
||||||
| flatten
|
| flatten
|
||||||
| filter {|x| ($x.test|length) > 0}
|
| filter {|x| ($x.test|length) > 0}
|
||||||
|
| filter {|x| if ($exclude_module|is-empty) {true} else {$exclude_module != $x.name}}
|
||||||
| filter {|x| if ($test|is-empty) {true} else {$test in $x.test}}
|
| filter {|x| if ($test|is-empty) {true} else {$test in $x.test}}
|
||||||
| filter {|x| if ($module|is-empty) {true} else {$module == $x.name}}
|
| filter {|x| if ($module|is-empty) {true} else {$module == $x.name}}
|
||||||
| update test {|x|
|
| update test {|x|
|
||||||
$x.test
|
$x.test
|
||||||
| if ($test|is-empty) {
|
| filter {|y| if ($test|is-empty) {true} else {$y == $test}}
|
||||||
$in
|
| filter {|y| if ($exclude|is-empty) {true} else {$y != $exclude}}
|
||||||
} else {
|
|
||||||
where $it == $test
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
if $list {
|
if $list {
|
||||||
|
|
Loading…
Reference in a new issue