Testing
The rules are in AGENTS.md. In short: the whole suite runs in under 2 minutes, and every test is a fast, deterministic, non-trivial unit test of core logic.
Commands
cargo test --workspace # all unit tests (about a second once built)
cargo test -p tenon-frontend compact # one module in a workspace crate
tenon interp scripts/run_script_tests.tn # dogfooded Tenon script tests (in make check)
python3 -B -m unittest discover -s scripts -p 'test_*.py' # optional Python bench/fuzz script tests
make check # the gate: lint, format, tests with the time budget
scripts/check.sh --quiet # same gate; prints `check: OK` and the log path, or only the failing step (TENON_QUIET=1 works too)
scripts/gate.sh --quiet # gate with a tree-keyed cache: a hit on an identical clean tree equals a pass
scripts/gate.sh --fast # inner-loop tier; never counts as a full pass (--force reruns, ignoring the cache)
scripts/gate.sh --gcc # opt out of the TinyCC default
TENON_FAST_CC=0 make check # opt out for make check (CC=gcc also works)
Native dev builds in the gate and in tenon test
and tenon run default to TinyCC.
tenon check is frontend-only. If TinyCC is
unavailable, the driver notes the fallback to gcc
-O0; dev FFI builds use a GCC-compatible compiler.
Release builds (tenon build /
tenon build --release) default to -O3
(and --profile uses -g -O2,
--debug uses -g -Og, --dev
uses -O0), and an explicit CC wins.
TENON_FAST_CC=1 remains compatible with the TinyCC
default. See ADR-0233.
The gate builds the tests first, then times only the run. Over
TENON_TEST_BUDGET_SECONDS (default 120) it fails. To
find what to cut:
RUSTC_BOOTSTRAP=1 cargo test --workspace -- -Z unstable-options --format json --report-time
Writing a test
- Call a pure function with in-memory input and assert on the result.
- One behaviour per test. Use a table inside one test for many inputs.
- No processes, C compiler, network, sleeps, wall clock or shared files. If the code under test needs them, extract the logic into a function that does not.
- Name it for the behaviour:
recursive_types_terminate, nottest3. - Do not test that constants equal themselves, that a single token lexes to one kind, or that a message string is unchanged.
What is not tested here
End-to-end runs of compiled programs on both backends, sandbox
and process behaviour, sanitizers, network and registry flows, and
performance are checked on demand with the tools under
bench/ and by hand. They are deliberately outside the
default suite. If one of them keeps catching real bugs, turn the
logic it exercises into a unit test.
Applying this to other Tenon apps
Every Tenon app keeps the same budget and the same criteria in its own AGENTS.md: under 2 minutes in total, unit-level, deterministic, no end-to-end or golden suites in the default gate.