GeezerVison is showing github.com — test: fix suite signal · nodejs/node@a80dd3a
File treeExpand file treeCollapse file tree Open diff view settings fixtures/test-runner/output
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: lib/internal/test_runner/test.js +4-1Lines changed: 4 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | 'use strict'; | 2 | 2 | const { | 3 | 3 | ArrayPrototypePush, | | 4 | + ArrayPrototypePushApply, | 4 | 5 | ArrayPrototypeReduce, | 5 | 6 | ArrayPrototypeShift, | 6 | 7 | ArrayPrototypeSlice, | @@ -760,8 +761,10 @@ class Suite extends Test { | 760 | 761 |
| 761 | 762 | try { | 762 | 763 | const { ctx, args } = this.getRunArgs(); | | 764 | + const runArgs = [this.fn, ctx]; | | 765 | + ArrayPrototypePushApply(runArgs, args); | 763 | 766 | this.buildSuite = PromisePrototypeThen( | 764 | | - PromiseResolve(this.runInAsyncScope(this.fn, ctx, args)), | | 767 | + PromiseResolve(ReflectApply(this.runInAsyncScope, this, runArgs)), | 765 | 768 | undefined, | 766 | 769 | (err) => { | 767 | 770 | this.fail(new ERR_TEST_FAILURE(err, kTestCodeFailure)); | |
Collapse file Copy file name to clipboardExpand all lines: test/fixtures/test-runner/output/abort_suite.snapshot +45-9Lines changed: 45 additions & 9 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -40,25 +40,61 @@ TAP version 13 | 40 | 40 | not ok 7 - not ok 3 | 41 | 41 | --- | 42 | 42 | duration_ms: ZERO | 43 | | - failureType: 'cancelledByParent' | 44 | | - error: 'test did not finish before its parent and was cancelled' | 45 | | - code: 'ERR_TEST_FAILURE' | | 43 | + failureType: 'testAborted' | | 44 | + error: 'This operation was aborted' | | 45 | + code: 20 | | 46 | + name: 'AbortError' | | 47 | + stack: |- | | 48 | + * | | 49 | + * | | 50 | + * | | 51 | + * | | 52 | + * | | 53 | + * | | 54 | + * | | 55 | + * | | 56 | + * | | 57 | + * | 46 | 58 | ... | 47 | 59 | # Subtest: not ok 4 | 48 | 60 | not ok 8 - not ok 4 | 49 | 61 | --- | 50 | 62 | duration_ms: ZERO | 51 | | - failureType: 'cancelledByParent' | 52 | | - error: 'test did not finish before its parent and was cancelled' | 53 | | - code: 'ERR_TEST_FAILURE' | | 63 | + failureType: 'testAborted' | | 64 | + error: 'This operation was aborted' | | 65 | + code: 20 | | 66 | + name: 'AbortError' | | 67 | + stack: |- | | 68 | + * | | 69 | + * | | 70 | + * | | 71 | + * | | 72 | + * | | 73 | + * | | 74 | + * | | 75 | + * | | 76 | + * | | 77 | + * | 54 | 78 | ... | 55 | 79 | # Subtest: not ok 5 | 56 | 80 | not ok 9 - not ok 5 | 57 | 81 | --- | 58 | 82 | duration_ms: ZERO | 59 | | - failureType: 'cancelledByParent' | 60 | | - error: 'test did not finish before its parent and was cancelled' | 61 | | - code: 'ERR_TEST_FAILURE' | | 83 | + failureType: 'testAborted' | | 84 | + error: 'This operation was aborted' | | 85 | + code: 20 | | 86 | + name: 'AbortError' | | 87 | + stack: |- | | 88 | + * | | 89 | + * | | 90 | + * | | 91 | + * | | 92 | + * | | 93 | + * | | 94 | + * | | 95 | + * | | 96 | + * | | 97 | + * | 62 | 98 | ... | 63 | 99 | 1..9 | 64 | 100 | not ok 1 - describe timeout signal | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-runner-misc.js +9-1Lines changed: 9 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -21,11 +21,19 @@ if (process.argv[2] === 'child') { | 21 | 21 | })).finally(common.mustCall(() => { | 22 | 22 | test(() => assert.strictEqual(testSignal.aborted, true)); | 23 | 23 | })); | | 24 | + | | 25 | + // TODO(benjamingr) add more tests to describe + AbortSignal | | 26 | + // this just tests the parameter is passed | | 27 | + test.describe('Abort Signal in describe', common.mustCall(({ signal }) => { | | 28 | + test.it('Supports AbortSignal', () => { | | 29 | + assert.strictEqual(signal.aborted, false); | | 30 | + }); | | 31 | + })); | 24 | 32 | } else assert.fail('unreachable'); | 25 | 33 | } else { | 26 | 34 | const child = spawnSync(process.execPath, [__filename, 'child', 'abortSignal']); | 27 | 35 | const stdout = child.stdout.toString(); | 28 | | - assert.match(stdout, /^# pass 1$/m); | | 36 | + assert.match(stdout, /^# pass 2$/m); | 29 | 37 | assert.match(stdout, /^# fail 0$/m); | 30 | 38 | assert.match(stdout, /^# cancelled 1$/m); | 31 | 39 | assert.strictEqual(child.status, 1); | |
|