summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/async-hooks/init-hooks.js6
-rw-r--r--test/async-hooks/test-crypto-pbkdf2.js2
-rw-r--r--test/async-hooks/test-crypto-randomBytes.js2
-rw-r--r--test/async-hooks/test-emit-before-after.js3
-rw-r--r--test/async-hooks/test-enable-disable.js4
-rw-r--r--test/async-hooks/test-fseventwrap.js5
-rw-r--r--test/async-hooks/test-fsreqwrap-readFile.js3
-rw-r--r--test/async-hooks/test-getaddrinforeqwrap.js3
-rw-r--r--test/async-hooks/test-getnameinforeqwrap.js3
-rw-r--r--test/async-hooks/test-graph.signal.js5
-rw-r--r--test/async-hooks/test-no-assert-when-disabled.js5
-rw-r--r--test/async-hooks/test-pipewrap.js3
-rw-r--r--test/async-hooks/test-promise.chain-promise-before-init-hooks.js4
-rw-r--r--test/async-hooks/test-promise.js3
-rw-r--r--test/async-hooks/test-signalwrap.js2
-rw-r--r--test/async-hooks/test-statwatcher.js5
-rw-r--r--test/common/index.js12
-rw-r--r--test/known_issues/test-stdin-is-always-net.socket.js2
-rw-r--r--test/parallel/test-async-hooks-disable-during-promise.js3
-rw-r--r--test/parallel/test-async-hooks-disable-gc-tracking.js2
-rw-r--r--test/parallel/test-async-hooks-enable-during-promise.js4
-rw-r--r--test/parallel/test-async-hooks-prevent-double-destroy.js2
-rw-r--r--test/parallel/test-async-hooks-promise-triggerid.js3
-rw-r--r--test/parallel/test-async-hooks-promise.js3
-rw-r--r--test/parallel/test-async-hooks-top-level-clearimmediate.js3
-rw-r--r--test/parallel/test-async-wrap-promise-after-enabled.js3
-rw-r--r--test/parallel/test-child-process-custom-fds.js3
-rw-r--r--test/parallel/test-child-process-http-socket-leak.js3
-rw-r--r--test/parallel/test-child-process-validate-stdio.js6
-rw-r--r--test/parallel/test-cli-eval.js3
-rw-r--r--test/parallel/test-cli-node-options-disallowed.js2
-rw-r--r--test/parallel/test-cli-node-options.js2
-rw-r--r--test/parallel/test-cluster-net-listen-relative-path.js2
-rw-r--r--test/parallel/test-console.js7
-rw-r--r--test/parallel/test-cwd-enoent-preload.js2
-rw-r--r--test/parallel/test-cwd-enoent-repl.js2
-rw-r--r--test/parallel/test-cwd-enoent.js2
-rw-r--r--test/parallel/test-debug-args.js5
-rw-r--r--test/parallel/test-fs-realpath.js3
-rw-r--r--test/parallel/test-fs-write-file-sync.js3
-rw-r--r--test/parallel/test-module-cjs-helpers.js4
-rw-r--r--test/parallel/test-preload.js2
-rw-r--r--test/parallel/test-process-chdir-errormessage.js6
-rw-r--r--test/parallel/test-process-chdir.js3
-rw-r--r--test/parallel/test-process-euid-egid.js8
-rw-r--r--test/parallel/test-process-exit-handler.js7
-rw-r--r--test/parallel/test-process-fatal-exception-tick.js3
-rw-r--r--test/parallel/test-process-uid-gid.js10
-rw-r--r--test/parallel/test-process-umask-mask.js3
-rw-r--r--test/parallel/test-process-umask.js2
-rw-r--r--test/parallel/test-repl-require.js3
-rw-r--r--test/parallel/test-repl-sigint-nested-eval.js2
-rw-r--r--test/parallel/test-repl-sigint.js2
-rw-r--r--test/parallel/test-repl-tab-complete.js3
-rw-r--r--test/parallel/test-require-symlink.js2
-rw-r--r--test/parallel/test-setproctitle.js2
-rw-r--r--test/parallel/test-signal-args.js5
-rw-r--r--test/parallel/test-signal-handler.js2
-rw-r--r--test/parallel/test-stdio-pipe-access.js4
-rw-r--r--test/parallel/test-stdio-pipe-redirect.js4
-rw-r--r--test/parallel/test-timers-immediate-unref-nested-once.js9
-rw-r--r--test/parallel/test-timers-immediate-unref-simple.js5
-rw-r--r--test/parallel/test-trace-events-all.js3
-rw-r--r--test/parallel/test-trace-events-api.js2
-rw-r--r--test/parallel/test-trace-events-async-hooks.js3
-rw-r--r--test/parallel/test-trace-events-binding.js3
-rw-r--r--test/parallel/test-trace-events-bootstrap.js3
-rw-r--r--test/parallel/test-trace-events-category-used.js3
-rw-r--r--test/parallel/test-trace-events-file-pattern.js3
-rw-r--r--test/parallel/test-trace-events-fs-sync.js3
-rw-r--r--test/parallel/test-trace-events-metadata.js3
-rw-r--r--test/parallel/test-trace-events-none.js3
-rw-r--r--test/parallel/test-trace-events-perf.js3
-rw-r--r--test/parallel/test-trace-events-process-exit.js3
-rw-r--r--test/parallel/test-trace-events-v8.js3
-rw-r--r--test/parallel/test-trace-events-vm.js3
-rw-r--r--test/sequential/test-async-wrap-getasyncid.js5
-rw-r--r--test/sequential/test-buffer-creation-regression.js1
-rw-r--r--test/sequential/test-fs-watch.js3
-rw-r--r--test/sequential/test-init.js3
-rw-r--r--test/sequential/test-inspector-overwrite-config.js4
-rw-r--r--test/sequential/test-performance.js3
-rw-r--r--tools/run-worker.js11
-rwxr-xr-xtools/test.py7
84 files changed, 273 insertions, 36 deletions
diff --git a/test/async-hooks/init-hooks.js b/test/async-hooks/init-hooks.js
index 509f443b29..14969d8e75 100644
--- a/test/async-hooks/init-hooks.js
+++ b/test/async-hooks/init-hooks.js
@@ -1,7 +1,7 @@
'use strict';
// Flags: --expose-gc
-require('../common');
+const common = require('../common');
const assert = require('assert');
const async_hooks = require('async_hooks');
const util = require('util');
@@ -162,6 +162,10 @@ class ActivityCollector {
const stub = { uid, type: 'Unknown', handleIsObject: true };
this._activities.set(uid, stub);
return stub;
+ } else if (!common.isMainThread) {
+ // Worker threads start main script execution inside of an AsyncWrap
+ // callback, so we don't yield errors for these.
+ return null;
} else {
const err = new Error(`Found a handle whose ${hook}` +
' hook was invoked but not its init hook');
diff --git a/test/async-hooks/test-crypto-pbkdf2.js b/test/async-hooks/test-crypto-pbkdf2.js
index 2a0b44db8c..ed7270d191 100644
--- a/test/async-hooks/test-crypto-pbkdf2.js
+++ b/test/async-hooks/test-crypto-pbkdf2.js
@@ -3,6 +3,8 @@
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
+if (!common.isMainThread)
+ common.skip('Worker bootstrapping works differently -> different async IDs');
const assert = require('assert');
const tick = require('./tick');
diff --git a/test/async-hooks/test-crypto-randomBytes.js b/test/async-hooks/test-crypto-randomBytes.js
index 76f8f77595..67f5221a5e 100644
--- a/test/async-hooks/test-crypto-randomBytes.js
+++ b/test/async-hooks/test-crypto-randomBytes.js
@@ -3,6 +3,8 @@
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
+if (!common.isMainThread)
+ common.skip('Worker bootstrapping works differently -> different async IDs');
const assert = require('assert');
const tick = require('./tick');
diff --git a/test/async-hooks/test-emit-before-after.js b/test/async-hooks/test-emit-before-after.js
index e7744eb4b7..6a9ceaeefb 100644
--- a/test/async-hooks/test-emit-before-after.js
+++ b/test/async-hooks/test-emit-before-after.js
@@ -7,6 +7,9 @@ const spawnSync = require('child_process').spawnSync;
const async_hooks = require('internal/async_hooks');
const initHooks = require('./init-hooks');
+if (!common.isMainThread)
+ common.skip('Worker bootstrapping works differently -> different async IDs');
+
switch (process.argv[2]) {
case 'test_invalid_async_id':
async_hooks.emitBefore(-2, 1);
diff --git a/test/async-hooks/test-enable-disable.js b/test/async-hooks/test-enable-disable.js
index 27e13efdd8..df093da608 100644
--- a/test/async-hooks/test-enable-disable.js
+++ b/test/async-hooks/test-enable-disable.js
@@ -88,6 +88,10 @@ const assert = require('assert');
const tick = require('./tick');
const initHooks = require('./init-hooks');
const { checkInvocations } = require('./hook-checks');
+
+if (!common.isMainThread)
+ common.skip('Worker bootstrapping works differently -> different timing');
+
// Include "Unknown"s because hook2 will not be able to identify
// the type of the first Immediate since it will miss its `init` invocation.
const types = [ 'Immediate', 'Unknown' ];
diff --git a/test/async-hooks/test-fseventwrap.js b/test/async-hooks/test-fseventwrap.js
index 2d9e697501..56ada05b76 100644
--- a/test/async-hooks/test-fseventwrap.js
+++ b/test/async-hooks/test-fseventwrap.js
@@ -1,5 +1,5 @@
'use strict';
-require('../common');
+const common = require('../common');
const assert = require('assert');
const initHooks = require('./init-hooks');
@@ -7,6 +7,9 @@ const tick = require('./tick');
const { checkInvocations } = require('./hook-checks');
const fs = require('fs');
+if (!common.isMainThread)
+ common.skip('Worker bootstrapping works differently -> different async IDs');
+
const hooks = initHooks();
hooks.enable();
diff --git a/test/async-hooks/test-fsreqwrap-readFile.js b/test/async-hooks/test-fsreqwrap-readFile.js
index a40b9a35fd..064cd80a48 100644
--- a/test/async-hooks/test-fsreqwrap-readFile.js
+++ b/test/async-hooks/test-fsreqwrap-readFile.js
@@ -7,6 +7,9 @@ const initHooks = require('./init-hooks');
const { checkInvocations } = require('./hook-checks');
const fs = require('fs');
+if (!common.isMainThread)
+ common.skip('Worker bootstrapping works differently -> different async IDs');
+
const hooks = initHooks();
hooks.enable();
diff --git a/test/async-hooks/test-getaddrinforeqwrap.js b/test/async-hooks/test-getaddrinforeqwrap.js
index 787ea26fd3..298c4931cc 100644
--- a/test/async-hooks/test-getaddrinforeqwrap.js
+++ b/test/async-hooks/test-getaddrinforeqwrap.js
@@ -7,6 +7,9 @@ const initHooks = require('./init-hooks');
const { checkInvocations } = require('./hook-checks');
const dns = require('dns');
+if (!common.isMainThread)
+ common.skip('Worker bootstrapping works differently -> different async IDs');
+
const hooks = initHooks();
hooks.enable();
diff --git a/test/async-hooks/test-getnameinforeqwrap.js b/test/async-hooks/test-getnameinforeqwrap.js
index 071462dddc..a32814e5b5 100644
--- a/test/async-hooks/test-getnameinforeqwrap.js
+++ b/test/async-hooks/test-getnameinforeqwrap.js
@@ -7,6 +7,9 @@ const initHooks = require('./init-hooks');
const { checkInvocations } = require('./hook-checks');
const dns = require('dns');
+if (!common.isMainThread)
+ common.skip('Worker bootstrapping works differently -> different async IDs');
+
const hooks = initHooks();
hooks.enable();
diff --git a/test/async-hooks/test-graph.signal.js b/test/async-hooks/test-graph.signal.js
index 770fe00da4..4c5b857fc2 100644
--- a/test/async-hooks/test-graph.signal.js
+++ b/test/async-hooks/test-graph.signal.js
@@ -1,9 +1,10 @@
'use strict';
const common = require('../common');
-if (common.isWindows) {
+if (common.isWindows)
common.skip('no signals on Windows');
-}
+if (!common.isMainThread)
+ common.skip('No signal handling available in Workers');
const initHooks = require('./init-hooks');
const verifyGraph = require('./verify-graph');
diff --git a/test/async-hooks/test-no-assert-when-disabled.js b/test/async-hooks/test-no-assert-when-disabled.js
index 12742bd5d4..70114d1e11 100644
--- a/test/async-hooks/test-no-assert-when-disabled.js
+++ b/test/async-hooks/test-no-assert-when-disabled.js
@@ -1,6 +1,9 @@
'use strict';
// Flags: --no-force-async-hooks-checks --expose-internals
-require('../common');
+const common = require('../common');
+
+if (!common.isMainThread)
+ common.skip('Workers don\'t inherit per-env state like the check flag');
const async_hooks = require('internal/async_hooks');
diff --git a/test/async-hooks/test-pipewrap.js b/test/async-hooks/test-pipewrap.js
index 066458841f..f2b5bf9852 100644
--- a/test/async-hooks/test-pipewrap.js
+++ b/test/async-hooks/test-pipewrap.js
@@ -10,6 +10,9 @@ const initHooks = require('./init-hooks');
const { checkInvocations } = require('./hook-checks');
const spawn = require('child_process').spawn;
+if (!common.isMainThread)
+ common.skip('Worker bootstrapping works differently -> different async IDs');
+
const hooks = initHooks();
hooks.enable();
diff --git a/test/async-hooks/test-promise.chain-promise-before-init-hooks.js b/test/async-hooks/test-promise.chain-promise-before-init-hooks.js
index 00b53300c4..873fd272cf 100644
--- a/test/async-hooks/test-promise.chain-promise-before-init-hooks.js
+++ b/test/async-hooks/test-promise.chain-promise-before-init-hooks.js
@@ -4,6 +4,10 @@ const common = require('../common');
const assert = require('assert');
const initHooks = require('./init-hooks');
const { checkInvocations } = require('./hook-checks');
+
+if (!common.isMainThread)
+ common.skip('Worker bootstrapping works differently -> different async IDs');
+
common.crashOnUnhandledRejection();
const p = new Promise(common.mustCall(function executor(resolve, reject) {
diff --git a/test/async-hooks/test-promise.js b/test/async-hooks/test-promise.js
index 2ee6496213..d3070b7cbd 100644
--- a/test/async-hooks/test-promise.js
+++ b/test/async-hooks/test-promise.js
@@ -6,6 +6,9 @@ const assert = require('assert');
const initHooks = require('./init-hooks');
const { checkInvocations } = require('./hook-checks');
+if (!common.isMainThread)
+ common.skip('Worker bootstrapping works differently -> different async IDs');
+
common.crashOnUnhandledRejection();
const hooks = initHooks();
diff --git a/test/async-hooks/test-signalwrap.js b/test/async-hooks/test-signalwrap.js
index ae4f41c6a4..c94d763450 100644
--- a/test/async-hooks/test-signalwrap.js
+++ b/test/async-hooks/test-signalwrap.js
@@ -3,6 +3,8 @@ const common = require('../common');
if (common.isWindows)
common.skip('no signals in Windows');
+if (!common.isMainThread)
+ common.skip('No signal handling available in Workers');
const assert = require('assert');
const initHooks = require('./init-hooks');
diff --git a/test/async-hooks/test-statwatcher.js b/test/async-hooks/test-statwatcher.js
index 52d1463064..8085ebf51b 100644
--- a/test/async-hooks/test-statwatcher.js
+++ b/test/async-hooks/test-statwatcher.js
@@ -1,12 +1,15 @@
'use strict';
-require('../common');
+const common = require('../common');
const commonPath = require.resolve('../common');
const assert = require('assert');
const initHooks = require('./init-hooks');
const { checkInvocations } = require('./hook-checks');
const fs = require('fs');
+if (!common.isMainThread)
+ common.skip('Worker bootstrapping works differently -> different async IDs');
+
const hooks = initHooks();
hooks.enable();
diff --git a/test/common/index.js b/test/common/index.js
index f76e1cd38c..f9cf6ec663 100644
--- a/test/common/index.js
+++ b/test/common/index.js
@@ -46,6 +46,14 @@ Object.defineProperty(exports, 'PORT', {
enumerable: true
});
+exports.isMainThread = (() => {
+ try {
+ return require('worker').isMainThread;
+ } catch {
+ // Worker module not enabled → only a single main thread exists.
+ return true;
+ }
+})();
exports.isWindows = process.platform === 'win32';
exports.isWOW64 = exports.isWindows &&
@@ -746,6 +754,10 @@ exports.skipIfInspectorDisabled = function skipIfInspectorDisabled() {
if (process.config.variables.v8_enable_inspector === 0) {
exports.skip('V8 inspector is disabled');
}
+ if (!exports.isMainThread) {
+ // TODO(addaleax): Fix me.
+ exports.skip('V8 inspector is not available in Workers');
+ }
};
exports.skipIf32Bits = function skipIf32Bits() {
diff --git a/test/known_issues/test-stdin-is-always-net.socket.js b/test/known_issues/test-stdin-is-always-net.socket.js
index 9a4c524c4a..8db33bd7a5 100644
--- a/test/known_issues/test-stdin-is-always-net.socket.js
+++ b/test/known_issues/test-stdin-is-always-net.socket.js
@@ -19,5 +19,5 @@ const proc = spawn(
// To double-check this test, set stdio to 'pipe' and uncomment the line below.
// proc.stderr.pipe(process.stderr);
proc.on('exit', common.mustCall(function(exitCode) {
- process.exitCode = exitCode;
+ assert.strictEqual(exitCode, 0);
}));
diff --git a/test/parallel/test-async-hooks-disable-during-promise.js b/test/parallel/test-async-hooks-disable-during-promise.js
index d656666129..ace9bca679 100644
--- a/test/parallel/test-async-hooks-disable-during-promise.js
+++ b/test/parallel/test-async-hooks-disable-during-promise.js
@@ -3,6 +3,9 @@ const common = require('../common');
const async_hooks = require('async_hooks');
common.crashOnUnhandledRejection();
+if (!common.isMainThread)
+ common.skip('Worker bootstrapping works differently -> different AsyncWraps');
+
const hook = async_hooks.createHook({
init: common.mustCall(2),
before: common.mustCall(1),
diff --git a/test/parallel/test-async-hooks-disable-gc-tracking.js b/test/parallel/test-async-hooks-disable-gc-tracking.js
index a34739a9bb..84c5043aad 100644
--- a/test/parallel/test-async-hooks-disable-gc-tracking.js
+++ b/test/parallel/test-async-hooks-disable-gc-tracking.js
@@ -8,7 +8,7 @@ const common = require('../common');
const async_hooks = require('async_hooks');
const hook = async_hooks.createHook({
- destroy: common.mustCall(1) // only 1 immediate is destroyed
+ destroy: common.mustCallAtLeast(1) // only 1 immediate is destroyed
}).enable();
new async_hooks.AsyncResource('foobar', { requireManualDestroy: true });
diff --git a/test/parallel/test-async-hooks-enable-during-promise.js b/test/parallel/test-async-hooks-enable-during-promise.js
index 17b3c884bb..29d25de980 100644
--- a/test/parallel/test-async-hooks-enable-during-promise.js
+++ b/test/parallel/test-async-hooks-enable-during-promise.js
@@ -7,8 +7,8 @@ common.crashOnUnhandledRejection();
Promise.resolve(1).then(common.mustCall(() => {
async_hooks.createHook({
init: common.mustCall(),
- before: common.mustCall(),
- after: common.mustCall(2)
+ before: common.mustCallAtLeast(),
+ after: common.mustCallAtLeast(2)
}).enable();
process.nextTick(common.mustCall());
diff --git a/test/parallel/test-async-hooks-prevent-double-destroy.js b/test/parallel/test-async-hooks-prevent-double-destroy.js
index 5cd9c5e9a0..689dc399f9 100644
--- a/test/parallel/test-async-hooks-prevent-double-destroy.js
+++ b/test/parallel/test-async-hooks-prevent-double-destroy.js
@@ -8,7 +8,7 @@ const common = require('../common');
const async_hooks = require('async_hooks');
const hook = async_hooks.createHook({
- destroy: common.mustCall(2) // 1 immediate + manual destroy
+ destroy: common.mustCallAtLeast(2) // 1 immediate + manual destroy
}).enable();
{
diff --git a/test/parallel/test-async-hooks-promise-triggerid.js b/test/parallel/test-async-hooks-promise-triggerid.js
index 7afd005855..507a8a4ada 100644
--- a/test/parallel/test-async-hooks-promise-triggerid.js
+++ b/test/parallel/test-async-hooks-promise-triggerid.js
@@ -3,6 +3,9 @@ const common = require('../common');
const assert = require('assert');
const async_hooks = require('async_hooks');
+if (!common.isMainThread)
+ common.skip('Worker bootstrapping works differently -> different async IDs');
+
common.crashOnUnhandledRejection();
const promiseAsyncIds = [];
diff --git a/test/parallel/test-async-hooks-promise.js b/test/parallel/test-async-hooks-promise.js
index 4b36f6026b..be1509c7fc 100644
--- a/test/parallel/test-async-hooks-promise.js
+++ b/test/parallel/test-async-hooks-promise.js
@@ -3,6 +3,9 @@ const common = require('../common');
const assert = require('assert');
const async_hooks = require('async_hooks');
+if (!common.isMainThread)
+ common.skip('Worker bootstrapping works differently -> different async IDs');
+
const initCalls = [];
const resolveCalls = [];
diff --git a/test/parallel/test-async-hooks-top-level-clearimmediate.js b/test/parallel/test-async-hooks-top-level-clearimmediate.js
index e7a5d8f560..cc5fcf48eb 100644
--- a/test/parallel/test-async-hooks-top-level-clearimmediate.js
+++ b/test/parallel/test-async-hooks-top-level-clearimmediate.js
@@ -6,6 +6,9 @@ const common = require('../common');
const assert = require('assert');
const async_hooks = require('async_hooks');
+if (!common.isMainThread)
+ common.skip('Worker bootstrapping works differently -> different async IDs');
+
let seenId, seenResource;
async_hooks.createHook({
diff --git a/test/parallel/test-async-wrap-promise-after-enabled.js b/test/parallel/test-async-wrap-promise-after-enabled.js
index 9535c080f2..5df8f13c00 100644
--- a/test/parallel/test-async-wrap-promise-after-enabled.js
+++ b/test/parallel/test-async-wrap-promise-after-enabled.js
@@ -5,6 +5,9 @@
const common = require('../common');
const assert = require('assert');
+if (!common.isMainThread)
+ common.skip('Worker bootstrapping works differently -> different timing');
+
const async_hooks = require('async_hooks');
const seenEvents = [];
diff --git a/test/parallel/test-child-process-custom-fds.js b/test/parallel/test-child-process-custom-fds.js
index fbfc8776a3..c314656476 100644
--- a/test/parallel/test-child-process-custom-fds.js
+++ b/test/parallel/test-child-process-custom-fds.js
@@ -5,6 +5,9 @@ const assert = require('assert');
const internalCp = require('internal/child_process');
const oldSpawnSync = internalCp.spawnSync;
+if (!common.isMainThread)
+ common.skip('stdio is not associated with file descriptors in Workers');
+
// Verify that customFds is used if stdio is not provided.
{
const msg = 'child_process: options.customFds option is deprecated. ' +
diff --git a/test/parallel/test-child-process-http-socket-leak.js b/test/parallel/test-child-process-http-socket-leak.js
index 30d8601b84..553a327753 100644
--- a/test/parallel/test-child-process-http-socket-leak.js
+++ b/test/parallel/test-child-process-http-socket-leak.js
@@ -6,7 +6,6 @@ const common = require('../common');
const assert = require('assert');
const { fork } = require('child_process');
const http = require('http');
-const { kTimeout } = require('internal/timers');
if (process.argv[2] === 'child') {
process.once('message', (req, socket) => {
@@ -19,6 +18,8 @@ if (process.argv[2] === 'child') {
return;
}
+const { kTimeout } = require('internal/timers');
+
let child;
let socket;
diff --git a/test/parallel/test-child-process-validate-stdio.js b/test/parallel/test-child-process-validate-stdio.js
index 4c4f137110..26e4c29767 100644
--- a/test/parallel/test-child-process-validate-stdio.js
+++ b/test/parallel/test-child-process-validate-stdio.js
@@ -30,7 +30,8 @@ common.expectsError(() => _validateStdio(stdio2, true),
{ code: 'ERR_IPC_SYNC_FORK', type: Error }
);
-{
+
+if (common.isMainThread) {
const stdio3 = [process.stdin, process.stdout, process.stderr];
const result = _validateStdio(stdio3, false);
assert.deepStrictEqual(result, {
@@ -42,4 +43,7 @@ common.expectsError(() => _validateStdio(stdio2, true),
ipc: undefined,
ipcFd: undefined
});
+} else {
+ common.printSkipMessage(
+ 'stdio is not associated with file descriptors in Workers');
}
diff --git a/test/parallel/test-cli-eval.js b/test/parallel/test-cli-eval.js
index 201d5a6a49..7a2c7a82aa 100644
--- a/test/parallel/test-cli-eval.js
+++ b/test/parallel/test-cli-eval.js
@@ -34,6 +34,9 @@ const path = require('path');
const fixtures = require('../common/fixtures');
const nodejs = `"${process.execPath}"`;
+if (!common.isMainThread)
+ common.skip('process.chdir is not available in Workers');
+
if (process.argv.length > 2) {
console.log(process.argv.slice(2).join(' '));
process.exit(0);
diff --git a/test/parallel/test-cli-node-options-disallowed.js b/test/parallel/test-cli-node-options-disallowed.js
index e4ae2d1aea..0351f83c52 100644
--- a/test/parallel/test-cli-node-options-disallowed.js
+++ b/test/parallel/test-cli-node-options-disallowed.js
@@ -2,6 +2,8 @@
const common = require('../common');
if (process.config.variables.node_without_node_options)
common.skip('missing NODE_OPTIONS support');
+if (!common.isMainThread)
+ common.skip('process.chdir is not available in Workers');
// Test options specified by env variable.
diff --git a/test/parallel/test-cli-node-options.js b/test/parallel/test-cli-node-options.js
index 2383935f4b..d851f225fc 100644
--- a/test/parallel/test-cli-node-options.js
+++ b/test/parallel/test-cli-node-options.js
@@ -2,6 +2,8 @@
const common = require('../common');
if (process.config.variables.node_without_node_options)
common.skip('missing NODE_OPTIONS support');
+if (!common.isMainThread)
+ common.skip('process.chdir is not available in Workers');
// Test options specified by env variable.
diff --git a/test/parallel/test-cluster-net-listen-relative-path.js b/test/parallel/test-cluster-net-listen-relative-path.js
index ce9ead9e2e..7e61cf83da 100644
--- a/test/parallel/test-cluster-net-listen-relative-path.js
+++ b/test/parallel/test-cluster-net-listen-relative-path.js
@@ -11,6 +11,8 @@ const tmpdir = require('../common/tmpdir');
if (common.isWindows)
common.skip('On Windows named pipes live in their own ' +
'filesystem and don\'t have a ~100 byte limit');
+if (!common.isMainThread)
+ common.skip('process.chdir is not available in Workers');
// Choose a socket name such that the absolute path would exceed 100 bytes.
const socketDir = './unix-socket-dir';
diff --git a/test/parallel/test-console.js b/test/parallel/test-console.js
index 9a0fa778c1..9e2e28b04e 100644
--- a/test/parallel/test-console.js
+++ b/test/parallel/test-console.js
@@ -27,9 +27,10 @@ const util = require('util');
assert.ok(process.stdout.writable);
assert.ok(process.stderr.writable);
// Support legacy API
-assert.strictEqual(typeof process.stdout.fd, 'number');
-assert.strictEqual(typeof process.stderr.fd, 'number');
-
+if (common.isMainThread) {
+ assert.strictEqual(typeof process.stdout.fd, 'number');
+ assert.strictEqual(typeof process.stderr.fd, 'number');
+}
process.once('warning', common.mustCall((warning) => {
assert(/no such label/.test(warning.message));
}));
diff --git a/test/parallel/test-cwd-enoent-preload.js b/test/parallel/test-cwd-enoent-preload.js
index b83ff6ff88..2077d9c147 100644
--- a/test/parallel/test-cwd-enoent-preload.js
+++ b/test/parallel/test-cwd-enoent-preload.js
@@ -3,6 +3,8 @@ const common = require('../common');
// Fails with EINVAL on SmartOS, EBUSY on Windows, EBUSY on AIX.
if (common.isSunOS || common.isWindows || common.isAIX)
common.skip('cannot rmdir current working directory');
+if (!common.isMainThread)
+ common.skip('process.chdir is not available in Workers');
const assert = require('assert');
const fs = require('fs');
diff --git a/test/parallel/test-cwd-enoent-repl.js b/test/parallel/test-cwd-enoent-repl.js
index d42679d868..5ea8abc7e4 100644
--- a/test/parallel/test-cwd-enoent-repl.js
+++ b/test/parallel/test-cwd-enoent-repl.js
@@ -3,6 +3,8 @@ const common = require('../common');
// Fails with EINVAL on SmartOS, EBUSY on Windows, EBUSY on AIX.
if (common.isSunOS || common.isWindows || common.isAIX)
common.skip('cannot rmdir current working directory');
+if (!common.isMainThread)
+ common.skip('process.chdir is not available in Workers');
const assert = require('assert');
const fs = require('fs');
diff --git a/test/parallel/test-cwd-enoent.js b/test/parallel/test-cwd-enoent.js
index e5d93f46ce..8beb1e3fbe 100644
--- a/test/parallel/test-cwd-enoent.js
+++ b/test/parallel/test-cwd-enoent.js
@@ -3,6 +3,8 @@ const common = require('../common');
// Fails with EINVAL on SmartOS, EBUSY on Windows, EBUSY on AIX.
if (common.isSunOS || common.isWindows || common.isAIX)
common.skip('cannot rmdir current working directory');
+if (!common.isMainThread)
+ common.skip('process.chdir is not available in Workers');
const assert = require('assert');
const fs = require('fs');
diff --git a/test/parallel/test-debug-args.js b/test/parallel/test-debug-args.js
index a4ed4f9f1e..bb7ec55824 100644
--- a/test/parallel/test-debug-args.js
+++ b/test/parallel/test-debug-args.js
@@ -1,7 +1,10 @@
'use strict';
// Flags: --debug-code
-require('../common');
+const common = require('../common');
const assert = require('assert');
+if (!common.isMainThread)
+ common.skip('execArgv does not affect Workers');
+
assert(process.execArgv.includes('--debug-code'));
diff --git a/test/parallel/test-fs-realpath.js b/test/parallel/test-fs-realpath.js
index d7efc748bc..599616f522 100644
--- a/test/parallel/test-fs-realpath.js
+++ b/test/parallel/test-fs-realpath.js
@@ -24,6 +24,9 @@ const common = require('../common');
const fixtures = require('../common/fixtures');
const tmpdir = require('../common/tmpdir');
+if (!common.isMainThread)
+ common.skip('process.chdir is not available in Workers');
+
const assert = require('assert');
const fs = require('fs');
const path = require('path');
diff --git a/test/parallel/test-fs-write-file-sync.js b/test/parallel/test-fs-write-file-sync.js
index 9a19b9f6e9..2964ac368b 100644
--- a/test/parallel/test-fs-write-file-sync.js
+++ b/test/parallel/test-fs-write-file-sync.js
@@ -28,6 +28,9 @@ let openCount = 0;
let mode;
let content;
+if (!common.isMainThread)
+ common.skip('process.umask is not available in Workers');
+
// Need to hijack fs.open/close to make sure that things
// get closed once they're opened.
fs._openSync = fs.openSync;
diff --git a/test/parallel/test-module-cjs-helpers.js b/test/parallel/test-module-cjs-helpers.js
index f6e80af032..8e50ecd314 100644
--- a/test/parallel/test-module-cjs-helpers.js
+++ b/test/parallel/test-module-cjs-helpers.js
@@ -1,5 +1,5 @@
'use strict';
-// Flags: --expose-internals
+// Flags: --expose-internals --experimental-worker
require('../common');
const assert = require('assert');
@@ -7,5 +7,5 @@ const { builtinLibs } = require('internal/modules/cjs/helpers');
const hasInspector = process.config.variables.v8_enable_inspector === 1;
-const expectedLibs = hasInspector ? 33 : 32;
+const expectedLibs = hasInspector ? 34 : 33;
assert.strictEqual(builtinLibs.length, expectedLibs);
diff --git a/test/parallel/test-preload.js b/test/parallel/test-preload.js
index 60d52dbcf1..5941c0b96b 100644
--- a/test/parallel/test-preload.js
+++ b/test/parallel/test-preload.js
@@ -5,6 +5,8 @@ const fixtures = require('../common/fixtures');
// Refs: https://github.com/nodejs/node/pull/2253
if (common.isSunOS)
common.skip('unreliable on SunOS');
+if (!common.isMainThread)
+ common.skip('process.chdir is not available in Workers');
const assert = require('assert');
const childProcess = require('child_process');
diff --git a/test/parallel/test-process-chdir-errormessage.js b/test/parallel/test-process-chdir-errormessage.js
index e511688cc7..0475d7940c 100644
--- a/test/parallel/test-process-chdir-errormessage.js
+++ b/test/parallel/test-process-chdir-errormessage.js
@@ -1,8 +1,10 @@
'use strict';
-const { expectsError } = require('../common');
+const common = require('../common');
+if (!common.isMainThread)
+ common.skip('process.chdir is not available in Workers');
-expectsError(
+common.expectsError(
() => {
process.chdir('does-not-exist');
},
diff --git a/test/parallel/test-process-chdir.js b/test/parallel/test-process-chdir.js
index 998147dd43..e66d366fb7 100644
--- a/test/parallel/test-process-chdir.js
+++ b/test/parallel/test-process-chdir.js
@@ -5,6 +5,9 @@ const assert = require('assert');
const fs = require('fs');
const path = require('path');
+if (!common.isMainThread)
+ common.skip('process.chdir is not available in Workers');
+
const tmpdir = require('../common/tmpdir');
process.chdir('..');
diff --git a/test/parallel/test-process-euid-egid.js b/test/parallel/test-process-euid-egid.js
index 84fbd03e32..5639163bf3 100644
--- a/test/parallel/test-process-euid-egid.js
+++ b/test/parallel/test-process-euid-egid.js
@@ -3,9 +3,11 @@
const common = require('../common');
const assert = require('assert');
-if (common.isWindows) {
- assert.strictEqual(process.geteuid, undefined);
- assert.strictEqual(process.getegid, undefined);
+if (common.isWindows || !common.isMainThread) {
+ if (common.isMainThread) {
+ assert.strictEqual(process.geteuid, undefined);
+ assert.strictEqual(process.getegid, undefined);
+ }
assert.strictEqual(process.seteuid, undefined);
assert.strictEqual(process.setegid, undefined);
return;
diff --git a/test/parallel/test-process-exit-handler.js b/test/parallel/test-process-exit-handler.js
index 22d84f3434..d74e320fe6 100644
--- a/test/parallel/test-process-exit-handler.js
+++ b/test/parallel/test-process-exit-handler.js
@@ -1,11 +1,14 @@
'use strict';
-require('../common');
+const common = require('../common');
+
+if (!common.isMainThread)
+ common.skip('execArgv does not affect Workers');
// This test ensures that no asynchronous operations are performed in the 'exit'
// handler.
// https://github.com/nodejs/node/issues/12322
process.on('exit', () => {
- setTimeout(process.abort, 0); // Should not run.
+ setTimeout(() => process.abort(), 0); // Should not run.
for (const start = Date.now(); Date.now() - start < 10;);
});
diff --git a/test/parallel/test-process-fatal-exception-tick.js b/test/parallel/test-process-fatal-exception-tick.js
index 605f961f63..f22273e01c 100644
--- a/test/parallel/test-process-fatal-exception-tick.js
+++ b/test/parallel/test-process-fatal-exception-tick.js
@@ -3,6 +3,9 @@
const common = require('../common');
const assert = require('assert');
+if (!common.isMainThread)
+ common.skip('Error handling timing is different in Workers');
+
// If a process encounters an uncaughtException, it should schedule
// processing of nextTicks on the next Immediates cycle but not
// before all Immediates are handled
diff --git a/test/parallel/test-process-uid-gid.js b/test/parallel/test-process-uid-gid.js
index 2475194309..456cba7f4d 100644
--- a/test/parallel/test-process-uid-gid.js
+++ b/test/parallel/test-process-uid-gid.js
@@ -24,11 +24,13 @@ const common = require('../common');
const assert = require('assert');
-if (common.isWindows) {
- // uid/gid functions are POSIX only
- assert.strictEqual(process.getuid, undefined);
+if (common.isWindows || !common.isMainThread) {
+ // uid/gid functions are POSIX only, setters are main-thread only.
+ if (common.isMainThread) {
+ assert.strictEqual(process.getuid, undefined);
+ assert.strictEqual(process.getgid, undefined);
+ }
assert.strictEqual(process.setuid, undefined);
- assert.strictEqual(process.getgid, undefined);
assert.strictEqual(process.setgid, undefined);
return;
}
diff --git a/test/parallel/test-process-umask-mask.js b/test/parallel/test-process-umask-mask.js
index 8ec8fc0074..26ea5b1d9d 100644
--- a/test/parallel/test-process-umask-mask.js
+++ b/test/parallel/test-process-umask-mask.js
@@ -6,6 +6,9 @@
const common = require('../common');
const assert = require('assert');
+if (!common.isMainThread)
+ common.skip('process.umask is not available in Workers');
+
let mask;
if (common.isWindows) {
diff --git a/test/parallel/test-process-umask.js b/test/parallel/test-process-umask.js
index 1d496f05ef..b1e0c08bcb 100644
--- a/test/parallel/test-process-umask.js
+++ b/test/parallel/test-process-umask.js
@@ -22,6 +22,8 @@
'use strict';
const common = require('../common');
const assert = require('assert');
+if (!common.isMainThread)
+ common.skip('process.umask is not available in Workers');
// Note in Windows one can only set the "user" bits.
let mask;
diff --git a/test/parallel/test-repl-require.js b/test/parallel/test-repl-require.js
index 3d1af7f2f8..ecab4ba698 100644
--- a/test/parallel/test-repl-require.js
+++ b/test/parallel/test-repl-require.js
@@ -5,6 +5,9 @@ const fixtures = require('../common/fixtures');
const assert = require('assert');
const net = require('net');
+if (!common.isMainThread)
+ common.skip('process.chdir is not available in Workers');
+
process.chdir(fixtures.fixturesDir);
const repl = require('repl');
diff --git a/test/parallel/test-repl-sigint-nested-eval.js b/test/parallel/test-repl-sigint-nested-eval.js
index ea07393527..28e4d44b23 100644
--- a/test/parallel/test-repl-sigint-nested-eval.js
+++ b/test/parallel/test-repl-sigint-nested-eval.js
@@ -4,6 +4,8 @@ if (common.isWindows) {
// No way to send CTRL_C_EVENT to processes from JS right now.
common.skip('platform not supported');
}
+if (!common.isMainThread)
+ common.skip('No signal handling available in Workers');
const assert = require('assert');
const spawn = require('child_process').spawn;
diff --git a/test/parallel/test-repl-sigint.js b/test/parallel/test-repl-sigint.js
index 14cafd0463..8ad0b2f5c2 100644
--- a/test/parallel/test-repl-sigint.js
+++ b/test/parallel/test-repl-sigint.js
@@ -4,6 +4,8 @@ if (common.isWindows) {
// No way to send CTRL_C_EVENT to processes from JS right now.
common.skip('platform not supported');
}
+if (!common.isMainThread)
+ common.skip('No signal handling available in Workers');
const assert = require('assert');
const spawn = require('child_process').spawn;
diff --git a/test/parallel/test-repl-tab-complete.js b/test/parallel/test-repl-tab-complete.js
index 6485f8bd17..57c1615e6f 100644
--- a/test/parallel/test-repl-tab-complete.js
+++ b/test/parallel/test-repl-tab-complete.js
@@ -26,6 +26,9 @@ const assert = require('assert');
const fixtures = require('../common/fixtures');
const hasInspector = process.config.variables.v8_enable_inspector === 1;
+if (!common.isMainThread)
+ common.skip('process.chdir is not available in Workers');
+
// We have to change the directory to ../fixtures before requiring repl
// in order to make the tests for completion of node_modules work properly
// since repl modifies module.paths.
diff --git a/test/parallel/test-require-symlink.js b/test/parallel/test-require-symlink.js
index d245c21dd1..7aad3ee0a7 100644
--- a/test/parallel/test-require-symlink.js
+++ b/test/parallel/test-require-symlink.js
@@ -4,6 +4,8 @@ const common = require('../common');
if (!common.canCreateSymLink())
common.skip('insufficient privileges');
+if (!common.isMainThread)
+ common.skip('process.chdir is not available in Workers');
const assert = require('assert');
const { spawn } = require('child_process');
diff --git a/test/parallel/test-setproctitle.js b/test/parallel/test-setproctitle.js
index 1ab6bff6a3..e5f6858f78 100644
--- a/test/parallel/test-setproctitle.js
+++ b/test/parallel/test-setproctitle.js
@@ -5,6 +5,8 @@ const common = require('../common');
// FIXME add sunos support
if (common.isSunOS)
common.skip(`Unsupported platform [${process.platform}]`);
+if (!common.isMainThread)
+ common.skip('Setting the process title from Workers is not supported');
const assert = require('assert');
const exec = require('child_process').exec;
diff --git a/test/parallel/test-signal-args.js b/test/parallel/test-signal-args.js
index d9fa6df347..7b72ed6dcb 100644
--- a/test/parallel/test-signal-args.js
+++ b/test/parallel/test-signal-args.js
@@ -3,9 +3,10 @@
const common = require('../common');
const assert = require('assert');
-if (common.isWindows) {
+if (common.isWindows)
common.skip('Sending signals with process.kill is not supported on Windows');
-}
+if (!common.isMainThread)
+ common.skip('No signal handling available in Workers');
process.once('SIGINT', common.mustCall((signal) => {
assert.strictEqual(signal, 'SIGINT');
diff --git a/test/parallel/test-signal-handler.js b/test/parallel/test-signal-handler.js
index a5c900695a..05ec4e7f73 100644
--- a/test/parallel/test-signal-handler.js
+++ b/test/parallel/test-signal-handler.js
@@ -25,6 +25,8 @@ const common = require('../common');
if (common.isWindows)
common.skip('SIGUSR1 and SIGHUP signals are not supported');
+if (!common.isMainThread)
+ common.skip('Signal handling in Workers is not supported');
console.log(`process.pid: ${process.pid}`);
diff --git a/test/parallel/test-stdio-pipe-access.js b/test/parallel/test-stdio-pipe-access.js
index ef84bb8380..d32c5f0ba9 100644
--- a/test/parallel/test-stdio-pipe-access.js
+++ b/test/parallel/test-stdio-pipe-access.js
@@ -1,5 +1,7 @@
'use strict';
-require('../common');
+const common = require('../common');
+if (!common.isMainThread)
+ common.skip('Workers don’t have process-like stdio');
// Test if Node handles acessing process.stdin if it is a redirected
// pipe without deadlocking
diff --git a/test/parallel/test-stdio-pipe-redirect.js b/test/parallel/test-stdio-pipe-redirect.js
index b47f5b9cf4..60f16b5cb2 100644
--- a/test/parallel/test-stdio-pipe-redirect.js
+++ b/test/parallel/test-stdio-pipe-redirect.js
@@ -1,5 +1,7 @@
'use strict';
-require('../common');
+const common = require('../common');
+if (!common.isMainThread)
+ common.skip('Workers don’t have process-like stdio');
// Test if Node handles redirecting one child process stdout to another
// process stdin without crashing.
diff --git a/test/parallel/test-timers-immediate-unref-nested-once.js b/test/parallel/test-timers-immediate-unref-nested-once.js
new file mode 100644
index 0000000000..00efce9bcb
--- /dev/null
+++ b/test/parallel/test-timers-immediate-unref-nested-once.js
@@ -0,0 +1,9 @@
+'use strict';
+
+const common = require('../common');
+
+// This immediate should not execute as it was unrefed
+// and nothing else is keeping the event loop alive
+setImmediate(() => {
+ setImmediate(common.mustNotCall()).unref();
+});
diff --git a/test/parallel/test-timers-immediate-unref-simple.js b/test/parallel/test-timers-immediate-unref-simple.js
index 6849746032..369894fcde 100644
--- a/test/parallel/test-timers-immediate-unref-simple.js
+++ b/test/parallel/test-timers-immediate-unref-simple.js
@@ -2,6 +2,11 @@
const common = require('../common');
+if (!common.isMainThread) {
+ // Note that test-timers-immediate-unref-nested-once works instead.
+ common.skip('Worker bootstrapping works differently -> different timing');
+}
+
// This immediate should not execute as it was unrefed
// and nothing else is keeping the event loop alive
setImmediate(common.mustNotCall()).unref();
diff --git a/test/parallel/test-trace-events-all.js b/test/parallel/test-trace-events-all.js
index 51d0f3c5a2..585d4acd18 100644
--- a/test/parallel/test-trace-events-all.js
+++ b/test/parallel/test-trace-events-all.js
@@ -4,6 +4,9 @@ const assert = require('assert');
const cp = require('child_process');
const fs = require('fs');
+if (!common.isMainThread)
+ common.skip('process.chdir is not available in Workers');
+
const CODE =
'setTimeout(() => { for (var i = 0; i < 100000; i++) { "test" + i } }, 1)';
const FILE_NAME = 'node_trace.1.log';
diff --git a/test/parallel/test-trace-events-api.js b/test/parallel/test-trace-events-api.js
index a68a2850a3..5dd4c623c0 100644
--- a/test/parallel/test-trace-events-api.js
+++ b/test/parallel/test-trace-events-api.js
@@ -5,6 +5,8 @@ const common = require('../common');
if (!common.hasTracing)
common.skip('missing trace events');
+if (!common.isMainThread)
+ common.skip('process.chdir is not available in Workers');
const assert = require('assert');
const cp = require('child_process');
diff --git a/test/parallel/test-trace-events-async-hooks.js b/test/parallel/test-trace-events-async-hooks.js
index e0b5e0625b..9dd71eda4c 100644
--- a/test/parallel/test-trace-events-async-hooks.js
+++ b/test/parallel/test-trace-events-async-hooks.js
@@ -5,6 +5,9 @@ const cp = require('child_process');
const fs = require('fs');
const util = require('util');
+if (!common.isMainThread)
+ common.skip('process.chdir is not available in Workers');
+
const CODE =
'setTimeout(() => { for (var i = 0; i < 100000; i++) { "test" + i } }, 1)';
const FILE_NAME = 'node_trace.1.log';
diff --git a/test/parallel/test-trace-events-binding.js b/test/parallel/test-trace-events-binding.js
index e52f1c769f..f50c132184 100644
--- a/test/parallel/test-trace-events-binding.js
+++ b/test/parallel/test-trace-events-binding.js
@@ -4,6 +4,9 @@ const assert = require('assert');
const cp = require('child_process');
const fs = require('fs');
+if (!common.isMainThread)
+ common.skip('process.chdir is not available in Workers');
+
const CODE = `
process.binding("trace_events").emit(
'b'.charCodeAt(0), 'custom',
diff --git a/test/parallel/test-trace-events-bootstrap.js b/test/parallel/test-trace-events-bootstrap.js
index 6f8c76564a..c0f8a49c85 100644
--- a/test/parallel/test-trace-events-bootstrap.js
+++ b/test/parallel/test-trace-events-bootstrap.js
@@ -6,6 +6,9 @@ const path = require('path');
const fs = require('fs');
const tmpdir = require('../common/tmpdir');
+if (!common.isMainThread)
+ common.skip('process.chdir is not available in Workers');
+
const names = [
'environment',
'nodeStart',
diff --git a/test/parallel/test-trace-events-category-used.js b/test/parallel/test-trace-events-category-used.js
index a98cb35037..d5aff4e136 100644
--- a/test/parallel/test-trace-events-category-used.js
+++ b/test/parallel/test-trace-events-category-used.js
@@ -3,6 +3,9 @@ const common = require('../common');
const assert = require('assert');
const cp = require('child_process');
+if (!common.isMainThread)
+ common.skip('process.chdir is not available in Workers');
+
const CODE = `console.log(
process.binding("trace_events").categoryGroupEnabled("custom")
);`;
diff --git a/test/parallel/test-trace-events-file-pattern.js b/test/parallel/test-trace-events-file-pattern.js
index 46059ad31d..c8098a4397 100644
--- a/test/parallel/test-trace-events-file-pattern.js
+++ b/test/parallel/test-trace-events-file-pattern.js
@@ -5,6 +5,9 @@ const assert = require('assert');
const cp = require('child_process');
const fs = require('fs');
+if (!common.isMainThread)
+ common.skip('process.chdir is not available in Workers');
+
tmpdir.refresh();
process.chdir(tmpdir.path);
diff --git a/test/parallel/test-trace-events-fs-sync.js b/test/parallel/test-trace-events-fs-sync.js
index 60ab5efa3a..491679c9c0 100644
--- a/test/parallel/test-trace-events-fs-sync.js
+++ b/test/parallel/test-trace-events-fs-sync.js
@@ -4,6 +4,9 @@ const assert = require('assert');
const cp = require('child_process');
const fs = require('fs');
+if (!common.isMainThread)
+ common.skip('process.chdir is not available in Workers');
+
const tests = new Array();
const traceFile = 'node_trace.1.log';
diff --git a/test/parallel/test-trace-events-metadata.js b/test/parallel/test-trace-events-metadata.js
index 8b6e97ce35..440aa00a9c 100644
--- a/test/parallel/test-trace-events-metadata.js
+++ b/test/parallel/test-trace-events-metadata.js
@@ -4,6 +4,9 @@ const assert = require('assert');
const cp = require('child_process');
const fs = require('fs');
+if (!common.isMainThread)
+ common.skip('process.chdir is not available in Workers');
+
const CODE =
'setTimeout(() => { for (var i = 0; i < 100000; i++) { "test" + i } }, 1)';
const FILE_NAME = 'node_trace.1.log';
diff --git a/test/parallel/test-trace-events-none.js b/test/parallel/test-trace-events-none.js
index a3f0338f28..e6beea3b97 100644
--- a/test/parallel/test-trace-events-none.js
+++ b/test/parallel/test-trace-events-none.js
@@ -4,6 +4,9 @@ const assert = require('assert');
const cp = require('child_process');
const fs = require('fs');
+if (!common.isMainThread)
+ common.skip('process.chdir is not available in Workers');
+
const CODE =
'setTimeout(() => { for (var i = 0; i < 100000; i++) { "test" + i } }, 1)';
const FILE_NAME = 'node_trace.1.log';
diff --git a/test/parallel/test-trace-events-perf.js b/test/parallel/test-trace-events-perf.js
index 57ac0e3142..8ca5a41eac 100644
--- a/test/parallel/test-trace-events-perf.js
+++ b/test/parallel/test-trace-events-perf.js
@@ -6,6 +6,9 @@ const path = require('path');
const fs = require('fs');
const tmpdir = require('../common/tmpdir');
+if (!common.isMainThread)
+ common.skip('process.chdir is not available in Workers');
+
if (process.argv[2] === 'child') {
const { performance } = require('perf_hooks');
diff --git a/test/parallel/test-trace-events-process-exit.js b/test/parallel/test-trace-events-process-exit.js
index 9f164ee627..aeb9fc19c2 100644
--- a/test/parallel/test-trace-events-process-exit.js
+++ b/test/parallel/test-trace-events-process-exit.js
@@ -4,6 +4,9 @@ const assert = require('assert');
const cp = require('child_process');
const fs = require('fs');
+if (!common.isMainThread)
+ common.skip('process.chdir is not available in Workers');
+
const tmpdir = require('../common/tmpdir');
const FILE_NAME = 'node_trace.1.log';
diff --git a/test/parallel/test-trace-events-v8.js b/test/parallel/test-trace-events-v8.js
index 49c34b8f17..325789e968 100644
--- a/test/parallel/test-trace-events-v8.js
+++ b/test/parallel/test-trace-events-v8.js
@@ -4,6 +4,9 @@ const assert = require('assert');
const cp = require('child_process');
const fs = require('fs');
+if (!common.isMainThread)
+ common.skip('process.chdir is not available in Workers');
+
const CODE =
'setTimeout(() => { for (var i = 0; i < 100000; i++) { "test" + i } }, 1)';
const FILE_NAME = 'node_trace.1.log';
diff --git a/test/parallel/test-trace-events-vm.js b/test/parallel/test-trace-events-vm.js
index 3dc6e263e1..45724e3e4c 100644
--- a/test/parallel/test-trace-events-vm.js
+++ b/test/parallel/test-trace-events-vm.js
@@ -6,6 +6,9 @@ const path = require('path');
const fs = require('fs');
const tmpdir = require('../common/tmpdir');
+if (!common.isMainThread)
+ common.skip('process.chdir is not available in Workers');
+
const names = [
'ContextifyScript::New',
'RunInThisContext',
diff --git a/test/sequential/test-async-wrap-getasyncid.js b/test/sequential/test-async-wrap-getasyncid.js
index af08d7b656..c16624a79e 100644
--- a/test/sequential/test-async-wrap-getasyncid.js
+++ b/test/sequential/test-async-wrap-getasyncid.js
@@ -39,6 +39,8 @@ common.crashOnUnhandledRejection();
delete providers.STREAMPIPE;
delete providers.MESSAGEPORT;
delete providers.WORKER;
+ if (!common.isMainThread)
+ delete providers.INSPECTORJSBINDING;
const objKeys = Object.keys(providers);
if (objKeys.length > 0)
@@ -281,7 +283,8 @@ if (common.hasCrypto) { // eslint-disable-line node-core/crypto-check
testInitialized(req, 'SendWrap');
}
-if (process.config.variables.v8_enable_inspector !== 0) {
+if (process.config.variables.v8_enable_inspector !== 0 &&
+ common.isMainThread) {
const binding = process.binding('inspector');
const handle = new binding.Connection(() => {});
testInitialized(handle, 'Connection');
diff --git a/test/sequential/test-buffer-creation-regression.js b/test/sequential/test-buffer-creation-regression.js
index 8c3a09848c..07deb1db0f 100644
--- a/test/sequential/test-buffer-creation-regression.js
+++ b/test/sequential/test-buffer-creation-regression.js
@@ -30,7 +30,6 @@ try {
} catch (e) {
if (e instanceof RangeError && acceptableOOMErrors.includes(e.message))
common.skip(`Unable to allocate ${size} bytes for ArrayBuffer`);
-
throw e;
}
diff --git a/test/sequential/test-fs-watch.js b/test/sequential/test-fs-watch.js
index 3c8ae0eba7..1326e62bc1 100644
--- a/test/sequential/test-fs-watch.js
+++ b/test/sequential/test-fs-watch.js
@@ -28,6 +28,9 @@ const path = require('path');
const tmpdir = require('../common/tmpdir');
+if (!common.isMainThread)
+ common.skip('process.chdir is not available in Workers');
+
const expectFilePath = common.isWindows ||
common.isLinux ||
common.isOSX ||
diff --git a/test/sequential/test-init.js b/test/sequential/test-init.js
index 5dd8d9ab14..1b1b09ee83 100644
--- a/test/sequential/test-init.js
+++ b/test/sequential/test-init.js
@@ -25,6 +25,9 @@ const assert = require('assert');
const child = require('child_process');
const fixtures = require('../common/fixtures');
+if (!common.isMainThread)
+ common.skip('process.chdir is not available in Workers');
+
if (process.env.TEST_INIT) {
return process.stdout.write('Loaded successfully!');
}
diff --git a/test/sequential/test-inspector-overwrite-config.js b/test/sequential/test-inspector-overwrite-config.js
index 8b641a0048..46cb922402 100644
--- a/test/sequential/test-inspector-overwrite-config.js
+++ b/test/sequential/test-inspector-overwrite-config.js
@@ -13,6 +13,10 @@
const common = require('../common');
const assert = require('assert');
+
+if (!common.isMainThread)
+ common.skip('--require does not work with Workers');
+
const inspector = require('inspector');
const msg = 'Test inspector logging';
let asserted = false;
diff --git a/test/sequential/test-performance.js b/test/sequential/test-performance.js
index c5065227a6..fdadb0be14 100644
--- a/test/sequential/test-performance.js
+++ b/test/sequential/test-performance.js
@@ -4,6 +4,9 @@ const common = require('../common');
const assert = require('assert');
const { performance } = require('perf_hooks');
+if (!common.isMainThread)
+ common.skip('bootstrapping workers works differently');
+
assert(performance);
assert(performance.nodeTiming);
assert.strictEqual(typeof performance.timeOrigin, 'number');
diff --git a/tools/run-worker.js b/tools/run-worker.js
new file mode 100644
index 0000000000..a9dd773ecf
--- /dev/null
+++ b/tools/run-worker.js
@@ -0,0 +1,11 @@
+'use strict';
+if (typeof require === 'undefined') {
+ console.log('1..0 # Skipped: Not being run as CommonJS');
+ process.exit(0);
+}
+
+const path = require('path');
+const { Worker } = require('worker');
+
+new Worker(path.resolve(process.cwd(), process.argv[2]))
+ .on('exit', (code) => process.exitCode = code);
diff --git a/tools/test.py b/tools/test.py
index e5581e8da4..27a2722438 100755
--- a/tools/test.py
+++ b/tools/test.py
@@ -1375,6 +1375,8 @@ def BuildOptions():
help="Expect test cases to fail", default=False, action="store_true")
result.add_option("--valgrind", help="Run tests through valgrind",
default=False, action="store_true")
+ result.add_option("--worker", help="Run parallel tests inside a worker context",
+ default=False, action="store_true")
result.add_option("--check-deopts", help="Check tests for permanent deoptimizations",
default=False, action="store_true")
result.add_option("--cat", help="Print the source of the tests",
@@ -1617,6 +1619,11 @@ def Main():
options.node_args.append("--always-opt")
options.progress = "deopts"
+ if options.worker:
+ run_worker = join(workspace, "tools", "run-worker.js")
+ options.node_args.append('--experimental-worker')
+ options.node_args.append(run_worker)
+
shell = abspath(options.shell)
buildspace = dirname(shell)