Files
stack/agents/darkwing/work/queue-a1/n13.patch
T
jason.woltjeandClaude Opus 5.5 08bd3a4cc5 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]>
2026-09-26 19:10:31 -05:00

45 lines
2.7 KiB
Diff
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
diff --git a/scripts/test-discord.sh b/scripts/test-discord.sh
index 6044100c..9ec4ddda 100755
--- a/scripts/test-discord.sh
+++ b/scripts/test-discord.sh
@@ -139,7 +139,16 @@ else
fi
# --- the seven offline groups ---
-node --test --test-reporter=spec packages/discord/tests/ >"$SANDBOX/node-test.log" 2>&1
+# A nested `node --test` inherits a parent runner's NODE_TEST_CONTEXT, reports
+# to that runner and exits 0 whatever its tests do, so the suite clears it
+# (#1508 N13). The planted failing test proves a failure still fails here.
+node_tests() { env -u NODE_TEST_CONTEXT node --test "$@"; }
+mkdir -p "$SANDBOX/planted"
+printf '%s\n' 'import { test } from "node:test";' 'import assert from "node:assert/strict";' 'test("planted failure", () => assert.equal(1, 2));' >"$SANDBOX/planted/planted.test.mjs"
+NODE_TEST_CONTEXT=child-v8 node_tests "$SANDBOX/planted/" >"$SANDBOX/planted.log" 2>&1
+[ $? -eq 1 ] && grep -q '^✖ planted failure' "$SANDBOX/planted.log"
+check "a failing nested test fails the run under a parent runner's NODE_TEST_CONTEXT" $?
+node_tests --test-reporter=spec packages/discord/tests/ >"$SANDBOX/node-test.log" 2>&1
NODE_RC=$?
check "node --test packages/discord/tests/ ($(grep -E '^ℹ pass' "$SANDBOX/node-test.log" | tr -d '\n' || echo 'summary missing'))" $NODE_RC
if [ "$NODE_RC" -ne 0 ]; then
diff --git a/scripts/test-foundation.sh b/scripts/test-foundation.sh
index 251eb674..b94dab5c 100755
--- a/scripts/test-foundation.sh
+++ b/scripts/test-foundation.sh
@@ -73,7 +73,16 @@ done
check "checked-in demo bundles equal a fresh generation" $DEMO_OK
# --- unit, CLI, privacy, non-effect and fixture-index tests ---
-node --test scripts/foundation/ >"$SANDBOX/node-test.log" 2>&1
+# A nested `node --test` inherits a parent runner's NODE_TEST_CONTEXT, reports
+# to that runner and exits 0 whatever its tests do, so the suite clears it
+# (#1508 N13). The planted failing test proves a failure still fails here.
+node_tests() { env -u NODE_TEST_CONTEXT node --test "$@"; }
+mkdir -p "$SANDBOX/planted"
+printf '%s\n' 'import { test } from "node:test";' 'import assert from "node:assert/strict";' 'test("planted failure", () => assert.equal(1, 2));' >"$SANDBOX/planted/planted.test.mjs"
+NODE_TEST_CONTEXT=child-v8 node_tests "$SANDBOX/planted/" >"$SANDBOX/planted.log" 2>&1
+[ $? -eq 1 ] && grep -q '^✖ planted failure' "$SANDBOX/planted.log"
+check "a failing nested test fails the run under a parent runner's NODE_TEST_CONTEXT" $?
+node_tests scripts/foundation/ >"$SANDBOX/node-test.log" 2>&1
NODE_RC=$?
check "node --test scripts/foundation/ ($(grep -E '^ℹ pass' "$SANDBOX/node-test.log" | tr -d '\n' || echo 'summary missing'))" $NODE_RC
[ "$NODE_RC" -ne 0 ] && grep -E "^✖|AssertionError" "$SANDBOX/node-test.log" | head -20