(sigil test native-backend)
(sigil test native-backend) - Native Codegen Backend Test Runner
Runs test files through native compilation instead of bytecode. For each test file:
- Run via bytecode to get baseline output
- Build a native executable via the host-supplied build-fn (the build-fn owns codegen + linking)
- Run the native binary
- Compare outputs
Categories: PASS - native output matches bytecode DIFF - native output differs from bytecode BUILDFAIL - build-fn returned success? = #f (covers what used to be split into COMPILEFAIL + BUILDFAIL; granularity folded into build-fn's build-output diagnostic string) RUNFAIL - native binary crashes or exits non-zero with signal TIMEOUT - native binary hangs (>30s) BC_FAIL - bytecode run itself fails (skip baseline)
The native backend is dependency-inverted at the top entry point run-native-backend-tests. Hosts (sigil-cli, embedded harnesses, the future sigilc self-test) supply the build-fn callback. There is no direct dependency on (sigil build) or (sigil compiler) here.
Exports
strip-ansiprocedureStrip ANSI escape codes from a string
filter-bytecode-outputprocedureFilter output lines, removing build noise and empty lines.
filter-native-outputprocedureFilter native output lines, removing empty lines and trailing result values from the standalone main.
line-is-build-noise?procedureCheck if a line is build noise from sigil run
capture-command-outputprocedureRun a command and capture stdout as lines. Returns (exit-code . lines).
capture-command-stderrprocedureRun a command and capture stderr. Drains stdout to avoid buffer deadlock. Returns (exit-code . stderr-string).
read-all-linesprocedureRead all lines from a port
drain-portprocedureDrain a port without accumulating data
file->labelprocedureBuild the label for a test file (dir/name)
file->safe-nameprocedureBuild a safe filename from a test path for temp files
run-single-native-testprocedureRun a single test file through the native backend pipeline. Returns a native-backend-result.
run-native-build-and-compareprocedureSteps 2-4: Build via host-supplied build-fn, run, and compare. The build-fn owns both Scheme→C codegen and linking.
run-native-and-compareprocedureSteps 4-5: Run native binary and compare with bytecode.
lines-equal?procedureCompare two lists of lines for equality
make-diff-summaryprocedureCreate a brief diff summary showing first difference
run-native-backend-testsprocedureRun native backend tests for a list of files. Prints progress and returns a native-backend-summary.
files: list of test file paths options: alist with optional keys: verbose - show diff details quiet - suppress per-test output results-dir - directory for artifacts (default: /tmp/native-test-results) sigil-bin - bytecode binary used for the baseline run (default: build/boot/bin/sigil under current dir)
Keyword arguments: build-fn: (build-fn config sources output-path opts) => (values success? artifact-path build-output) REQUIRED for native runs. Ownership: codegen + linking. config: symbol like 'dev / 'release, or a workspace-resolved config record. Threaded into every build-fn call so hosts can pick output dirs / flags / features.
print-category-lineprocedurePrint a summary category line (only if count > 0, except PASS)
print-native-backend-resultprocedurePrint a single native backend test result
native-backend-resultvariable(No description)
native-backend-result?variable(No description)
native-backend-result-filevariable(No description)
native-backend-result-categoryvariable(No description)
native-backend-result-messagevariable(No description)
native-backend-summaryvariable(No description)
native-backend-summary?variable(No description)
native-backend-summary-totalvariable(No description)
native-backend-summary-passvariable(No description)
native-backend-summary-diffvariable(No description)
(No description)
(No description)
native-backend-summary-run-failvariable(No description)
native-backend-summary-timeoutvariable(No description)
native-backend-summary-bc-failvariable(No description)