cli/gda_expr_cli tutorial
This tutorial shows how to run .decTest files with the GDA runner: select
files and rows, shard a run, get JSON output and make unsupported rows fail
the run. The runner is reached as floating-conformance --backend gda; below,
gda abbreviates that command.
| I want to | Use |
|---|---|
| run the committed smoke file | gda with no path |
| run some files or a directory | gda PATH … |
| run only some row ids | --cases |
| split a corpus over processes | --shard-count, --shard-index |
| fail on rows that were not executed | --strict-supported |
| call the runner from MoonBit | @gda_expr_cli.run |
Quick start
The executable is built from a checkout of the repository. Build it and run the committed smoke file:
just conformance build decimal_gda
_build/conformance/gda/native/release/build/gda-conformance.exe --backend gda
GDA expression execution summary
cases: …
selected cases: …
executable cases: …
passed cases: …
failed cases: 0
skipped cases: …
shard: 0/1
The exit status is 0 when no executable row failed.
From MoonBit code
The runner is also a library. The package belongs to the tools module Luna-Flow/floating-tools (directory tooling/ of the repository, versioned with the library), not to the published library. Write your code as a package of this workspace or, once the tools module is published, run moon add Luna-Flow/floating-tools@0.11.0. Import it and pass the argument vector, program name first:
import {
"Luna-Flow/floating-tools/cli/gda_expr_cli",
}
///|
test "run the GDA runner from MoonBit code" {
let status = @gda_expr_cli.run([
"gda", "--json", "../testdata/decimal_gda/smoke.decTest",
])
inspect(status, content="0")
// A file that is not a `.decTest` file is a usage error.
inspect(@gda_expr_cli.run(["gda", "moon.mod"]), content="2")
}
just docs runs the tests of this page in the module directory tooling/, so the corpus paths start with ../testdata; use your own paths in your code.
run prints the same output as the executable and returns the exit status
instead of exiting.
Everyday tasks
Run files and directories
gda path/to/add.decTest path/to/multiply.decTest
gda .tmp/decimal/official # every *.decTest directly in the directory
Files are sorted by path and executed as one run; a file named twice runs once.
Select rows
gda --cases add001 add.decTest
gda --cases add001..add099,addx1001 add.decTest
A range matches ids of the same length that sort between its bounds.
Shard a run
gda --json --shard-count 4 --shard-index 0 .tmp/decimal/official
gda --json --shard-count 4 --shard-index 1 .tmp/decimal/official
Shard i runs the rows whose position (after the --cases filter, across all
files) is i modulo the shard count. Adding the JSON counters of all shards
gives the counters of the unsharded run, except totalCases, which every
shard already reports for the whole run.
Fail on unsupported rows
gda --strict-supported add.decTest
With --strict-supported the exit status is 1 if any selected row is
unsupported or legacy, even when all executed rows pass.
Going further
just conformance run decimal_gdafetches the pinned official corpora, splits them into the phases oftestdata/decimal_gda/interpreter_stages.jsonand runs the shards in parallel with this runner.- gda_expr tutorial explains the row semantics and the pass rule.
Common pitfalls
--helpreturns2. The runner prints its usage as an error; through the dispatcher,--helpshows the dispatcher usage instead.- First parse error only. A malformed line stops the run with one
file:line:1: message; fix it and rerun to see the next. - Non-recursive directories. Subdirectories are not searched.
- The suffix is case-sensitive. A named file such as
add.dectestoradd.txtis the errornot a .decTest file: PATH(exit2), and inside a directory such entries are skipped, so a directory without any.decTestfile gives an empty run that exits with0.
Next steps
- cli/gda_expr_cli API for options, output keys and exit codes.
- cli/gda_expr_cli design.
- frontend/gda_expr tutorial for the row semantics.