forked from nodejs/node-core-test
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR-URL: nodejs/node#43911 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> (cherry picked from commit 2e682f10b6104373fded64b0e364984b85ae2243)
- Loading branch information
Showing
4 changed files
with
47 additions
and
7 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,35 @@ | ||
// https://github.com/nodejs/node/blob/2e682f10b6104373fded64b0e364984b85ae2243/test/parallel/test-runner-misc.js | ||
|
||
'use strict' | ||
const common = require('../common') | ||
const assert = require('assert') | ||
const { spawnSync } = require('child_process') | ||
const { setTimeout } = require('timers/promises') | ||
|
||
if (process.argv[2] === 'child') { | ||
const test = require('node:test') | ||
|
||
if (process.argv[3] === 'abortSignal') { | ||
assert.throws(() => test({ signal: {} }), { | ||
code: 'ERR_INVALID_ARG_TYPE', | ||
name: 'TypeError' | ||
}) | ||
|
||
let testSignal | ||
test({ timeout: 10 }, common.mustCall(async ({ signal }) => { | ||
assert.strictEqual(signal.aborted, false) | ||
testSignal = signal | ||
await setTimeout(50) | ||
})).finally(common.mustCall(() => { | ||
test(() => assert.strictEqual(testSignal.aborted, true)) | ||
})) | ||
} else assert.fail('unreachable') | ||
} else { | ||
const child = spawnSync(process.execPath, [__filename, 'child', 'abortSignal']) | ||
const stdout = child.stdout.toString() | ||
assert.match(stdout, /^# pass 1$/m) | ||
assert.match(stdout, /^# fail 0$/m) | ||
assert.match(stdout, /^# cancelled 1$/m) | ||
assert.strictEqual(child.status, 1) | ||
assert.strictEqual(child.signal, null) | ||
} |