From 014500cefa820d7d19dffa78dfa83938d4dec083 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Mon, 18 Mar 2024 15:41:36 -0400 Subject: [PATCH] Revert "test_runner: abort unfinished tests on async error" This reverts commit 29b231763ea96dd2de6e9cf45b72e1150cb0ac3c. Fixes: https://github.com/nodejs/node/issues/52139 --- lib/internal/test_runner/harness.js | 2 +- .../test-runner/output/describe_it.snapshot | 4 +- .../output/junit_reporter.snapshot | 2 + .../test-runner/output/output.snapshot | 2 + .../test-runner/output/output_cli.snapshot | 2 + .../test-runner/output/spec_reporter.snapshot | 4 ++ .../output/spec_reporter_cli.snapshot | 4 ++ .../output/unfinished-suite-async-error.js | 14 ------ .../unfinished-suite-async-error.snapshot | 43 ------------------- test/parallel/test-runner-output.mjs | 1 - 10 files changed, 18 insertions(+), 60 deletions(-) delete mode 100644 test/fixtures/test-runner/output/unfinished-suite-async-error.js delete mode 100644 test/fixtures/test-runner/output/unfinished-suite-async-error.snapshot diff --git a/lib/internal/test_runner/harness.js b/lib/internal/test_runner/harness.js index 504cc1e93acd7a..60b88558a0017a 100644 --- a/lib/internal/test_runner/harness.js +++ b/lib/internal/test_runner/harness.js @@ -75,7 +75,7 @@ function createProcessEventHandler(eventName, rootTest) { } test.fail(new ERR_TEST_FAILURE(err, eventName)); - test.abortController.abort(); + test.postRun(); }; } diff --git a/test/fixtures/test-runner/output/describe_it.snapshot b/test/fixtures/test-runner/output/describe_it.snapshot index f6fed1a481908b..1d4f7853ead0d1 100644 --- a/test/fixtures/test-runner/output/describe_it.snapshot +++ b/test/fixtures/test-runner/output/describe_it.snapshot @@ -494,9 +494,10 @@ not ok 50 - custom inspect symbol that throws fail * * * - async Promise.all (index 0) * * + * + async Promise.all (index 0) ... 1..2 not ok 51 - subtest sync throw fails @@ -627,6 +628,7 @@ not ok 54 - timeouts code: 'ERR_TEST_FAILURE' stack: |- * + * ... 1..2 not ok 55 - successful thenable diff --git a/test/fixtures/test-runner/output/junit_reporter.snapshot b/test/fixtures/test-runner/output/junit_reporter.snapshot index f29f72e6ddb2ed..c7136d18e6c3df 100644 --- a/test/fixtures/test-runner/output/junit_reporter.snapshot +++ b/test/fixtures/test-runner/output/junit_reporter.snapshot @@ -372,6 +372,8 @@ Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fails at second * * * + * + * } diff --git a/test/fixtures/test-runner/output/output.snapshot b/test/fixtures/test-runner/output/output.snapshot index 905acaa498bffb..0e6cab8549d4b2 100644 --- a/test/fixtures/test-runner/output/output.snapshot +++ b/test/fixtures/test-runner/output/output.snapshot @@ -552,6 +552,8 @@ not ok 51 - custom inspect symbol that throws fail * * * + * + * ... 1..2 not ok 52 - subtest sync throw fails diff --git a/test/fixtures/test-runner/output/output_cli.snapshot b/test/fixtures/test-runner/output/output_cli.snapshot index 37c85137e4eb7f..cd2be499a3b7de 100644 --- a/test/fixtures/test-runner/output/output_cli.snapshot +++ b/test/fixtures/test-runner/output/output_cli.snapshot @@ -552,6 +552,8 @@ not ok 51 - custom inspect symbol that throws fail * * * + * + * ... 1..2 not ok 52 - subtest sync throw fails diff --git a/test/fixtures/test-runner/output/spec_reporter.snapshot b/test/fixtures/test-runner/output/spec_reporter.snapshot index a15ce8261bfc65..5af5f4750569bc 100644 --- a/test/fixtures/test-runner/output/spec_reporter.snapshot +++ b/test/fixtures/test-runner/output/spec_reporter.snapshot @@ -229,6 +229,8 @@ * * * + * + * subtest sync throw fails (*ms) @@ -513,6 +515,8 @@ * * * + * + * * timed out async test (*ms) diff --git a/test/fixtures/test-runner/output/spec_reporter_cli.snapshot b/test/fixtures/test-runner/output/spec_reporter_cli.snapshot index 79e7ecbd61d88f..1321cb7321400d 100644 --- a/test/fixtures/test-runner/output/spec_reporter_cli.snapshot +++ b/test/fixtures/test-runner/output/spec_reporter_cli.snapshot @@ -229,6 +229,8 @@ * * * + * + * subtest sync throw fails (*ms) @@ -513,6 +515,8 @@ * * * + * + * * timed out async test (*ms) diff --git a/test/fixtures/test-runner/output/unfinished-suite-async-error.js b/test/fixtures/test-runner/output/unfinished-suite-async-error.js deleted file mode 100644 index ee6bf1a6918d48..00000000000000 --- a/test/fixtures/test-runner/output/unfinished-suite-async-error.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; -const { describe, it } = require('node:test'); - -describe('unfinished suite with asynchronous error', () => { - it('uses callback', (t, done) => { - setImmediate(() => { - throw new Error('callback test does not complete'); - }); - }); - - it('should pass 1'); -}); - -it('should pass 2'); diff --git a/test/fixtures/test-runner/output/unfinished-suite-async-error.snapshot b/test/fixtures/test-runner/output/unfinished-suite-async-error.snapshot deleted file mode 100644 index 593e46d45e779a..00000000000000 --- a/test/fixtures/test-runner/output/unfinished-suite-async-error.snapshot +++ /dev/null @@ -1,43 +0,0 @@ -TAP version 13 -# Subtest: unfinished suite with asynchronous error - # Subtest: uses callback - not ok 1 - uses callback - --- - duration_ms: * - location: '/test/fixtures/test-runner/output/unfinished-suite-async-error.js:(LINE):3' - failureType: 'uncaughtException' - error: 'callback test does not complete' - code: 'ERR_TEST_FAILURE' - stack: |- - * - * - ... - # Subtest: should pass 1 - ok 2 - should pass 1 - --- - duration_ms: * - ... - 1..2 -not ok 1 - unfinished suite with asynchronous error - --- - duration_ms: * - type: 'suite' - location: '/test/fixtures/test-runner/output/unfinished-suite-async-error.js:(LINE):1' - failureType: 'subtestsFailed' - error: '1 subtest failed' - code: 'ERR_TEST_FAILURE' - ... -# Subtest: should pass 2 -ok 2 - should pass 2 - --- - duration_ms: * - ... -1..2 -# tests 3 -# suites 1 -# pass 2 -# fail 1 -# cancelled 0 -# skipped 0 -# todo 0 -# duration_ms * diff --git a/test/parallel/test-runner-output.mjs b/test/parallel/test-runner-output.mjs index abc3d7c97b4879..6e797ae1575800 100644 --- a/test/parallel/test-runner-output.mjs +++ b/test/parallel/test-runner-output.mjs @@ -119,7 +119,6 @@ const tests = [ { name: 'test-runner/output/output_cli.js' }, { name: 'test-runner/output/name_pattern.js' }, { name: 'test-runner/output/name_pattern_with_only.js' }, - { name: 'test-runner/output/unfinished-suite-async-error.js' }, { name: 'test-runner/output/unresolved_promise.js' }, { name: 'test-runner/output/default_output.js', transform: specTransform, tty: true }, { name: 'test-runner/output/arbitrary-output.js' },