From fc2e24ce3de435d8274ecef0ef442f6bf3a9fcc2 Mon Sep 17 00:00:00 2001 From: Justin Grant Date: Fri, 10 Sep 2021 14:42:18 -0700 Subject: [PATCH] Fix problems running Test262 tests in a debugger This commit enables running Test262 in debuggers like VSCode: * Adds a TIMEOUT environment variable (in msecs) to prevent the harnesss from killing the process while you're debugging it. Default is 10,000ms === 10 seconds. (same as existing default) * Works around a problem where passing tests were mistakenly labelled as failures when run in the debugger because of Node's debug-related console output. https://github.com/js-temporal/temporal-polyfill/pull/46 requires this. --- polyfill/ci_test.sh | 2 ++ polyfill/test/parseResults.js | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/polyfill/ci_test.sh b/polyfill/ci_test.sh index 4364df15e5..a388efd140 100755 --- a/polyfill/ci_test.sh +++ b/polyfill/ci_test.sh @@ -1,6 +1,7 @@ #!/bin/bash TESTS=${@:-"./*/**/*.js"} +TIMEOUT=${TIMEOUT:-10000} PRELUDE=${PRELUDE:-script.js} export NODE_PATH=$PWD/node_modules @@ -37,6 +38,7 @@ test262-harness \ --reporter-keys file,rawResult,result,scenario \ --test262Dir ../test262 \ --prelude "../$PRELUDE" \ + --timeout "$TIMEOUT" \ --preprocessor ./preprocessor.test262.js \ $TRANSFORMER_ARG \ "$TESTS" \ diff --git a/polyfill/test/parseResults.js b/polyfill/test/parseResults.js index f01f591f97..19b47c3baf 100755 --- a/polyfill/test/parseResults.js +++ b/polyfill/test/parseResults.js @@ -52,6 +52,11 @@ stdin.on('end', function () { const unexpectedPasses = []; for (const test of tests) { const { result, scenario, file } = test; + if (result.message === 'Debugger attached.\nWaiting for the debugger to disconnect...\n') { + // work around https://github.com/nodejs/node/issues/34799 when running tests in the debugger + result.message = ''; + result.pass = true; + } const expectedFailure = expectedFailures.has(file); const message = `${PREFIXES[+expectedFailure][+result.pass]} ${file} (${scenario})\n`; stdout.write(message);