(sigil test cli)
(sigil test cli) - Reusable Test CLI Logic
Provides argument parsing and test execution for both the sigil test command and standalone test harnesses. This module allows test harnesses to share the exact same behavior as sigil test.
The native-backend path requires the host to supply a build-fn (the runner's top-level dep inversion — see (sigil test native-backend)). Pass it via test-main's keyword args:
(test-main args build-fn: <fn> config: 'dev)
Harness binaries built by sigil-build call (test-main args) without kwargs — they don't need the native-backend path because the harness itself is already a native binary running bytecode tests. If a user passes --backend=native to a harness without a build-fn injected, the runner errors with a clear message.
Exports
parse-test-argsprocedureParse test command arguments into an options alist.
Recognizes the following flags: --native Run only native (C) tests --sgl Run only Sigil (.sgl) tests -f, --filter Run only tests matching PATTERN -c, --compact Compact output (dots instead of full names) -q, --quiet Minimal output (exit code only) --fail-fast Stop on first failure --no-color Disable colored output --report PATH Write JSON report to PATH and print summary line
Returns: (options . remaining-args) options - alist of parsed options remaining-args - non-flag arguments (test files/directories)
file-executable?procedureCheck if a file is executable
discover-native-testsprocedureDiscover native test executables in build directories. Looks for test- executables in build//bin/
expand-test-argsprocedureExpand test arguments (files or directories) to test file paths.
test-mainprocedureMain entry point for running tests.
This function can be called from:
- The
sigil testCLI command (via sigil-cli's (sigil cli test) orchestrator, which supplies build-fn:) - A standalone test harness binary (no kwargs — bytecode mode only)
Arguments: args - command-line arguments (excluding program name)
Keyword arguments: build-fn: callback for native-backend compile + link. Required when the user passes --backend=native; if absent the runner errors with a clear message. config: symbol like 'dev / 'release. Defaults to whatever --config sets, then 'dev. Passed through to build-fn.
Returns: exit code (0 = success, 1 = failures)