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