Skip to content

Commit

Permalink
Factor out the script that imports the test commands
Browse files Browse the repository at this point in the history
  • Loading branch information
NonlinearFruit committed Mar 28, 2024
1 parent 55ab0ba commit c1f9b7e
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions nuunit.nu
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
def main [--test-spec-module-name = "test-spec.nu"] {
def main [
--test-spec-module-name = "test-spec.nu"
] {
if (not ($test_spec_module_name | path exists)) {
return $"Invalid test spec module: ($test_spec_module_name)"
}
discover-tests $test_spec_module_name
let module = $test_spec_module_name | str replace '.nu' ''
let importScript = $"use ($test_spec_module_name) *"
discover-tests $module $importScript
| run-tests
| output-tests
}

def discover-tests [testSpecModuleName] {
let module = $testSpecModuleName | str replace '.nu' ''
def discover-tests [module testImportScript] {
run-nushell [
--commands
$"use ($testSpecModuleName)
$"($testImportScript)
scope modules
| where name == '($module)'
Expand All @@ -24,7 +27,7 @@ def discover-tests [testSpecModuleName] {
{
id: \($it.index + 1)
name: $it.item
exec: $'use ($testSpecModuleName) *; try {\($it.item)} catch {|err| print -e $err.debug; exit 1}'
exec: $'($testImportScript); try {\($it.item)} catch {|err| print -e $err.debug; exit 1}'
}
}
| to nuon"
Expand Down

0 comments on commit c1f9b7e

Please sign in to comment.