Skip to content

Commit

Permalink
Fix problems running Test262 tests in a debugger
Browse files Browse the repository at this point in the history
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.

js-temporal/temporal-polyfill#46 requires this.
  • Loading branch information
justingrant committed Sep 10, 2021
1 parent 899cc24 commit fc2e24c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions polyfill/ci_test.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash

TESTS=${@:-"./*/**/*.js"}
TIMEOUT=${TIMEOUT:-10000}
PRELUDE=${PRELUDE:-script.js}

export NODE_PATH=$PWD/node_modules
Expand Down Expand Up @@ -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" \
Expand Down
5 changes: 5 additions & 0 deletions polyfill/test/parseResults.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit fc2e24c

Please sign in to comment.