File tree Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ export def main [
4
4
-- test-spec-module-name = " test-spec.nu"
5
5
-- as-json
6
6
] {
7
- if (not ( $test_spec_module_name | path exists ) ) {
7
+ if (is- not-valid-test-spec $test_spec_module_name ) {
8
8
return $" Invalid test spec module: ($test_spec_module_name )"
9
9
}
10
10
let module = $test_spec_module_name | split row ' /' | last | str replace ' .nu' ' '
@@ -24,17 +24,30 @@ export def main [
24
24
| exit $in
25
25
}
26
26
27
+ def is-not-valid-test-spec [spec ] {
28
+ not ($spec | path exists )
29
+ }
30
+
27
31
def run-test-discoverer [module testImportScript ] {
28
32
run-nushell [
29
33
--commands
30
34
$" ($testImportScript )
31
- (view source discover-tests )
35
+ (inline- source-code discover-tests )
32
36
discover-tests '($module )' '($testImportScript )'
33
37
| to nuon"
34
38
]
35
39
| from nuon
36
40
}
37
41
42
+ def inline-source-code [command ] {
43
+ try {
44
+ view source $command
45
+ } catch {
46
+ view source $" nuunit ($command )"
47
+ | str replace ' nuunit ' ' '
48
+ }
49
+ }
50
+
38
51
export def discover-tests [module testImportScript ] {
39
52
scope modules
40
53
| where name == $module
Original file line number Diff line number Diff line change @@ -114,6 +114,18 @@ export def "test that the after each passes context to a test" [] {
114
114
| verify json results
115
115
}
116
116
117
+ export def "test that importing all nuunit commands is gracefully handled" [] {
118
+ use std assert
119
+ let specFile = " tests/generic-test-spec.nu"
120
+
121
+ let results = do {
122
+ ^$nu.current-exe --no-config-file -c $' use nuunit.nu; nuunit --test-spec-module-name ($specFile )'
123
+ }
124
+ | complete
125
+
126
+ assert (0 == $results.exit_code )
127
+ }
128
+
117
129
def run-test-spec [specFile ] {
118
130
(^$nu.current-exe --no-config-file nuunit.nu -- test-spec-module-name $specFile -- as-json )
119
131
| from json
You can’t perform that action at this time.
0 commit comments