testing
This commit is contained in:
1 parent
d47c401013
commit
49c6d6e6cc
7 files changed
+187
-17
No files matched your search
Executable
+27
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env nu
|
||||
#
|
||||
# runtest — run the hermenix CLI test suite (nu/tests/).
|
||||
#
|
||||
# Requires the nutest module on NU_LIB_DIRS, which `nix develop`'s devShell
|
||||
# sets up (that devShell also puts bin/ on PATH, so `runtest` works bare).
|
||||
# Runs everything by default; pass a suite name to run just one file
|
||||
# instead:
|
||||
# runtest # everything
|
||||
# runtest vm_test # only nu/tests/vm_test.nu
|
||||
#
|
||||
# To step through a single suite interactively instead of via nutest's
|
||||
# runner, use runtest-debug.
|
||||
|
||||
use nutest
|
||||
|
||||
def main [
|
||||
suite?: string # only run nu/tests/<suite>.nu, e.g. vm_test
|
||||
] {
|
||||
let repo_root = ($env.FILE_PWD | path dirname)
|
||||
let tests_path = ($repo_root | path join "nu" "tests")
|
||||
if $suite == null {
|
||||
nutest run-tests --path $tests_path --fail --returns table
|
||||
} else {
|
||||
nutest run-tests --path $tests_path --fail --match-suites $suite --returns table
|
||||
}
|
||||
}
|
||||
Executable
+29
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env nu
|
||||
#
|
||||
# runtest-debug — interactively debug one CLI test file.
|
||||
#
|
||||
# Sources the given suite (e.g. `runtest-debug vm_test`) and drops you into
|
||||
# an interactive nushell session with it loaded, instead of running it
|
||||
# through nutest. Call any @test-tagged command by its full name to run
|
||||
# just that test on its own and inspect what happens — nutest's runner
|
||||
# captures output and runs tests concurrently, which gets in the way of
|
||||
# stepping through a failure by hand.
|
||||
#
|
||||
# Test files don't need NU_LIB_DIRS/nutest themselves (only runtest's own
|
||||
# runner does), so this works without the devShell's nutest wiring too.
|
||||
|
||||
def main [suite: string] {
|
||||
let repo_root = ($env.FILE_PWD | path dirname)
|
||||
let file = ($repo_root | path join "nu" "tests" $"($suite).nu")
|
||||
if not ($file | path exists) {
|
||||
print -e $"no such test file: ($file)"
|
||||
exit 1
|
||||
}
|
||||
let child_script = (
|
||||
"source '" + $file + "'\n"
|
||||
+ "print 'Loaded. Custom/test commands now in scope:'\n"
|
||||
+ "scope commands | where type == 'custom' | get name | each {|n| print (' ' + $n)}\n"
|
||||
+ "print 'Call one by its full name to run just that test.'"
|
||||
)
|
||||
^nu --execute $child_script
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
#!/usr/bin/env nu
|
||||
#
|
||||
# bin/test — run the full hermenix CLI test suite (nu/tests/).
|
||||
#
|
||||
# Requires the nutest module on NU_LIB_DIRS, which `nix develop`'s devShell
|
||||
# sets up. For filtering to specific suites/tests, run
|
||||
# `nutest run-tests --path nu/tests --match-tests <pattern>` directly.
|
||||
|
||||
use nutest
|
||||
|
||||
def main [] {
|
||||
let repo_root = ($env.FILE_PWD | path dirname)
|
||||
nutest run-tests --path ($repo_root | path join "nu" "tests") --fail
|
||||
}
|
||||
Reference in new issue
Block a user