-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test_runner: avoid swallowing of asynchronously thrown errors
Fixes: #44612 PR-URL: #45264 Backport-PR-URL: #46839 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
- Loading branch information
1 parent
c04808d
commit 5fdf374
Showing
6 changed files
with
45 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import test from 'node:test'; | ||
|
||
test('extraneous async activity test', () => { | ||
setImmediate(() => { throw new Error(); }); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import test from 'node:test'; | ||
|
||
test('extraneous async activity test', () => { | ||
setTimeout(() => { throw new Error(); }, 100); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
'use strict'; | ||
require('../common'); | ||
const fixtures = require('../common/fixtures'); | ||
const assert = require('assert'); | ||
const { spawnSync } = require('child_process'); | ||
|
||
{ | ||
const child = spawnSync(process.execPath, [ | ||
'--test', | ||
fixtures.path('test-runner', 'extraneous_set_immediate_async.mjs'), | ||
]); | ||
const stdout = child.stdout.toString(); | ||
assert.match(stdout, /^# pass 0$/m); | ||
assert.match(stdout, /^# fail 1$/m); | ||
assert.match(stdout, /^# cancelled 0$/m); | ||
assert.strictEqual(child.status, 1); | ||
assert.strictEqual(child.signal, null); | ||
} | ||
|
||
{ | ||
const child = spawnSync(process.execPath, [ | ||
'--test', | ||
fixtures.path('test-runner', 'extraneous_set_timeout_async.mjs'), | ||
]); | ||
const stdout = child.stdout.toString(); | ||
assert.match(stdout, /^# pass 0$/m); | ||
assert.match(stdout, /^# fail 1$/m); | ||
assert.match(stdout, /^# cancelled 0$/m); | ||
assert.strictEqual(child.status, 1); | ||
assert.strictEqual(child.signal, null); | ||
} |