fix(tests): clear NODE_TEST_CONTEXT for nested node --test in two suites (#1508)

test-foundation.sh and test-discord.sh ran a nested node --test that would
exit 0 on failure under a parent runner. Both clear the variable now, and
each has a check that fails the suite if it comes back. Darkwing wrote it,
Filbert approved it (e464be6c). Nine suites green on an index export.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-09-26 19:10:31 -05:00
co-authored by Claude Opus 5.5
parent 34a72af912
commit 08bd3a4cc5
8 changed files with 175 additions and 14 deletions
+59
View File
@@ -0,0 +1,59 @@
# N13: nested `node --test` in two suites (#1508)
Darkwing, 2026-09-26. Filbert's note N13, put in DEFERRED by Sage as a
small reviewed item before A2. Nothing is committed, staged or pushed.
## The defect
`scripts/test-foundation.sh:76` and `scripts/test-discord.sh:142` start a
nested `node --test` without clearing `NODE_TEST_CONTEXT`. Under a parent
test runner the nested run reports to that runner and exits 0 whatever its
tests do. I reproduced it at HEAD 40a02d2b: with a failing test planted in
each suite's test directory and `NODE_TEST_CONTEXT=child-v8` set, both
suites exit 0. The check line reads `OK node --test ... (summary
missing)`. In a control run of foundation without the variable, the same
planted test fails the suite, so only a run under a parent runner is
blind. I ran that control for foundation only.
## The change
`n13.patch` (sha256 00868b2f) changes only the two suites, +20 −2 lines.
Each suite now has a `node_tests` function that runs `env -u
NODE_TEST_CONTEXT node --test`, and uses it for its test run. Each also
gets one new check. It writes a failing test into the sandbox, runs it
through `node_tests` with `NODE_TEST_CONTEXT=child-v8` set, and requires
exit 1 and `✖ planted failure` in the output. If someone drops the `env
-u`, that check fails on every run, not only under a parent runner.
| File | sha256 |
|---|---|
| `scripts/test-foundation.sh` | 60f04822 |
| `scripts/test-discord.sh` | 2ad3be74 |
| `n13-check.sh` | 6a231759 |
## The check
`n13-check.sh CLONE` runs in a scratch clone only and refuses the
canonical checkout. For each suite it plants a failing test in the real
test directory and runs the whole suite with `NODE_TEST_CONTEXT=child-v8`:
| Suite | Case | Exit |
|---|---|---|
| foundation | HEAD, planted failure | 0 (the defect) |
| foundation | fixed, planted failure | 1 |
| foundation | fixed, no planted failure | 0 |
| foundation | fixed but `env -u` removed, no planted failure | 1 |
| discord | HEAD, planted failure | 0 (the defect) |
| discord | fixed, planted failure | 1 |
| discord | fixed, no planted failure | 0 |
| discord | fixed but `env -u` removed, no planted failure | 1 |
In the fixed runs with the planted failure, the suite prints `FAIL node
--test ...` with the pass count and the planted test's name. The last row
of each is the mutation: the new check alone fails the suite.
All nine suites pass at 40a02d2b with this change and the queue A1
candidate: foundation 44 and discord 64, one more check each than before.
I found no other nested `node --test` in the suites. `test-queue.sh` and
`queue-commit.sh` already clear the variable.