Skip to content

Commit eea0eb6

Browse files
committed
CR
1 parent 2386e84 commit eea0eb6

File tree

5 files changed

+12
-10
lines changed

5 files changed

+12
-10
lines changed

Diff for: doc/api/test.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ changes:
337337
* `only` {boolean} If truthy, and the test context is configured to run
338338
`only` tests, then this test will be run. Otherwise, the test is skipped.
339339
**Default:** `false`.
340-
* `signal` {AbortSignal} allows aborting an in-progress test
340+
* `signal` {AbortSignal} Allows aborting an in-progress test
341341
* `skip` {boolean|string} If truthy, the test is skipped. If a string is
342342
provided, that string is displayed in the test results as the reason for
343343
skipping the test. **Default:** `false`.
@@ -491,7 +491,7 @@ test('top level test', (t) => {
491491
added: REPLACEME
492492
-->
493493

494-
this is an <AbortSignal> used to signal when the test has been aborted.
494+
* <AbortSignal> Can be used to abort test subtasks when the test has been aborted.
495495

496496
```js
497497
test('top level test', async (t) => {
@@ -605,7 +605,7 @@ exposed as part of the API.
605605
added: REPLACEME
606606
-->
607607

608-
this is an <AbortSignal> used to signal when the test has been aborted.
608+
* <AbortSignal> Can be used to abort test subtasks when the test has been aborted.
609609

610610
[TAP]: https://testanything.org/
611611
[`--test-only`]: cli.md#--test-only

Diff for: lib/internal/main/test_runner.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const {
33
ArrayFrom,
44
ArrayPrototypeFilter,
55
ArrayPrototypeIncludes,
6+
ArrayPrototypeJoin,
67
ArrayPrototypePush,
78
ArrayPrototypeSlice,
89
ArrayPrototypeSort,
@@ -124,8 +125,8 @@ function runTestFile(path) {
124125
err = new ERR_TEST_FAILURE('test failed', kSubtestsFailed);
125126
err.exitCode = code;
126127
err.signal = signal;
127-
err.stdout = stdout.join('');
128-
err.stderr = stderr.join('');
128+
err.stdout = ArrayPrototypeJoin(stdout, '');
129+
err.stderr = ArrayPrototypeJoin(stderr, '');
129130
// The stack will not be useful since the failures came from tests
130131
// in a child process.
131132
err.stack = undefined;

Diff for: lib/internal/test_runner/test.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ const {
55
ArrayPrototypeUnshift,
66
FunctionPrototype,
77
Number,
8+
PromisePrototypeThen,
9+
PromiseResolve,
810
ReflectApply,
911
SafeMap,
1012
SafePromiseAll,
1113
SafePromiseRace,
12-
PromiseResolve,
1314
Symbol,
1415
} = primordials;
1516
const { AsyncResource } = require('async_hooks');
@@ -55,7 +56,7 @@ function stopTest(timeout, signal) {
5556
if (timeout === kDefaultTimeout) {
5657
return once(signal, 'abort');
5758
}
58-
return setTimeout(timeout, null, { ref: false, signal }).then(() => {
59+
return PromisePrototypeThen(setTimeout(timeout, null, { ref: false, signal }), () => {
5960
throw new ERR_TEST_FAILURE(
6061
`test timed out after ${timeout}ms`,
6162
kTestTimeoutFailure

Diff for: test/message/test_runner_abort.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ test('promise timeout signal', { signal: AbortSignal.timeout(1) }, async (t) =>
2020
});
2121

2222
test('promise abort signal', { signal: AbortSignal.abort() }, async (t) => {
23-
t.test('should not appear', () => {});
23+
await t.test('should not appear', () => {});
2424
});
2525

2626
test('callback timeout signal', { signal: AbortSignal.timeout(1) }, (t, done) => {
@@ -38,7 +38,7 @@ test('callback timeout signal', { signal: AbortSignal.timeout(1) }, (t, done) =>
3838
});
3939

4040
test('callback abort signal', { signal: AbortSignal.abort() }, (t, done) => {
41-
t.test('should not appear', () => {});
41+
t.test('should not appear', done);
4242
});
4343

4444
// AbortSignal.timeout(1) doesn't prevent process from closing

Diff for: test/message/test_runner_abort.out

+1-1
Original file line numberDiff line numberDiff line change
@@ -246,4 +246,4 @@ not ok 4 - callback abort signal
246246
# cancelled 4
247247
# skipped 0
248248
# todo 0
249-
# duration_ms *
249+
# duration_ms *

0 commit comments

Comments
 (0)