#!/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
    }
}
