test(harness): shorten timeout checks
This commit is contained in:
parent
3c4a8876b9
commit
8065502e0d
@ -23,4 +23,4 @@ Test timeouts run in two independent layers (see [`docs/adrs/adr-0009-layered-te
|
||||
- **libtest per-case timeout (primary).** Each `libtest` case is cancelled after `3` seconds by default, failing with a distinct `libtest timeout` message. Override with `--timeout <seconds>`, or disable with `--no-timeout` (both forwarded by `runtest` to each case). This catches a single hung case quickly without taking down the whole run.
|
||||
- **Shell watchdog (backstop).** The whole CraftOS-PC process is killed if it does not finish within `TRAP_CCLIBS_TEST_TIMEOUT_SECONDS` (`.env.sample` ships `7`; the recipe falls back to `7`). Keep it above the `3`s libtest default so libtest fires first; the watchdog only catches what Lua cannot interrupt. Override in `.env` for slower local probes.
|
||||
|
||||
`just test-timeout` is a self-asserting regression guard for these layers and runs automatically as part of `just ci`. It chains `just test-timeout-lua` (proves libtest cancels a slow case at 2s, before a generous 5s shell backstop) and `just test-timeout-shell` (proves the 3s shell watchdog kills a slow case run with `--no-timeout`). Both drive the `tests/harness/slow-case.lua` fixture, which is never picked up by the normal `just test` suite (`runtest` skips `tests/` subdirectories).
|
||||
`just test-timeout` is a self-asserting regression guard for these layers and runs automatically as part of `just ci`. It chains `just test-timeout-lua` (proves libtest cancels a slow case at 0.1s, before a 2s shell backstop) and `just test-timeout-shell` (proves the 1s shell watchdog kills a slow case run with `--no-timeout`). Both drive the `tests/harness/slow-case.lua` fixture, which is never picked up by the normal `just test` suite (`runtest` skips `tests/` subdirectories).
|
||||
|
||||
10
Justfile
10
Justfile
@ -205,13 +205,13 @@ _timeout-fixture script shell_timeout extra_flag expect: check-install
|
||||
rm -rf "$data_dir"
|
||||
exit "$rc"
|
||||
|
||||
# Prove the libtest (Lua) timeout layer: libtest cancels the slow case at 2s,
|
||||
# before the generous 5s shell watchdog backstop can fire.
|
||||
test-timeout-lua: (_timeout-fixture "/tests/harness/slow-case.lua" "5" "'--timeout', '2'," "lua")
|
||||
# Prove the libtest (Lua) timeout layer: libtest cancels the slow case quickly,
|
||||
# before the shell watchdog backstop can fire.
|
||||
test-timeout-lua: (_timeout-fixture "/tests/harness/slow-case.lua" "2" "'--timeout', '0.1'," "lua")
|
||||
|
||||
# Prove the shell watchdog backstop: the slow case runs with the libtest timeout
|
||||
# bypassed (--no-timeout), so the 3s shell watchdog kills the whole process.
|
||||
test-timeout-shell: (_timeout-fixture "/tests/harness/slow-case.lua" "3" "'--no-timeout'," "shell")
|
||||
# bypassed (--no-timeout), so the shell watchdog kills the whole process.
|
||||
test-timeout-shell: (_timeout-fixture "/tests/harness/slow-case.lua" "1" "'--no-timeout'," "shell")
|
||||
|
||||
# Fast regression guard for both timeout layers. Wired into `ci`.
|
||||
test-timeout: test-timeout-lua test-timeout-shell
|
||||
|
||||
@ -58,11 +58,11 @@ confused.
|
||||
- A hung case now fails in ~3s with a per-case message instead of taking down the whole
|
||||
process anonymously.
|
||||
- `just test-timeout` is a self-asserting harness regression guard wired into `just ci`. It
|
||||
chains `test-timeout-lua` (Layer 1: libtest cancels the slow case at 2s, before a generous
|
||||
5s shell backstop) and `test-timeout-shell` (Layer 2: the 3s watchdog kills the slow case
|
||||
with libtest bypassed). Both drive a single `tests/harness/slow-case.lua` fixture; the
|
||||
tight timeouts — not the fixture's sleep length — decide which layer fires, so each check
|
||||
finishes in ~3s and the harness itself is covered against regressions on every `ci`.
|
||||
chains `test-timeout-lua` (Layer 1: libtest cancels the slow case at 0.1s, before a 2s
|
||||
shell backstop) and `test-timeout-shell` (Layer 2: the 1s watchdog kills the slow case with
|
||||
libtest bypassed). Both drive a single `tests/harness/slow-case.lua` fixture; the tight
|
||||
timeouts — not the fixture's sleep length — decide which layer fires, so the harness itself
|
||||
is covered against regressions on every `ci`.
|
||||
- `libtest` stays a normal ComputerCraft program: `parallel` and `sleep` are sandbox
|
||||
globals, so the timeout works in CraftOS-PC and in-game alike.
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user