Skip to content

Commit ed05d9a

Browse files
addaleaxtargos
authored andcommitted
test,tools: enable running tests under workers
Enable running tests inside workers by passing `--worker` to `tools/test.py`. A number of tests are marked as skipped, or have been slightly altered to fit the different environment. PR-URL: #20876 Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Shingo Inoue <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: John-David Dalton <[email protected]> Reviewed-By: Gus Caplan <[email protected]>
1 parent 9ad42b7 commit ed05d9a

File tree

84 files changed

+274
-37
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+274
-37
lines changed

test/async-hooks/init-hooks.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22
// Flags: --expose-gc
33

4-
require('../common');
4+
const common = require('../common');
55
const assert = require('assert');
66
const async_hooks = require('async_hooks');
77
const util = require('util');
@@ -162,6 +162,10 @@ class ActivityCollector {
162162
const stub = { uid, type: 'Unknown', handleIsObject: true };
163163
this._activities.set(uid, stub);
164164
return stub;
165+
} else if (!common.isMainThread) {
166+
// Worker threads start main script execution inside of an AsyncWrap
167+
// callback, so we don't yield errors for these.
168+
return null;
165169
} else {
166170
const err = new Error(`Found a handle whose ${hook}` +
167171
' hook was invoked but not its init hook');

test/async-hooks/test-crypto-pbkdf2.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
const common = require('../common');
44
if (!common.hasCrypto)
55
common.skip('missing crypto');
6+
if (!common.isMainThread)
7+
common.skip('Worker bootstrapping works differently -> different async IDs');
68

79
const assert = require('assert');
810
const tick = require('./tick');

test/async-hooks/test-crypto-randomBytes.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
const common = require('../common');
44
if (!common.hasCrypto)
55
common.skip('missing crypto');
6+
if (!common.isMainThread)
7+
common.skip('Worker bootstrapping works differently -> different async IDs');
68

79
const assert = require('assert');
810
const tick = require('./tick');

test/async-hooks/test-emit-before-after.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ const spawnSync = require('child_process').spawnSync;
77
const async_hooks = require('internal/async_hooks');
88
const initHooks = require('./init-hooks');
99

10+
if (!common.isMainThread)
11+
common.skip('Worker bootstrapping works differently -> different async IDs');
12+
1013
switch (process.argv[2]) {
1114
case 'test_invalid_async_id':
1215
async_hooks.emitBefore(-2, 1);

test/async-hooks/test-enable-disable.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ const assert = require('assert');
8888
const tick = require('./tick');
8989
const initHooks = require('./init-hooks');
9090
const { checkInvocations } = require('./hook-checks');
91+
92+
if (!common.isMainThread)
93+
common.skip('Worker bootstrapping works differently -> different timing');
94+
9195
// Include "Unknown"s because hook2 will not be able to identify
9296
// the type of the first Immediate since it will miss its `init` invocation.
9397
const types = [ 'Immediate', 'Unknown' ];

test/async-hooks/test-fseventwrap.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
'use strict';
2-
require('../common');
2+
const common = require('../common');
33

44
const assert = require('assert');
55
const initHooks = require('./init-hooks');
66
const tick = require('./tick');
77
const { checkInvocations } = require('./hook-checks');
88
const fs = require('fs');
99

10+
if (!common.isMainThread)
11+
common.skip('Worker bootstrapping works differently -> different async IDs');
12+
1013
const hooks = initHooks();
1114

1215
hooks.enable();

test/async-hooks/test-fsreqwrap-readFile.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ const initHooks = require('./init-hooks');
77
const { checkInvocations } = require('./hook-checks');
88
const fs = require('fs');
99

10+
if (!common.isMainThread)
11+
common.skip('Worker bootstrapping works differently -> different async IDs');
12+
1013
const hooks = initHooks();
1114

1215
hooks.enable();

test/async-hooks/test-getaddrinforeqwrap.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ const initHooks = require('./init-hooks');
77
const { checkInvocations } = require('./hook-checks');
88
const dns = require('dns');
99

10+
if (!common.isMainThread)
11+
common.skip('Worker bootstrapping works differently -> different async IDs');
12+
1013
const hooks = initHooks();
1114

1215
hooks.enable();

test/async-hooks/test-getnameinforeqwrap.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ const initHooks = require('./init-hooks');
77
const { checkInvocations } = require('./hook-checks');
88
const dns = require('dns');
99

10+
if (!common.isMainThread)
11+
common.skip('Worker bootstrapping works differently -> different async IDs');
12+
1013
const hooks = initHooks();
1114

1215
hooks.enable();

test/async-hooks/test-graph.signal.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
'use strict';
22

33
const common = require('../common');
4-
if (common.isWindows) {
4+
if (common.isWindows)
55
common.skip('no signals on Windows');
6-
}
6+
if (!common.isMainThread)
7+
common.skip('No signal handling available in Workers');
78

89
const initHooks = require('./init-hooks');
910
const verifyGraph = require('./verify-graph');

0 commit comments

Comments
 (0)