diff --git a/docs/adrs/adr-0007-test-framework.md b/docs/adrs/adr-0007-test-framework.md index 0d615b7..115cb0f 100644 --- a/docs/adrs/adr-0007-test-framework.md +++ b/docs/adrs/adr-0007-test-framework.md @@ -50,7 +50,7 @@ Two independent timeout layers, ordered so the finer one fires first. **Layer 1 — `libtest` per-case timeout (primary).** [`apis/libtest.lua`](../../packages/trapos-test/apis/libtest.lua) races each test case against a timer with `parallel.waitForAny(runner, timer)`. The default is `DEFAULT_TIMEOUT_SECONDS = 3`. When the timer wins, the case fails with a distinct message containing the token `libtest timeout` and, in `--verbose`, an extra `TIMEOUT … (libtest)` diagnostic. `--timeout ` overrides the default; `--no-timeout` disables the layer. `runtest` forwards both flags to each case script. This only interrupts cases that yield (the usual hang); a non-yielding CPU loop cannot be preempted in ComputerCraft. -**Layer 2 — shell watchdog (backstop).** The `Justfile` `test:` recipe keeps its `TRAPOS_TEST_TIMEOUT_SECONDS` watchdog as an independent double-check. Its default matches the libtest default (`.env.test` ships `3`; the recipe falls back to `3`) so libtest fires first for yielding cases in normal runs and the watchdog only catches what Lua cannot — a non-yielding loop, a wedged libtest, or a deliberately bypassed case. Its SIGTERM message is worded differently from the `libtest timeout` message, so the two layers are never confused. +**Layer 2 — shell watchdog (backstop).** The `Justfile` `test:` recipe keeps its `TRAPOS_TEST_TIMEOUT_SECONDS` watchdog as an independent double-check. Its default matches the libtest default (`env.sample` ships `3`; the recipe falls back to `3`) so libtest fires first for yielding cases in normal runs and the watchdog only catches what Lua cannot — a non-yielding loop, a wedged libtest, or a deliberately bypassed case. Its SIGTERM message is worded differently from the `libtest timeout` message, so the two layers are never confused. ### How to write tests properly diff --git a/.env.test b/env.sample similarity index 100% rename from .env.test rename to env.sample diff --git a/just/install.just b/just/install.just index eacc52e..892bfb5 100644 --- a/just/install.just +++ b/just/install.just @@ -39,5 +39,5 @@ generate-env: printf '%s\n' "$line" ;; esac - done < .env.test > .env + done < env.sample > .env printf '%s\n' 'Generated .env' diff --git a/just/test.just b/just/test.just index 1a83a9f..9570be3 100644 --- a/just/test.just +++ b/just/test.just @@ -20,7 +20,7 @@ _craftos-test *args: stage #!/usr/bin/env bash set -uo pipefail - if [ -f .env.test ]; then set -a; . ./.env.test; set +a; fi + if [ -f env.sample ]; then set -a; . ./env.sample; set +a; fi pretty=0 has_output=0 @@ -98,7 +98,7 @@ _timeout-fixture script shell_timeout extra_flag expect: check-install stage #!/usr/bin/env bash set -uo pipefail repo='{{justfile_directory()}}' - if [ -f "$repo/.env.test" ]; then set -a; . "$repo/.env.test"; set +a; fi + if [ -f "$repo/env.sample" ]; then set -a; . "$repo/env.sample"; set +a; fi rom_arg="" if [ "$(uname -s)" = "Darwin" ]; then rom_arg="--rom /Applications/CraftOS-PC.app/Contents/Resources"