File tree Expand file tree Collapse file tree 2 files changed +20
-9
lines changed Expand file tree Collapse file tree 2 files changed +20
-9
lines changed Original file line number Diff line number Diff line change 1
- def main [] {
2
- discover-tests
1
+ def main [-- test-spec-module-name = " test-spec.nu" ] {
2
+ if (not ($test_spec_module_name | path exists )) {
3
+ return $" Invalid test spec module: ($test_spec_module_name )"
4
+ }
5
+ discover-tests $test_spec_module_name
3
6
| run-tests
4
7
| output-tests
5
8
}
6
9
7
- def discover-tests [] {
10
+ def discover-tests [testSpecModuleName ] {
11
+ let module = $testSpecModuleName | str replace ' .nu' ' '
8
12
run-nushell [
9
13
--commands
10
- ' use test-spec.nu
14
+ $" use ( $testSpecModuleName )
11
15
12
16
scope modules
13
- | where name == "test-spec"
17
+ | where name == '( $module )'
14
18
| get commands
15
19
| flatten
16
- | where name =~ " ^test"
20
+ | where name =~ ' ^test'
17
21
| get name
18
22
| enumerate
19
23
| each {|it|
20
24
{
21
- id: ($it.index + 1)
25
+ id: \ ( $it.index + 1)
22
26
name: $it.item
23
- exec: $" use test-spec.nu ; try {test-spec ($it.item)} catch {|err| print -e $err.msg ; exit 1}"
27
+ exec: $' use ( $testSpecModuleName ) * ; try {\ ( $it.item)} catch {|err| print -e $err.debug ; exit 1}'
24
28
}
25
29
}
26
- | to nuon'
30
+ | to nuon"
27
31
]
28
32
| from nuon
29
33
}
Original file line number Diff line number Diff line change
1
+ use std assert
2
+
3
+ export def "test handles when spec does not exist" [] {
4
+ let specFile = " not real"
5
+ ^$nu.current-exe --no-config-file nuunit.nu -- test-spec-module-name $specFile
6
+ | assert equal $" Invalid test spec module: ($specFile )" ($in | str trim )
7
+ }
You can’t perform that action at this time.
0 commit comments