test: rely less on duplicative common test harness utilities
There are several cleanups here that are not just style nits... 1. The `common.isMainThread` was just a passthrough to the `isMainThread` export on the worker_thread module. It's use was inconsistent and just obfuscated the fact that the test file depend on the `worker_threads` built-in. By eliminating it we simplify the test harness a bit and make it clearer which tests depend on the worker_threads check. 2. The `common.isDumbTerminal` is fairly unnecesary since that just wraps a public API check. 3. Several of the `common.skipIf....` checks were inconsistently used and really don't need to be separate utility functions. A key part of the motivation here is to work towards making more of the tests more self-contained and less reliant on the common test harness where possible. PR-URL: https://github.com/nodejs/node/pull/56712 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This commit is contained in:
parent
0713ee3a17
commit
8caa1dcee6
@ -1,8 +1,47 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const cp = require('child_process');
|
const cp = require('child_process');
|
||||||
|
|
||||||
|
function getPrintedStackTrace(stderr) {
|
||||||
|
const lines = stderr.split('\n');
|
||||||
|
|
||||||
|
let state = 'initial';
|
||||||
|
const result = {
|
||||||
|
message: [],
|
||||||
|
nativeStack: [],
|
||||||
|
jsStack: [],
|
||||||
|
};
|
||||||
|
for (let i = 0; i < lines.length; ++i) {
|
||||||
|
const line = lines[i].trim();
|
||||||
|
if (line.length === 0) {
|
||||||
|
continue; // Skip empty lines.
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (state) {
|
||||||
|
case 'initial':
|
||||||
|
result.message.push(line);
|
||||||
|
if (line.includes('Native stack trace')) {
|
||||||
|
state = 'native-stack';
|
||||||
|
} else {
|
||||||
|
result.message.push(line);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'native-stack':
|
||||||
|
if (line.includes('JavaScript stack trace')) {
|
||||||
|
state = 'js-stack';
|
||||||
|
} else {
|
||||||
|
result.nativeStack.push(line);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'js-stack':
|
||||||
|
result.jsStack.push(line);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
if (process.argv[2] === 'child') {
|
if (process.argv[2] === 'child') {
|
||||||
process.abort();
|
process.abort();
|
||||||
} else {
|
} else {
|
||||||
@ -10,7 +49,7 @@ if (process.argv[2] === 'child') {
|
|||||||
const stderr = child.stderr.toString();
|
const stderr = child.stderr.toString();
|
||||||
|
|
||||||
assert.strictEqual(child.stdout.toString(), '');
|
assert.strictEqual(child.stdout.toString(), '');
|
||||||
const { nativeStack, jsStack } = common.getPrintedStackTrace(stderr);
|
const { nativeStack, jsStack } = getPrintedStackTrace(stderr);
|
||||||
|
|
||||||
if (!nativeStack.every((frame, index) => frame.startsWith(`${index + 1}:`))) {
|
if (!nativeStack.every((frame, index) => frame.startsWith(`${index + 1}:`))) {
|
||||||
assert.fail(`Each frame should start with a frame number:\n${stderr}`);
|
assert.fail(`Each frame should start with a frame number:\n${stderr}`);
|
||||||
@ -18,7 +57,7 @@ if (process.argv[2] === 'child') {
|
|||||||
|
|
||||||
// For systems that don't support backtraces, the native stack is
|
// For systems that don't support backtraces, the native stack is
|
||||||
// going to be empty.
|
// going to be empty.
|
||||||
if (!common.isWindows && nativeStack.length > 0) {
|
if (process.platform !== 'win32' && nativeStack.length > 0) {
|
||||||
const { getBinaryPath } = require('../common/shared-lib-util');
|
const { getBinaryPath } = require('../common/shared-lib-util');
|
||||||
if (!nativeStack.some((frame) => frame.includes(`[${getBinaryPath()}]`))) {
|
if (!nativeStack.some((frame) => frame.includes(`[${getBinaryPath()}]`))) {
|
||||||
assert.fail(`Some native stack frame include the binary name:\n${stderr}`);
|
assert.fail(`Some native stack frame include the binary name:\n${stderr}`);
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
// Flags: --expose-gc
|
// Flags: --expose-gc
|
||||||
|
|
||||||
const common = require('../common');
|
require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const async_hooks = require('async_hooks');
|
const async_hooks = require('async_hooks');
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
const util = require('util');
|
const util = require('util');
|
||||||
const print = process._rawDebug;
|
const print = process._rawDebug;
|
||||||
|
|
||||||
@ -161,7 +162,7 @@ class ActivityCollector {
|
|||||||
const stub = { uid, type: 'Unknown', handleIsObject: true, handle: {} };
|
const stub = { uid, type: 'Unknown', handleIsObject: true, handle: {} };
|
||||||
this._activities.set(uid, stub);
|
this._activities.set(uid, stub);
|
||||||
return stub;
|
return stub;
|
||||||
} else if (!common.isMainThread) {
|
} else if (!isMainThread) {
|
||||||
// Worker threads start main script execution inside of an AsyncWrap
|
// Worker threads start main script execution inside of an AsyncWrap
|
||||||
// callback, so we don't yield errors for these.
|
// callback, so we don't yield errors for these.
|
||||||
return null;
|
return null;
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
if (!common.hasCrypto)
|
if (!common.hasCrypto) {
|
||||||
common.skip('missing crypto');
|
common.skip('missing crypto');
|
||||||
if (!common.isMainThread)
|
}
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
if (!isMainThread) {
|
||||||
common.skip('Worker bootstrapping works differently -> different async IDs');
|
common.skip('Worker bootstrapping works differently -> different async IDs');
|
||||||
|
}
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const tick = require('../common/tick');
|
const tick = require('../common/tick');
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
if (!common.hasCrypto)
|
if (!common.hasCrypto) {
|
||||||
common.skip('missing crypto');
|
common.skip('missing crypto');
|
||||||
if (!common.isMainThread)
|
}
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
if (!isMainThread) {
|
||||||
common.skip('Worker bootstrapping works differently -> different async IDs');
|
common.skip('Worker bootstrapping works differently -> different async IDs');
|
||||||
|
}
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const tick = require('../common/tick');
|
const tick = require('../common/tick');
|
||||||
|
@ -87,8 +87,9 @@ const assert = require('assert');
|
|||||||
const tick = require('../common/tick');
|
const tick = require('../common/tick');
|
||||||
const initHooks = require('./init-hooks');
|
const initHooks = require('./init-hooks');
|
||||||
const { checkInvocations } = require('./hook-checks');
|
const { checkInvocations } = require('./hook-checks');
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
if (!common.isMainThread)
|
if (!isMainThread)
|
||||||
common.skip('Worker bootstrapping works differently -> different timing');
|
common.skip('Worker bootstrapping works differently -> different timing');
|
||||||
|
|
||||||
// Include "Unknown"s because hook2 will not be able to identify
|
// Include "Unknown"s because hook2 will not be able to identify
|
||||||
|
@ -6,12 +6,15 @@ const initHooks = require('./init-hooks');
|
|||||||
const tick = require('../common/tick');
|
const tick = require('../common/tick');
|
||||||
const { checkInvocations } = require('./hook-checks');
|
const { checkInvocations } = require('./hook-checks');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
if (!common.isMainThread)
|
if (!isMainThread) {
|
||||||
common.skip('Worker bootstrapping works differently -> different async IDs');
|
common.skip('Worker bootstrapping works differently -> different async IDs');
|
||||||
|
}
|
||||||
|
|
||||||
if (common.isIBMi)
|
if (common.isIBMi) {
|
||||||
common.skip('IBMi does not support fs.watch()');
|
common.skip('IBMi does not support fs.watch()');
|
||||||
|
}
|
||||||
|
|
||||||
const hooks = initHooks();
|
const hooks = initHooks();
|
||||||
|
|
||||||
|
@ -6,9 +6,11 @@ const tick = require('../common/tick');
|
|||||||
const initHooks = require('./init-hooks');
|
const initHooks = require('./init-hooks');
|
||||||
const { checkInvocations } = require('./hook-checks');
|
const { checkInvocations } = require('./hook-checks');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
if (!common.isMainThread)
|
if (!isMainThread) {
|
||||||
common.skip('Worker bootstrapping works differently -> different async IDs');
|
common.skip('Worker bootstrapping works differently -> different async IDs');
|
||||||
|
}
|
||||||
|
|
||||||
const hooks = initHooks();
|
const hooks = initHooks();
|
||||||
|
|
||||||
|
@ -6,9 +6,11 @@ const tick = require('../common/tick');
|
|||||||
const initHooks = require('./init-hooks');
|
const initHooks = require('./init-hooks');
|
||||||
const { checkInvocations } = require('./hook-checks');
|
const { checkInvocations } = require('./hook-checks');
|
||||||
const dns = require('dns');
|
const dns = require('dns');
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
if (!common.isMainThread)
|
if (!isMainThread) {
|
||||||
common.skip('Worker bootstrapping works differently -> different async IDs');
|
common.skip('Worker bootstrapping works differently -> different async IDs');
|
||||||
|
}
|
||||||
|
|
||||||
const hooks = initHooks();
|
const hooks = initHooks();
|
||||||
|
|
||||||
|
@ -6,9 +6,11 @@ const tick = require('../common/tick');
|
|||||||
const initHooks = require('./init-hooks');
|
const initHooks = require('./init-hooks');
|
||||||
const { checkInvocations } = require('./hook-checks');
|
const { checkInvocations } = require('./hook-checks');
|
||||||
const dns = require('dns');
|
const dns = require('dns');
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
if (!common.isMainThread)
|
if (!isMainThread) {
|
||||||
common.skip('Worker bootstrapping works differently -> different async IDs');
|
common.skip('Worker bootstrapping works differently -> different async IDs');
|
||||||
|
}
|
||||||
|
|
||||||
const hooks = initHooks();
|
const hooks = initHooks();
|
||||||
|
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
if (common.isWindows)
|
if (common.isWindows) {
|
||||||
common.skip('no signals on Windows');
|
common.skip('no signals on Windows');
|
||||||
if (!common.isMainThread)
|
}
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
if (!isMainThread) {
|
||||||
common.skip('No signal handling available in Workers');
|
common.skip('No signal handling available in Workers');
|
||||||
|
}
|
||||||
|
|
||||||
const initHooks = require('./init-hooks');
|
const initHooks = require('./init-hooks');
|
||||||
const verifyGraph = require('./verify-graph');
|
const verifyGraph = require('./verify-graph');
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
// Flags: --no-force-async-hooks-checks --expose-internals
|
// Flags: --no-force-async-hooks-checks --expose-internals
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
if (!common.isMainThread)
|
if (!isMainThread) {
|
||||||
common.skip('Workers don\'t inherit per-env state like the check flag');
|
common.skip('Workers don\'t inherit per-env state like the check flag');
|
||||||
|
}
|
||||||
|
|
||||||
const async_hooks = require('internal/async_hooks');
|
const async_hooks = require('internal/async_hooks');
|
||||||
|
|
||||||
|
@ -9,9 +9,11 @@ const tick = require('../common/tick');
|
|||||||
const initHooks = require('./init-hooks');
|
const initHooks = require('./init-hooks');
|
||||||
const { checkInvocations } = require('./hook-checks');
|
const { checkInvocations } = require('./hook-checks');
|
||||||
const { spawn } = require('child_process');
|
const { spawn } = require('child_process');
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
if (!common.isMainThread)
|
if (!isMainThread) {
|
||||||
common.skip('Worker bootstrapping works differently -> different async IDs');
|
common.skip('Worker bootstrapping works differently -> different async IDs');
|
||||||
|
}
|
||||||
|
|
||||||
const hooks = initHooks();
|
const hooks = initHooks();
|
||||||
|
|
||||||
|
@ -4,9 +4,11 @@ const common = require('../common');
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const initHooks = require('./init-hooks');
|
const initHooks = require('./init-hooks');
|
||||||
const { checkInvocations } = require('./hook-checks');
|
const { checkInvocations } = require('./hook-checks');
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
if (!common.isMainThread)
|
if (!isMainThread) {
|
||||||
common.skip('Worker bootstrapping works differently -> different async IDs');
|
common.skip('Worker bootstrapping works differently -> different async IDs');
|
||||||
|
}
|
||||||
|
|
||||||
const p = new Promise(common.mustCall(function executor(resolve) {
|
const p = new Promise(common.mustCall(function executor(resolve) {
|
||||||
resolve(5);
|
resolve(5);
|
||||||
|
@ -5,9 +5,11 @@ const common = require('../common');
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const initHooks = require('./init-hooks');
|
const initHooks = require('./init-hooks');
|
||||||
const { checkInvocations } = require('./hook-checks');
|
const { checkInvocations } = require('./hook-checks');
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
if (!common.isMainThread)
|
if (!isMainThread) {
|
||||||
common.skip('Worker bootstrapping works differently -> different async IDs');
|
common.skip('Worker bootstrapping works differently -> different async IDs');
|
||||||
|
}
|
||||||
|
|
||||||
const hooks = initHooks();
|
const hooks = initHooks();
|
||||||
|
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
|
||||||
if (common.isWindows)
|
if (common.isWindows) {
|
||||||
common.skip('no signals in Windows');
|
common.skip('no signals in Windows');
|
||||||
if (!common.isMainThread)
|
}
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
if (!isMainThread) {
|
||||||
common.skip('No signal handling available in Workers');
|
common.skip('No signal handling available in Workers');
|
||||||
|
}
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const initHooks = require('./init-hooks');
|
const initHooks = require('./init-hooks');
|
||||||
|
@ -7,8 +7,11 @@ const initHooks = require('./init-hooks');
|
|||||||
const { checkInvocations } = require('./hook-checks');
|
const { checkInvocations } = require('./hook-checks');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
||||||
if (!common.isMainThread)
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
|
if (!isMainThread) {
|
||||||
common.skip('Worker bootstrapping works differently -> different async IDs');
|
common.skip('Worker bootstrapping works differently -> different async IDs');
|
||||||
|
}
|
||||||
|
|
||||||
tmpdir.refresh();
|
tmpdir.refresh();
|
||||||
|
|
||||||
|
@ -5,9 +5,11 @@ const common = require('../common');
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const initHooks = require('./init-hooks');
|
const initHooks = require('./init-hooks');
|
||||||
const async_hooks = require('async_hooks');
|
const async_hooks = require('async_hooks');
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
if (!common.isMainThread)
|
if (!isMainThread) {
|
||||||
common.skip('Worker bootstrapping works differently -> different async IDs');
|
common.skip('Worker bootstrapping works differently -> different async IDs');
|
||||||
|
}
|
||||||
|
|
||||||
const promiseAsyncIds = [];
|
const promiseAsyncIds = [];
|
||||||
const hooks = initHooks({
|
const hooks = initHooks({
|
||||||
|
@ -6,7 +6,9 @@ if (common.isWindows) {
|
|||||||
common.skip('vcbuild.bat doesn\'t build the n-api benchmarks yet');
|
common.skip('vcbuild.bat doesn\'t build the n-api benchmarks yet');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!common.isMainThread) {
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
|
if (!isMainThread) {
|
||||||
common.skip('addons are not supported in workers');
|
common.skip('addons are not supported in workers');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,10 +102,6 @@ symlinks
|
|||||||
([SeCreateSymbolicLinkPrivilege](https://msdn.microsoft.com/en-us/library/windows/desktop/bb530716\(v=vs.85\).aspx)).
|
([SeCreateSymbolicLinkPrivilege](https://msdn.microsoft.com/en-us/library/windows/desktop/bb530716\(v=vs.85\).aspx)).
|
||||||
On non-Windows platforms, this always returns `true`.
|
On non-Windows platforms, this always returns `true`.
|
||||||
|
|
||||||
### `createZeroFilledFile(filename)`
|
|
||||||
|
|
||||||
Creates a 10 MiB file of all null characters.
|
|
||||||
|
|
||||||
### `enoughTestMem`
|
### `enoughTestMem`
|
||||||
|
|
||||||
* [\<boolean>][<boolean>]
|
* [\<boolean>][<boolean>]
|
||||||
@ -257,10 +253,6 @@ Platform check for Advanced Interactive eXecutive (AIX).
|
|||||||
|
|
||||||
Attempts to 'kill' `pid`
|
Attempts to 'kill' `pid`
|
||||||
|
|
||||||
### `isDumbTerminal`
|
|
||||||
|
|
||||||
* [\<boolean>][<boolean>]
|
|
||||||
|
|
||||||
### `isFreeBSD`
|
### `isFreeBSD`
|
||||||
|
|
||||||
* [\<boolean>][<boolean>]
|
* [\<boolean>][<boolean>]
|
||||||
@ -456,10 +448,6 @@ will not be run.
|
|||||||
|
|
||||||
Logs '1..0 # Skipped: ' + `msg` and exits with exit code `0`.
|
Logs '1..0 # Skipped: ' + `msg` and exits with exit code `0`.
|
||||||
|
|
||||||
### `skipIfDumbTerminal()`
|
|
||||||
|
|
||||||
Skip the rest of the tests if the current terminal is a dumb terminal
|
|
||||||
|
|
||||||
### `skipIfEslintMissing()`
|
### `skipIfEslintMissing()`
|
||||||
|
|
||||||
Skip the rest of the tests in the current file when `ESLint` is not available
|
Skip the rest of the tests in the current file when `ESLint` is not available
|
||||||
@ -475,11 +463,6 @@ was disabled at compile time.
|
|||||||
Skip the rest of the tests in the current file when the Node.js executable
|
Skip the rest of the tests in the current file when the Node.js executable
|
||||||
was compiled with a pointer size smaller than 64 bits.
|
was compiled with a pointer size smaller than 64 bits.
|
||||||
|
|
||||||
### `skipIfWorker()`
|
|
||||||
|
|
||||||
Skip the rest of the tests in the current file when not running on a main
|
|
||||||
thread.
|
|
||||||
|
|
||||||
## ArrayStream module
|
## ArrayStream module
|
||||||
|
|
||||||
The `ArrayStream` module provides a simple `Stream` that pushes elements from
|
The `ArrayStream` module provides a simple `Stream` that pushes elements from
|
||||||
|
@ -139,8 +139,6 @@ const isPi = (() => {
|
|||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
const isDumbTerminal = process.env.TERM === 'dumb';
|
|
||||||
|
|
||||||
// When using high concurrency or in the CI we need much more time for each connection attempt
|
// When using high concurrency or in the CI we need much more time for each connection attempt
|
||||||
net.setDefaultAutoSelectFamilyAttemptTimeout(platformTimeout(net.getDefaultAutoSelectFamilyAttemptTimeout() * 10));
|
net.setDefaultAutoSelectFamilyAttemptTimeout(platformTimeout(net.getDefaultAutoSelectFamilyAttemptTimeout() * 10));
|
||||||
const defaultAutoSelectFamilyAttemptTimeout = net.getDefaultAutoSelectFamilyAttemptTimeout();
|
const defaultAutoSelectFamilyAttemptTimeout = net.getDefaultAutoSelectFamilyAttemptTimeout();
|
||||||
@ -243,13 +241,6 @@ function childShouldThrowAndAbort() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function createZeroFilledFile(filename) {
|
|
||||||
const fd = fs.openSync(filename, 'w');
|
|
||||||
fs.ftruncateSync(fd, 10 * 1024 * 1024);
|
|
||||||
fs.closeSync(fd);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const pwdCommand = isWindows ?
|
const pwdCommand = isWindows ?
|
||||||
['cmd.exe', ['/d', '/c', 'cd']] :
|
['cmd.exe', ['/d', '/c', 'cd']] :
|
||||||
['pwd', []];
|
['pwd', []];
|
||||||
@ -716,12 +707,6 @@ function skipIf32Bits() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function skipIfWorker() {
|
|
||||||
if (!isMainThread) {
|
|
||||||
skip('This test only works on a main thread');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getArrayBufferViews(buf) {
|
function getArrayBufferViews(buf) {
|
||||||
const { buffer, byteOffset, byteLength } = buf;
|
const { buffer, byteOffset, byteLength } = buf;
|
||||||
|
|
||||||
@ -806,12 +791,6 @@ function invalidArgTypeHelper(input) {
|
|||||||
return ` Received type ${typeof input} (${inspected})`;
|
return ` Received type ${typeof input} (${inspected})`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function skipIfDumbTerminal() {
|
|
||||||
if (isDumbTerminal) {
|
|
||||||
skip('skipping - dumb terminal');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function requireNoPackageJSONAbove(dir = __dirname) {
|
function requireNoPackageJSONAbove(dir = __dirname) {
|
||||||
let possiblePackage = path.join(dir, '..', 'package.json');
|
let possiblePackage = path.join(dir, '..', 'package.json');
|
||||||
let lastPackage = null;
|
let lastPackage = null;
|
||||||
@ -882,45 +861,6 @@ function escapePOSIXShell(cmdParts, ...args) {
|
|||||||
return [cmd, { env }];
|
return [cmd, { env }];
|
||||||
};
|
};
|
||||||
|
|
||||||
function getPrintedStackTrace(stderr) {
|
|
||||||
const lines = stderr.split('\n');
|
|
||||||
|
|
||||||
let state = 'initial';
|
|
||||||
const result = {
|
|
||||||
message: [],
|
|
||||||
nativeStack: [],
|
|
||||||
jsStack: [],
|
|
||||||
};
|
|
||||||
for (let i = 0; i < lines.length; ++i) {
|
|
||||||
const line = lines[i].trim();
|
|
||||||
if (line.length === 0) {
|
|
||||||
continue; // Skip empty lines.
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (state) {
|
|
||||||
case 'initial':
|
|
||||||
result.message.push(line);
|
|
||||||
if (line.includes('Native stack trace')) {
|
|
||||||
state = 'native-stack';
|
|
||||||
} else {
|
|
||||||
result.message.push(line);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'native-stack':
|
|
||||||
if (line.includes('JavaScript stack trace')) {
|
|
||||||
state = 'js-stack';
|
|
||||||
} else {
|
|
||||||
result.nativeStack.push(line);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'js-stack':
|
|
||||||
result.jsStack.push(line);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check the exports of require(esm).
|
* Check the exports of require(esm).
|
||||||
* TODO(joyeecheung): use it in all the test-require-module-* tests to minimize changes
|
* TODO(joyeecheung): use it in all the test-require-module-* tests to minimize changes
|
||||||
@ -943,7 +883,6 @@ const common = {
|
|||||||
buildType,
|
buildType,
|
||||||
canCreateSymLink,
|
canCreateSymLink,
|
||||||
childShouldThrowAndAbort,
|
childShouldThrowAndAbort,
|
||||||
createZeroFilledFile,
|
|
||||||
defaultAutoSelectFamilyAttemptTimeout,
|
defaultAutoSelectFamilyAttemptTimeout,
|
||||||
escapePOSIXShell,
|
escapePOSIXShell,
|
||||||
expectsError,
|
expectsError,
|
||||||
@ -951,7 +890,6 @@ const common = {
|
|||||||
expectWarning,
|
expectWarning,
|
||||||
getArrayBufferViews,
|
getArrayBufferViews,
|
||||||
getBufferSources,
|
getBufferSources,
|
||||||
getPrintedStackTrace,
|
|
||||||
getTTYfd,
|
getTTYfd,
|
||||||
hasIntl,
|
hasIntl,
|
||||||
hasCrypto,
|
hasCrypto,
|
||||||
@ -960,10 +898,8 @@ const common = {
|
|||||||
isAlive,
|
isAlive,
|
||||||
isASan,
|
isASan,
|
||||||
isDebug,
|
isDebug,
|
||||||
isDumbTerminal,
|
|
||||||
isFreeBSD,
|
isFreeBSD,
|
||||||
isLinux,
|
isLinux,
|
||||||
isMainThread,
|
|
||||||
isOpenBSD,
|
isOpenBSD,
|
||||||
isMacOS,
|
isMacOS,
|
||||||
isPi,
|
isPi,
|
||||||
@ -985,10 +921,8 @@ const common = {
|
|||||||
runWithInvalidFD,
|
runWithInvalidFD,
|
||||||
skip,
|
skip,
|
||||||
skipIf32Bits,
|
skipIf32Bits,
|
||||||
skipIfDumbTerminal,
|
|
||||||
skipIfEslintMissing,
|
skipIfEslintMissing,
|
||||||
skipIfInspectorDisabled,
|
skipIfInspectorDisabled,
|
||||||
skipIfWorker,
|
|
||||||
spawnPromisified,
|
spawnPromisified,
|
||||||
|
|
||||||
get enoughTestMem() {
|
get enoughTestMem() {
|
||||||
|
@ -8,7 +8,6 @@ const {
|
|||||||
buildType,
|
buildType,
|
||||||
canCreateSymLink,
|
canCreateSymLink,
|
||||||
childShouldThrowAndAbort,
|
childShouldThrowAndAbort,
|
||||||
createZeroFilledFile,
|
|
||||||
enoughTestMem,
|
enoughTestMem,
|
||||||
escapePOSIXShell,
|
escapePOSIXShell,
|
||||||
expectsError,
|
expectsError,
|
||||||
@ -21,12 +20,10 @@ const {
|
|||||||
hasIPv6,
|
hasIPv6,
|
||||||
isAIX,
|
isAIX,
|
||||||
isAlive,
|
isAlive,
|
||||||
isDumbTerminal,
|
|
||||||
isFreeBSD,
|
isFreeBSD,
|
||||||
isIBMi,
|
isIBMi,
|
||||||
isInsideDirWithUnusualChars,
|
isInsideDirWithUnusualChars,
|
||||||
isLinux,
|
isLinux,
|
||||||
isMainThread,
|
|
||||||
isOpenBSD,
|
isOpenBSD,
|
||||||
isMacOS,
|
isMacOS,
|
||||||
isSunOS,
|
isSunOS,
|
||||||
@ -45,7 +42,6 @@ const {
|
|||||||
runWithInvalidFD,
|
runWithInvalidFD,
|
||||||
skip,
|
skip,
|
||||||
skipIf32Bits,
|
skipIf32Bits,
|
||||||
skipIfDumbTerminal,
|
|
||||||
skipIfEslintMissing,
|
skipIfEslintMissing,
|
||||||
skipIfInspectorDisabled,
|
skipIfInspectorDisabled,
|
||||||
spawnPromisified,
|
spawnPromisified,
|
||||||
@ -59,7 +55,6 @@ export {
|
|||||||
canCreateSymLink,
|
canCreateSymLink,
|
||||||
childShouldThrowAndAbort,
|
childShouldThrowAndAbort,
|
||||||
createRequire,
|
createRequire,
|
||||||
createZeroFilledFile,
|
|
||||||
enoughTestMem,
|
enoughTestMem,
|
||||||
escapePOSIXShell,
|
escapePOSIXShell,
|
||||||
expectsError,
|
expectsError,
|
||||||
@ -73,12 +68,10 @@ export {
|
|||||||
hasIPv6,
|
hasIPv6,
|
||||||
isAIX,
|
isAIX,
|
||||||
isAlive,
|
isAlive,
|
||||||
isDumbTerminal,
|
|
||||||
isFreeBSD,
|
isFreeBSD,
|
||||||
isIBMi,
|
isIBMi,
|
||||||
isInsideDirWithUnusualChars,
|
isInsideDirWithUnusualChars,
|
||||||
isLinux,
|
isLinux,
|
||||||
isMainThread,
|
|
||||||
isOpenBSD,
|
isOpenBSD,
|
||||||
isMacOS,
|
isMacOS,
|
||||||
isSunOS,
|
isSunOS,
|
||||||
@ -97,7 +90,6 @@ export {
|
|||||||
runWithInvalidFD,
|
runWithInvalidFD,
|
||||||
skip,
|
skip,
|
||||||
skipIf32Bits,
|
skipIf32Bits,
|
||||||
skipIfDumbTerminal,
|
|
||||||
skipIfEslintMissing,
|
skipIfEslintMissing,
|
||||||
skipIfInspectorDisabled,
|
skipIfInspectorDisabled,
|
||||||
spawnPromisified,
|
spawnPromisified,
|
||||||
|
@ -13,8 +13,10 @@ import path from 'path';
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import url from 'url';
|
import url from 'url';
|
||||||
import process from 'process';
|
import process from 'process';
|
||||||
|
import { isMainThread } from 'worker_threads';
|
||||||
|
|
||||||
if (!common.isMainThread) {
|
|
||||||
|
if (!isMainThread) {
|
||||||
common.skip(
|
common.skip(
|
||||||
'test-esm-resolve-type.mjs: process.chdir is not available in Workers'
|
'test-esm-resolve-type.mjs: process.chdir is not available in Workers'
|
||||||
);
|
);
|
||||||
|
@ -3,7 +3,11 @@
|
|||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
|
||||||
// Can't process.chdir() in worker.
|
// Can't process.chdir() in worker.
|
||||||
common.skipIfWorker();
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
|
if (!isMainThread) {
|
||||||
|
common.skip('This test only works on a main thread');
|
||||||
|
}
|
||||||
|
|
||||||
const tmpdir = require('../common/tmpdir');
|
const tmpdir = require('../common/tmpdir');
|
||||||
const fixtures = require('../common/fixtures');
|
const fixtures = require('../common/fixtures');
|
||||||
|
6
test/fixtures/permission/fs-write.js
vendored
6
test/fixtures/permission/fs-write.js
vendored
@ -1,7 +1,11 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../../common');
|
const common = require('../../common');
|
||||||
common.skipIfWorker();
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
|
if (!isMainThread) {
|
||||||
|
common.skip('This test only works on a main thread');
|
||||||
|
}
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
6
test/fixtures/permission/processbinding.js
vendored
6
test/fixtures/permission/processbinding.js
vendored
@ -1,5 +1,9 @@
|
|||||||
const common = require('../../common');
|
const common = require('../../common');
|
||||||
common.skipIfWorker();
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
|
if (!isMainThread) {
|
||||||
|
common.skip('This test only works on a main thread');
|
||||||
|
}
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
|
||||||
|
@ -5,9 +5,11 @@ const cp = require('child_process');
|
|||||||
const tmpdir = require('../common/tmpdir');
|
const tmpdir = require('../common/tmpdir');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const util = require('util');
|
const util = require('util');
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
if (!common.isMainThread)
|
if (!isMainThread) {
|
||||||
common.skip('process.chdir is not available in Workers');
|
common.skip('process.chdir is not available in Workers');
|
||||||
|
}
|
||||||
|
|
||||||
const traceFile = 'node_trace.1.log';
|
const traceFile = 'node_trace.1.log';
|
||||||
|
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const async_hooks = require('async_hooks');
|
const async_hooks = require('async_hooks');
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
if (!common.isMainThread)
|
if (!isMainThread) {
|
||||||
common.skip('Worker bootstrapping works differently -> different AsyncWraps');
|
common.skip('Worker bootstrapping works differently -> different AsyncWraps');
|
||||||
|
}
|
||||||
|
|
||||||
const hook = async_hooks.createHook({
|
const hook = async_hooks.createHook({
|
||||||
init: common.mustCall(2),
|
init: common.mustCall(2),
|
||||||
|
@ -2,9 +2,11 @@
|
|||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const async_hooks = require('async_hooks');
|
const async_hooks = require('async_hooks');
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
if (!common.isMainThread)
|
if (!isMainThread) {
|
||||||
common.skip('Worker bootstrapping works differently -> different async IDs');
|
common.skip('Worker bootstrapping works differently -> different async IDs');
|
||||||
|
}
|
||||||
|
|
||||||
const promiseAsyncIds = [];
|
const promiseAsyncIds = [];
|
||||||
|
|
||||||
|
@ -2,9 +2,11 @@
|
|||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const async_hooks = require('async_hooks');
|
const async_hooks = require('async_hooks');
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
if (!common.isMainThread)
|
if (!isMainThread) {
|
||||||
common.skip('Worker bootstrapping works differently -> different async IDs');
|
common.skip('Worker bootstrapping works differently -> different async IDs');
|
||||||
|
}
|
||||||
|
|
||||||
const initCalls = [];
|
const initCalls = [];
|
||||||
const resolveCalls = [];
|
const resolveCalls = [];
|
||||||
|
@ -5,9 +5,11 @@
|
|||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const async_hooks = require('async_hooks');
|
const async_hooks = require('async_hooks');
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
if (!common.isMainThread)
|
if (!isMainThread) {
|
||||||
common.skip('Worker bootstrapping works differently -> different async IDs');
|
common.skip('Worker bootstrapping works differently -> different async IDs');
|
||||||
|
}
|
||||||
|
|
||||||
let seenId, seenResource;
|
let seenId, seenResource;
|
||||||
|
|
||||||
|
@ -4,9 +4,11 @@
|
|||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
if (!common.isMainThread)
|
if (!isMainThread) {
|
||||||
common.skip('Worker bootstrapping works differently -> different timing');
|
common.skip('Worker bootstrapping works differently -> different timing');
|
||||||
|
}
|
||||||
|
|
||||||
const async_hooks = require('async_hooks');
|
const async_hooks = require('async_hooks');
|
||||||
|
|
||||||
|
@ -115,7 +115,9 @@ expected.atRunTime = new Set([
|
|||||||
'NativeModule internal/modules/esm/utils',
|
'NativeModule internal/modules/esm/utils',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (common.isMainThread) {
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
|
if (isMainThread) {
|
||||||
[
|
[
|
||||||
'NativeModule url',
|
'NativeModule url',
|
||||||
].forEach(expected.beforePreExec.add.bind(expected.beforePreExec));
|
].forEach(expected.beforePreExec.add.bind(expected.beforePreExec));
|
||||||
@ -186,7 +188,7 @@ function err(message) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (common.isMainThread) {
|
if (isMainThread) {
|
||||||
const missing = expected.beforePreExec.difference(actual.beforePreExec);
|
const missing = expected.beforePreExec.difference(actual.beforePreExec);
|
||||||
const extra = actual.beforePreExec.difference(expected.beforePreExec);
|
const extra = actual.beforePreExec.difference(expected.beforePreExec);
|
||||||
if (missing.size !== 0) {
|
if (missing.size !== 0) {
|
||||||
@ -212,10 +214,10 @@ if (common.isMainThread) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!common.isMainThread) {
|
if (!isMainThread) {
|
||||||
// For workers, just merge beforePreExec into atRunTime for now.
|
// For workers, just merge beforePreExec into atRunTime for now.
|
||||||
// When we start adding modules to the worker snapshot, this branch
|
// When we start adding modules to the worker snapshot, this branch
|
||||||
// can be removed and we can just remove the common.isMainThread
|
// can be removed and we can just remove the isMainThread
|
||||||
// conditions.
|
// conditions.
|
||||||
expected.beforePreExec.forEach(expected.atRunTime.add.bind(expected.atRunTime));
|
expected.beforePreExec.forEach(expected.atRunTime.add.bind(expected.atRunTime));
|
||||||
actual.beforePreExec.forEach(actual.atRunTime.add.bind(actual.atRunTime));
|
actual.beforePreExec.forEach(actual.atRunTime.add.bind(actual.atRunTime));
|
||||||
|
@ -43,7 +43,9 @@ assert.throws(() => getValidStdio(stdio2, true),
|
|||||||
assert.throws(() => getValidStdio(stdio), expectedError);
|
assert.throws(() => getValidStdio(stdio), expectedError);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (common.isMainThread) {
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
|
if (isMainThread) {
|
||||||
const stdio3 = [process.stdin, process.stdout, process.stderr];
|
const stdio3 = [process.stdin, process.stdout, process.stderr];
|
||||||
const result = getValidStdio(stdio3, false);
|
const result = getValidStdio(stdio3, false);
|
||||||
assert.deepStrictEqual(result, {
|
assert.deepStrictEqual(result, {
|
||||||
|
@ -1,11 +1,16 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
|
||||||
if (common.isWindows)
|
if (common.isWindows) {
|
||||||
common.skip('On Windows named pipes live in their own ' +
|
common.skip('On Windows named pipes live in their own ' +
|
||||||
'filesystem and don\'t have a ~100 byte limit');
|
'filesystem and don\'t have a ~100 byte limit');
|
||||||
if (!common.isMainThread)
|
}
|
||||||
|
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
|
if (!isMainThread) {
|
||||||
common.skip('process.chdir is not available in Workers');
|
common.skip('process.chdir is not available in Workers');
|
||||||
|
}
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const cluster = require('cluster');
|
const cluster = require('cluster');
|
||||||
|
@ -5,7 +5,8 @@
|
|||||||
// and the cache is used when built in modules are compiled.
|
// and the cache is used when built in modules are compiled.
|
||||||
// Otherwise, verifies that no cache is used when compiling builtins.
|
// Otherwise, verifies that no cache is used when compiling builtins.
|
||||||
|
|
||||||
const { isMainThread } = require('../common');
|
require('../common');
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const {
|
const {
|
||||||
internalBinding
|
internalBinding
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
|
||||||
const stdoutWrite = process.stdout.write;
|
const stdoutWrite = process.stdout.write;
|
||||||
@ -18,7 +18,7 @@ function doTest(isTTY, check) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fake TTY
|
// Fake TTY
|
||||||
if (!common.isDumbTerminal) {
|
if (process.env.TERM !== 'dumb') {
|
||||||
doTest(true, check);
|
doTest(true, check);
|
||||||
}
|
}
|
||||||
doTest(false, '');
|
doTest(false, '');
|
||||||
|
@ -31,10 +31,12 @@ const {
|
|||||||
restoreStderr
|
restoreStderr
|
||||||
} = require('../common/hijackstdio');
|
} = require('../common/hijackstdio');
|
||||||
|
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
assert.ok(process.stdout.writable);
|
assert.ok(process.stdout.writable);
|
||||||
assert.ok(process.stderr.writable);
|
assert.ok(process.stderr.writable);
|
||||||
// Support legacy API
|
// Support legacy API
|
||||||
if (common.isMainThread) {
|
if (isMainThread) {
|
||||||
assert.strictEqual(typeof process.stdout.fd, 'number');
|
assert.strictEqual(typeof process.stdout.fd, 'number');
|
||||||
assert.strictEqual(typeof process.stderr.fd, 'number');
|
assert.strictEqual(typeof process.stderr.fd, 'number');
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,9 @@ if (!hasOpenSSL3)
|
|||||||
|
|
||||||
const assert = require('node:assert/strict');
|
const assert = require('node:assert/strict');
|
||||||
const crypto = require('node:crypto');
|
const crypto = require('node:crypto');
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
if (common.isMainThread) {
|
if (isMainThread) {
|
||||||
// TODO(richardlau): Decide if `crypto.setFips` should error if the
|
// TODO(richardlau): Decide if `crypto.setFips` should error if the
|
||||||
// provider named "fips" is not available.
|
// provider named "fips" is not available.
|
||||||
crypto.setFips(1);
|
crypto.setFips(1);
|
||||||
|
@ -1,10 +1,15 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
// Fails with EINVAL on SmartOS, EBUSY on Windows, EBUSY on AIX.
|
// Fails with EINVAL on SmartOS, EBUSY on Windows, EBUSY on AIX.
|
||||||
if (common.isSunOS || common.isWindows || common.isAIX || common.isIBMi)
|
if (common.isSunOS || common.isWindows || common.isAIX || common.isIBMi) {
|
||||||
common.skip('cannot rmdir current working directory');
|
common.skip('cannot rmdir current working directory');
|
||||||
if (!common.isMainThread)
|
}
|
||||||
|
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
|
if (!isMainThread) {
|
||||||
common.skip('process.chdir is not available in Workers');
|
common.skip('process.chdir is not available in Workers');
|
||||||
|
}
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
@ -1,10 +1,15 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
// Fails with EINVAL on SmartOS, EBUSY on Windows, EBUSY on AIX.
|
// Fails with EINVAL on SmartOS, EBUSY on Windows, EBUSY on AIX.
|
||||||
if (common.isSunOS || common.isWindows || common.isAIX || common.isIBMi)
|
if (common.isSunOS || common.isWindows || common.isAIX || common.isIBMi) {
|
||||||
common.skip('cannot rmdir current working directory');
|
common.skip('cannot rmdir current working directory');
|
||||||
if (!common.isMainThread)
|
}
|
||||||
|
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
|
if (!isMainThread) {
|
||||||
common.skip('process.chdir is not available in Workers');
|
common.skip('process.chdir is not available in Workers');
|
||||||
|
}
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
@ -1,10 +1,15 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
// Fails with EINVAL on SmartOS, EBUSY on Windows, EBUSY on AIX.
|
// Fails with EINVAL on SmartOS, EBUSY on Windows, EBUSY on AIX.
|
||||||
if (common.isSunOS || common.isWindows || common.isAIX || common.isIBMi)
|
if (common.isSunOS || common.isWindows || common.isAIX || common.isIBMi) {
|
||||||
common.skip('cannot rmdir current working directory');
|
common.skip('cannot rmdir current working directory');
|
||||||
if (!common.isMainThread)
|
}
|
||||||
|
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
|
if (!isMainThread) {
|
||||||
common.skip('process.chdir is not available in Workers');
|
common.skip('process.chdir is not available in Workers');
|
||||||
|
}
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
@ -24,6 +24,7 @@ const common = require('../common');
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
const tmpdir = require('../common/tmpdir');
|
const tmpdir = require('../common/tmpdir');
|
||||||
tmpdir.refresh();
|
tmpdir.refresh();
|
||||||
@ -217,7 +218,7 @@ function nextdir() {
|
|||||||
|
|
||||||
// mkdirpSync dirname loop
|
// mkdirpSync dirname loop
|
||||||
// XXX: windows and smartos have issues removing a directory that you're in.
|
// XXX: windows and smartos have issues removing a directory that you're in.
|
||||||
if (common.isMainThread && (common.isLinux || common.isMacOS)) {
|
if (isMainThread && (common.isLinux || common.isMacOS)) {
|
||||||
const pathname = tmpdir.resolve(nextdir());
|
const pathname = tmpdir.resolve(nextdir());
|
||||||
fs.mkdirSync(pathname);
|
fs.mkdirSync(pathname);
|
||||||
process.chdir(pathname);
|
process.chdir(pathname);
|
||||||
|
@ -23,9 +23,11 @@
|
|||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const fixtures = require('../common/fixtures');
|
const fixtures = require('../common/fixtures');
|
||||||
const tmpdir = require('../common/tmpdir');
|
const tmpdir = require('../common/tmpdir');
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
if (!common.isMainThread)
|
if (!isMainThread) {
|
||||||
common.skip('process.chdir is not available in Workers');
|
common.skip('process.chdir is not available in Workers');
|
||||||
|
}
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
@ -5,6 +5,8 @@ const fixtures = require('../common/fixtures');
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const tmpdir = require('../common/tmpdir');
|
const tmpdir = require('../common/tmpdir');
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
tmpdir.refresh();
|
tmpdir.refresh();
|
||||||
|
|
||||||
const url = fixtures.fileURL('a.js');
|
const url = fixtures.fileURL('a.js');
|
||||||
@ -86,7 +88,7 @@ if (common.isWindows) {
|
|||||||
// Test that strings are interpreted as paths and not as URL
|
// Test that strings are interpreted as paths and not as URL
|
||||||
// Can't use process.chdir in Workers
|
// Can't use process.chdir in Workers
|
||||||
// Please avoid testing fs.rmdir('file:') or using it as cleanup
|
// Please avoid testing fs.rmdir('file:') or using it as cleanup
|
||||||
if (common.isMainThread && !common.isWindows) {
|
if (isMainThread && !common.isWindows) {
|
||||||
const oldCwd = process.cwd();
|
const oldCwd = process.cwd();
|
||||||
process.chdir(tmpdir.path);
|
process.chdir(tmpdir.path);
|
||||||
|
|
||||||
|
@ -21,9 +21,11 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
if (!common.isMainThread)
|
if (!isMainThread) {
|
||||||
common.skip('Setting process.umask is not supported in Workers');
|
common.skip('Setting process.umask is not supported in Workers');
|
||||||
|
}
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
// http://groups.google.com/group/nodejs/browse_thread/thread/f66cd3c960406919
|
// http://groups.google.com/group/nodejs/browse_thread/thread/f66cd3c960406919
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
if (!common.hasCrypto)
|
|
||||||
common.skip('missing crypto');
|
|
||||||
|
|
||||||
|
if (!common.hasCrypto) {
|
||||||
|
common.skip('missing crypto');
|
||||||
|
}
|
||||||
|
|
||||||
|
const fs = require('fs');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
|
||||||
if (process.argv[2] === 'request') {
|
if (process.argv[2] === 'request') {
|
||||||
@ -73,7 +76,11 @@ function executeRequest(cb) {
|
|||||||
|
|
||||||
tmpdir.refresh();
|
tmpdir.refresh();
|
||||||
|
|
||||||
common.createZeroFilledFile(filename);
|
|
||||||
|
// Create a zero-filled file.
|
||||||
|
const fd = fs.openSync(filename, 'w');
|
||||||
|
fs.ftruncateSync(fd, 10 * 1024 * 1024);
|
||||||
|
fs.closeSync(fd);
|
||||||
|
|
||||||
server = http.createServer(function(req, res) {
|
server = http.createServer(function(req, res) {
|
||||||
res.writeHead(200);
|
res.writeHead(200);
|
||||||
|
@ -4,7 +4,7 @@ const assert = require('assert');
|
|||||||
const { execFileSync } = require('child_process');
|
const { execFileSync } = require('child_process');
|
||||||
const { readFileSync, globSync } = require('fs');
|
const { readFileSync, globSync } = require('fs');
|
||||||
const { path } = require('../common/fixtures');
|
const { path } = require('../common/fixtures');
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
// This test checks for regressions in environment variable handling and
|
// This test checks for regressions in environment variable handling and
|
||||||
// caching, but the localization data originated from ICU might change
|
// caching, but the localization data originated from ICU might change
|
||||||
@ -169,7 +169,7 @@ if (isMockable) {
|
|||||||
// Tests with process.env mutated inside
|
// Tests with process.env mutated inside
|
||||||
{
|
{
|
||||||
// process.env.TZ is not intercepted in Workers
|
// process.env.TZ is not intercepted in Workers
|
||||||
if (common.isMainThread) {
|
if (isMainThread) {
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
isSet(zones.map((TZ) => runEnvInside({ TZ }, () => new Date(333333333333).toString()))),
|
isSet(zones.map((TZ) => runEnvInside({ TZ }, () => new Date(333333333333).toString()))),
|
||||||
true
|
true
|
||||||
|
@ -3,7 +3,12 @@
|
|||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
common.skipIfInspectorDisabled();
|
common.skipIfInspectorDisabled();
|
||||||
common.skipIfWorker();
|
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
|
if (!isMainThread) {
|
||||||
|
common.skip('This test only works on a main thread');
|
||||||
|
}
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const inspector = require('inspector');
|
const inspector = require('inspector');
|
||||||
|
@ -3,7 +3,12 @@
|
|||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
|
||||||
common.skipIfInspectorDisabled();
|
common.skipIfInspectorDisabled();
|
||||||
common.skipIfWorker();
|
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
|
if (!isMainThread) {
|
||||||
|
common.skip('This test only works on a main thread');
|
||||||
|
}
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const { Worker } = require('worker_threads');
|
const { Worker } = require('worker_threads');
|
||||||
|
@ -6,7 +6,11 @@ common.skipIf32Bits();
|
|||||||
const { NodeInstance } = require('../common/inspector-helper.js');
|
const { NodeInstance } = require('../common/inspector-helper.js');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
|
||||||
common.skipIfWorker(); // Signal starts a server for a main thread inspector
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
|
if (!isMainThread) {
|
||||||
|
common.skip('This test only works on a main thread');
|
||||||
|
}
|
||||||
|
|
||||||
const script = `
|
const script = `
|
||||||
process._rawDebug('Waiting until a signal enables the inspector...');
|
process._rawDebug('Waiting until a signal enables the inspector...');
|
||||||
|
@ -10,8 +10,8 @@ const { pathToFileURL } = require('url');
|
|||||||
const { isMainThread, parentPort, Worker, workerData } =
|
const { isMainThread, parentPort, Worker, workerData } =
|
||||||
require('worker_threads');
|
require('worker_threads');
|
||||||
|
|
||||||
if (!workerData) {
|
if (!workerData && !isMainThread) {
|
||||||
common.skipIfWorker();
|
common.skip('This test only works on a main thread');
|
||||||
}
|
}
|
||||||
|
|
||||||
function toDebug() {
|
function toDebug() {
|
||||||
|
@ -6,8 +6,8 @@ common.skipIfInspectorDisabled();
|
|||||||
const { Session } = require('inspector');
|
const { Session } = require('inspector');
|
||||||
const { Worker, isMainThread, workerData } = require('worker_threads');
|
const { Worker, isMainThread, workerData } = require('worker_threads');
|
||||||
|
|
||||||
if (!workerData) {
|
if (!workerData && !isMainThread) {
|
||||||
common.skipIfWorker();
|
common.skip('This test only works on a main thread');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isMainThread) {
|
if (isMainThread) {
|
||||||
|
@ -9,6 +9,8 @@ const assert = require('assert');
|
|||||||
const vm = require('vm');
|
const vm = require('vm');
|
||||||
const { Session } = require('inspector');
|
const { Session } = require('inspector');
|
||||||
const { gcUntil } = require('../common/gc');
|
const { gcUntil } = require('../common/gc');
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
const session = new Session();
|
const session = new Session();
|
||||||
session.connect();
|
session.connect();
|
||||||
|
|
||||||
@ -34,7 +36,7 @@ async function testContextCreatedAndDestroyed() {
|
|||||||
assert.strictEqual(name.includes(`[${process.pid}]`), true);
|
assert.strictEqual(name.includes(`[${process.pid}]`), true);
|
||||||
} else {
|
} else {
|
||||||
let expects = `${process.argv0}[${process.pid}]`;
|
let expects = `${process.argv0}[${process.pid}]`;
|
||||||
if (!common.isMainThread) {
|
if (!isMainThread) {
|
||||||
expects = `Worker[${require('worker_threads').threadId}]`;
|
expects = `Worker[${require('worker_threads').threadId}]`;
|
||||||
}
|
}
|
||||||
assert.strictEqual(expects, name);
|
assert.strictEqual(expects, name);
|
||||||
|
@ -3,9 +3,15 @@
|
|||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
common.skipIfInspectorDisabled();
|
common.skipIfInspectorDisabled();
|
||||||
|
|
||||||
const { parentPort, workerData, Worker } = require('node:worker_threads');
|
const {
|
||||||
if (!workerData) {
|
isMainThread,
|
||||||
common.skipIfWorker();
|
parentPort,
|
||||||
|
workerData,
|
||||||
|
Worker,
|
||||||
|
} = require('node:worker_threads');
|
||||||
|
|
||||||
|
if (!workerData && !isMainThread) {
|
||||||
|
common.skip('This test only works on a main thread');
|
||||||
}
|
}
|
||||||
|
|
||||||
const inspector = require('node:inspector');
|
const inspector = require('node:inspector');
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
common.skipIfInspectorDisabled();
|
common.skipIfInspectorDisabled();
|
||||||
|
|
||||||
const { workerData, Worker } = require('node:worker_threads');
|
const { isMainThread, workerData, Worker } = require('node:worker_threads');
|
||||||
if (!workerData) {
|
if (!workerData && !isMainThread) {
|
||||||
common.skipIfWorker();
|
common.skip('This test only works on a main thread');
|
||||||
}
|
}
|
||||||
|
|
||||||
const assert = require('node:assert');
|
const assert = require('node:assert');
|
||||||
|
@ -7,7 +7,12 @@ const fixtures = require('../common/fixtures');
|
|||||||
const tmpdir = require('../common/tmpdir');
|
const tmpdir = require('../common/tmpdir');
|
||||||
|
|
||||||
common.skipIfInspectorDisabled();
|
common.skipIfInspectorDisabled();
|
||||||
common.skipIfWorker();
|
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
|
if (!isMainThread) {
|
||||||
|
common.skip('This test only works on a main thread');
|
||||||
|
}
|
||||||
|
|
||||||
tmpdir.refresh();
|
tmpdir.refresh();
|
||||||
|
|
||||||
|
@ -5,7 +5,12 @@
|
|||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
common.skipIfInspectorDisabled();
|
common.skipIfInspectorDisabled();
|
||||||
common.skipIfWorker();
|
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
|
if (!isMainThread) {
|
||||||
|
common.skip('This test only works on a main thread');
|
||||||
|
}
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const inspector = require('inspector');
|
const inspector = require('inspector');
|
||||||
|
@ -13,9 +13,11 @@
|
|||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
if (!common.isMainThread)
|
if (!isMainThread) {
|
||||||
common.skip('--require does not work with Workers');
|
common.skip('--require does not work with Workers');
|
||||||
|
}
|
||||||
|
|
||||||
const inspector = require('inspector');
|
const inspector = require('inspector');
|
||||||
const msg = 'Test inspector logging';
|
const msg = 'Test inspector logging';
|
||||||
|
@ -3,7 +3,12 @@
|
|||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
|
||||||
common.skipIfInspectorDisabled();
|
common.skipIfInspectorDisabled();
|
||||||
common.skipIfWorker();
|
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
|
if (!isMainThread) {
|
||||||
|
common.skip('This test only works on a main thread');
|
||||||
|
}
|
||||||
|
|
||||||
// Assert that even when started with `--inspect=0` workers are assigned
|
// Assert that even when started with `--inspect=0` workers are assigned
|
||||||
// consecutive (i.e. deterministically predictable) debug ports
|
// consecutive (i.e. deterministically predictable) debug ports
|
||||||
|
@ -3,7 +3,13 @@
|
|||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
|
||||||
common.skipIfInspectorDisabled();
|
common.skipIfInspectorDisabled();
|
||||||
common.skipIfWorker(); // https://github.com/nodejs/node/issues/22767
|
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
|
if (!isMainThread) {
|
||||||
|
// https://github.com/nodejs/node/issues/22767
|
||||||
|
common.skip('This test only works on a main thread');
|
||||||
|
}
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const { Session } = require('inspector');
|
const { Session } = require('inspector');
|
||||||
|
@ -6,8 +6,8 @@ common.skipIfInspectorDisabled();
|
|||||||
const { Worker, isMainThread, parentPort, workerData } =
|
const { Worker, isMainThread, parentPort, workerData } =
|
||||||
require('worker_threads');
|
require('worker_threads');
|
||||||
|
|
||||||
if (isMainThread || workerData !== 'launched by test') {
|
if (!isMainThread || workerData !== 'launched by test') {
|
||||||
common.skipIfWorker();
|
common.skip('This test only works on a main thread');
|
||||||
}
|
}
|
||||||
|
|
||||||
const { Session } = require('inspector');
|
const { Session } = require('inspector');
|
||||||
|
@ -8,8 +8,9 @@
|
|||||||
// 3. Deprecated modules are properly deprecated.
|
// 3. Deprecated modules are properly deprecated.
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
if (!common.isMainThread) {
|
if (!isMainThread) {
|
||||||
common.skip('Cannot test the existence of --expose-internals from worker');
|
common.skip('Cannot test the existence of --expose-internals from worker');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
common.skipIfWorker();
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
|
if (!isMainThread) {
|
||||||
|
common.skip('This test only works on a main thread');
|
||||||
|
}
|
||||||
|
|
||||||
const { spawnSync } = require('node:child_process');
|
const { spawnSync } = require('node:child_process');
|
||||||
const assert = require('node:assert');
|
const assert = require('node:assert');
|
||||||
|
@ -2,7 +2,11 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
common.skipIfWorker();
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
|
if (!isMainThread) {
|
||||||
|
common.skip('This test only works on a main thread');
|
||||||
|
}
|
||||||
|
|
||||||
const { createRequire } = require('node:module');
|
const { createRequire } = require('node:module');
|
||||||
const assert = require('node:assert');
|
const assert = require('node:assert');
|
||||||
|
@ -2,7 +2,13 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
common.skipIfWorker();
|
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
|
if (!isMainThread) {
|
||||||
|
common.skip('This test only works on a main thread');
|
||||||
|
}
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const childProcess = require('child_process');
|
const childProcess = require('child_process');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
@ -2,7 +2,11 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
common.skipIfWorker();
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
|
if (!isMainThread) {
|
||||||
|
common.skip('This test only works on a main thread');
|
||||||
|
}
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const { WASI } = require('wasi');
|
const { WASI } = require('wasi');
|
||||||
|
@ -2,7 +2,12 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
common.skipIfWorker();
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
|
if (!isMainThread) {
|
||||||
|
common.skip('This test only works on a main thread');
|
||||||
|
}
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const childProcess = require('child_process');
|
const childProcess = require('child_process');
|
||||||
|
|
||||||
|
@ -3,7 +3,11 @@
|
|||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
common.skipIfWorker();
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
|
if (!isMainThread) {
|
||||||
|
common.skip('This test only works on a main thread');
|
||||||
|
}
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const { spawnSync } = require('child_process');
|
const { spawnSync } = require('child_process');
|
||||||
|
@ -2,7 +2,11 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
common.skipIfWorker();
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
|
if (!isMainThread) {
|
||||||
|
common.skip('This test only works on a main thread');
|
||||||
|
}
|
||||||
|
|
||||||
if (!common.hasCrypto) {
|
if (!common.hasCrypto) {
|
||||||
common.skip('no crypto');
|
common.skip('no crypto');
|
||||||
|
@ -2,7 +2,11 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
common.skipIfWorker();
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
|
if (!isMainThread) {
|
||||||
|
common.skip('This test only works on a main thread');
|
||||||
|
}
|
||||||
|
|
||||||
if (!common.hasCrypto) {
|
if (!common.hasCrypto) {
|
||||||
common.skip('no crypto');
|
common.skip('no crypto');
|
||||||
|
@ -2,7 +2,11 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
common.skipIfWorker();
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
|
if (!isMainThread) {
|
||||||
|
common.skip('This test only works on a main thread');
|
||||||
|
}
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const { spawnSync } = require('child_process');
|
const { spawnSync } = require('child_process');
|
||||||
|
@ -3,7 +3,11 @@
|
|||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
common.skipIfWorker();
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
|
if (!isMainThread) {
|
||||||
|
common.skip('This test only works on a main thread');
|
||||||
|
}
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const { spawnSync } = require('child_process');
|
const { spawnSync } = require('child_process');
|
||||||
|
@ -2,7 +2,13 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
common.skipIfWorker();
|
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
|
if (!isMainThread) {
|
||||||
|
common.skip('This test only works on a main thread');
|
||||||
|
}
|
||||||
|
|
||||||
const fixtures = require('../common/fixtures');
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
const assert = require('node:assert');
|
const assert = require('node:assert');
|
||||||
|
@ -2,7 +2,12 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
common.skipIfWorker();
|
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
|
if (!isMainThread) {
|
||||||
|
common.skip('This test only works on a main thread');
|
||||||
|
}
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
@ -2,11 +2,19 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
common.skipIfWorker();
|
const { isMainThread } = require('worker_threads');
|
||||||
if (!common.canCreateSymLink())
|
|
||||||
|
if (!isMainThread) {
|
||||||
|
common.skip('This test only works on a main thread');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!common.canCreateSymLink()) {
|
||||||
common.skip('insufficient privileges');
|
common.skip('insufficient privileges');
|
||||||
if (!common.hasCrypto)
|
}
|
||||||
|
|
||||||
|
if (!common.hasCrypto) {
|
||||||
common.skip('no crypto');
|
common.skip('no crypto');
|
||||||
|
}
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
@ -15,9 +23,7 @@ const tmpdir = require('../common/tmpdir');
|
|||||||
const fixtures = require('../common/fixtures');
|
const fixtures = require('../common/fixtures');
|
||||||
const { spawnSync } = require('child_process');
|
const { spawnSync } = require('child_process');
|
||||||
|
|
||||||
{
|
tmpdir.refresh();
|
||||||
tmpdir.refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
const readOnlyFolder = tmpdir.resolve('read-only');
|
const readOnlyFolder = tmpdir.resolve('read-only');
|
||||||
const readWriteFolder = tmpdir.resolve('read-write');
|
const readWriteFolder = tmpdir.resolve('read-write');
|
||||||
|
@ -2,13 +2,19 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
common.skipIfWorker();
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
|
if (!isMainThread) {
|
||||||
|
common.skip('This test only works on a main thread');
|
||||||
|
}
|
||||||
|
|
||||||
const fixtures = require('../common/fixtures');
|
const fixtures = require('../common/fixtures');
|
||||||
if (!common.canCreateSymLink())
|
if (!common.canCreateSymLink()) {
|
||||||
common.skip('insufficient privileges');
|
common.skip('insufficient privileges');
|
||||||
if (!common.hasCrypto)
|
}
|
||||||
|
if (!common.hasCrypto) {
|
||||||
common.skip('no crypto');
|
common.skip('no crypto');
|
||||||
|
}
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
@ -2,13 +2,20 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
common.skipIfWorker();
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
|
if (!isMainThread) {
|
||||||
|
common.skip('This test only works on a main thread');
|
||||||
|
}
|
||||||
|
|
||||||
const fixtures = require('../common/fixtures');
|
const fixtures = require('../common/fixtures');
|
||||||
if (!common.canCreateSymLink())
|
if (!common.canCreateSymLink()) {
|
||||||
common.skip('insufficient privileges');
|
common.skip('insufficient privileges');
|
||||||
if (!common.hasCrypto)
|
}
|
||||||
|
|
||||||
|
if (!common.hasCrypto) {
|
||||||
common.skip('no crypto');
|
common.skip('no crypto');
|
||||||
|
}
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
@ -2,7 +2,11 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
common.skipIfWorker();
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
|
if (!isMainThread) {
|
||||||
|
common.skip('This test only works on a main thread');
|
||||||
|
}
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
@ -2,7 +2,11 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
common.skipIfWorker();
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
|
if (!isMainThread) {
|
||||||
|
common.skip('This test only works on a main thread');
|
||||||
|
}
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const { spawnSync } = require('child_process');
|
const { spawnSync } = require('child_process');
|
||||||
|
@ -2,9 +2,15 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
common.skipIfWorker();
|
const { isMainThread } = require('worker_threads');
|
||||||
if (!common.hasCrypto)
|
|
||||||
|
if (!isMainThread) {
|
||||||
|
common.skip('This test only works on a main thread');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!common.hasCrypto) {
|
||||||
common.skip('no crypto');
|
common.skip('no crypto');
|
||||||
|
}
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
|
||||||
|
@ -2,9 +2,15 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
common.skipIfWorker();
|
const { isMainThread } = require('worker_threads');
|
||||||
if (!common.hasCrypto)
|
|
||||||
|
if (!isMainThread) {
|
||||||
|
common.skip('This test only works on a main thread');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!common.hasCrypto) {
|
||||||
common.skip('no crypto');
|
common.skip('no crypto');
|
||||||
|
}
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const v8 = require('v8');
|
const v8 = require('v8');
|
||||||
|
@ -2,9 +2,15 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
common.skipIfWorker();
|
const { isMainThread } = require('worker_threads');
|
||||||
if (!common.hasCrypto)
|
|
||||||
|
if (!isMainThread) {
|
||||||
|
common.skip('This test only works on a main thread');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!common.hasCrypto) {
|
||||||
common.skip('no crypto');
|
common.skip('no crypto');
|
||||||
|
}
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
@ -5,8 +5,12 @@ const assert = require('assert');
|
|||||||
const { spawnSync } = require('child_process');
|
const { spawnSync } = require('child_process');
|
||||||
const fixtures = require('../common/fixtures');
|
const fixtures = require('../common/fixtures');
|
||||||
const file = fixtures.path('permission', 'inspector-brk.js');
|
const file = fixtures.path('permission', 'inspector-brk.js');
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
|
if (!isMainThread) {
|
||||||
|
common.skip('This test only works on a main thread');
|
||||||
|
}
|
||||||
|
|
||||||
common.skipIfWorker();
|
|
||||||
common.skipIfInspectorDisabled();
|
common.skipIfInspectorDisabled();
|
||||||
|
|
||||||
// See https://github.com/nodejs/node/issues/53385
|
// See https://github.com/nodejs/node/issues/53385
|
||||||
|
@ -2,7 +2,12 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
common.skipIfWorker();
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
|
if (!isMainThread) {
|
||||||
|
common.skip('This test only works on a main thread');
|
||||||
|
}
|
||||||
|
|
||||||
common.skipIfInspectorDisabled();
|
common.skipIfInspectorDisabled();
|
||||||
|
|
||||||
const { Session } = require('inspector');
|
const { Session } = require('inspector');
|
||||||
|
@ -2,7 +2,11 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
common.skipIfWorker();
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
|
if (!isMainThread) {
|
||||||
|
common.skip('This test only works on a main thread');
|
||||||
|
}
|
||||||
|
|
||||||
const { createRequire } = require('node:module');
|
const { createRequire } = require('node:module');
|
||||||
const assert = require('node:assert');
|
const assert = require('node:assert');
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
common.skipIfWorker();
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
|
if (!isMainThread) {
|
||||||
|
common.skip('This test only works on a main thread');
|
||||||
|
}
|
||||||
|
|
||||||
if (!common.hasCrypto) {
|
if (!common.hasCrypto) {
|
||||||
common.skip('no crypto');
|
common.skip('no crypto');
|
||||||
|
@ -2,13 +2,17 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
common.skipIfWorker();
|
|
||||||
const assert = require('assert');
|
|
||||||
const {
|
const {
|
||||||
Worker,
|
Worker,
|
||||||
isMainThread,
|
isMainThread,
|
||||||
} = require('worker_threads');
|
} = require('worker_threads');
|
||||||
|
|
||||||
|
if (!isMainThread) {
|
||||||
|
common.skip('This test only works on a main thread');
|
||||||
|
}
|
||||||
|
|
||||||
|
const assert = require('assert');
|
||||||
|
|
||||||
// Guarantee the initial state
|
// Guarantee the initial state
|
||||||
{
|
{
|
||||||
assert.ok(!process.permission.has('worker'));
|
assert.ok(!process.permission.has('worker'));
|
||||||
|
@ -54,7 +54,12 @@ const server = http.createServer((req, res) => {
|
|||||||
server.listen(0);
|
server.listen(0);
|
||||||
|
|
||||||
server.on('listening', () => {
|
server.on('listening', () => {
|
||||||
common.createZeroFilledFile(filename);
|
|
||||||
|
// Create a zero-filled file
|
||||||
|
const fd = fs.openSync(filename, 'w');
|
||||||
|
fs.ftruncateSync(fd, 10 * 1024 * 1024);
|
||||||
|
fs.closeSync(fd);
|
||||||
|
|
||||||
makeRequest();
|
makeRequest();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -4,11 +4,13 @@ const common = require('../common');
|
|||||||
const fixtures = require('../common/fixtures');
|
const fixtures = require('../common/fixtures');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const { exec } = require('child_process');
|
const { exec } = require('child_process');
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
const nodeBinary = process.argv[0];
|
const nodeBinary = process.argv[0];
|
||||||
|
|
||||||
if (!common.isMainThread)
|
if (!isMainThread) {
|
||||||
common.skip('process.chdir is not available in Workers');
|
common.skip('process.chdir is not available in Workers');
|
||||||
|
}
|
||||||
|
|
||||||
const selfRefModule = fixtures.path('self_ref_module');
|
const selfRefModule = fixtures.path('self_ref_module');
|
||||||
const fixtureA = fixtures.path('printA.js');
|
const fixtureA = fixtures.path('printA.js');
|
||||||
|
@ -2,9 +2,11 @@
|
|||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
if (!common.isMainThread)
|
if (!isMainThread) {
|
||||||
common.skip('process.abort() is not available in Workers');
|
common.skip('process.abort() is not available in Workers');
|
||||||
|
}
|
||||||
|
|
||||||
// Check that our built-in methods do not have a prototype/constructor behaviour
|
// Check that our built-in methods do not have a prototype/constructor behaviour
|
||||||
// if they don't need to. This could be tested for any of our C++ methods.
|
// if they don't need to. This could be tested for any of our C++ methods.
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
common.skipIfWorker();
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
|
if (!isMainThread) {
|
||||||
|
common.skip('This test only works on a main thread');
|
||||||
|
}
|
||||||
|
|
||||||
// Test that 'exit' is emitted if 'beforeExit' throws.
|
// Test that 'exit' is emitted if 'beforeExit' throws.
|
||||||
|
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
if (!common.isMainThread)
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
|
if (!isMainThread) {
|
||||||
common.skip('process.chdir is not available in Workers');
|
common.skip('process.chdir is not available in Workers');
|
||||||
|
}
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
|
||||||
assert.throws(
|
assert.throws(
|
||||||
|
@ -4,9 +4,11 @@ const common = require('../common');
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
if (!common.isMainThread)
|
if (!isMainThread) {
|
||||||
common.skip('process.chdir is not available in Workers');
|
common.skip('process.chdir is not available in Workers');
|
||||||
|
}
|
||||||
|
|
||||||
const tmpdir = require('../common/tmpdir');
|
const tmpdir = require('../common/tmpdir');
|
||||||
|
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
if (!common.isMainThread)
|
if (!isMainThread) {
|
||||||
common.skip('process.env.TZ is not intercepted in Workers');
|
common.skip('process.env.TZ is not intercepted in Workers');
|
||||||
|
}
|
||||||
|
|
||||||
if (common.isWindows) // Using a different TZ format.
|
if (common.isWindows) { // Using a different TZ format.
|
||||||
common.skip('todo: test on Windows');
|
common.skip('todo: test on Windows');
|
||||||
|
}
|
||||||
|
|
||||||
const date = new Date('2018-04-14T12:34:56.789Z');
|
const date = new Date('2018-04-14T12:34:56.789Z');
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
if (common.isWindows) {
|
if (common.isWindows) {
|
||||||
assert.strictEqual(process.geteuid, undefined);
|
assert.strictEqual(process.geteuid, undefined);
|
||||||
assert.strictEqual(process.getegid, undefined);
|
assert.strictEqual(process.getegid, undefined);
|
||||||
@ -11,8 +13,9 @@ if (common.isWindows) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!common.isMainThread)
|
if (!isMainThread) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
assert.throws(() => {
|
assert.throws(() => {
|
||||||
process.seteuid({});
|
process.seteuid({});
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
if (!common.isMainThread)
|
if (!isMainThread) {
|
||||||
common.skip('execArgv does not affect Workers');
|
common.skip('execArgv does not affect Workers');
|
||||||
|
}
|
||||||
|
|
||||||
// This test ensures that no asynchronous operations are performed in the 'exit'
|
// This test ensures that no asynchronous operations are performed in the 'exit'
|
||||||
// handler.
|
// handler.
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { isMainThread, hasCrypto, hasIntl } from '../common/index.mjs';
|
import { hasCrypto, hasIntl } from '../common/index.mjs';
|
||||||
import assert from 'node:assert';
|
import assert from 'node:assert';
|
||||||
import { builtinModules } from 'node:module';
|
import { builtinModules } from 'node:module';
|
||||||
|
import { isMainThread } from 'node:worker_threads';
|
||||||
|
|
||||||
for (const invalid of [1, undefined, null, false, [], {}, () => {}, Symbol('test')]) {
|
for (const invalid of [1, undefined, null, false, [], {}, () => {}, Symbol('test')]) {
|
||||||
assert.throws(() => process.getBuiltinModule(invalid), { code: 'ERR_INVALID_ARG_TYPE' });
|
assert.throws(() => process.getBuiltinModule(invalid), { code: 'ERR_INVALID_ARG_TYPE' });
|
||||||
|
@ -7,8 +7,11 @@ if (common.isWindows) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!common.isMainThread)
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
|
if (!isMainThread) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
[undefined, null, true, {}, [], () => {}].forEach((val) => {
|
[undefined, null, true, {}, [], () => {}].forEach((val) => {
|
||||||
assert.throws(
|
assert.throws(
|
||||||
|
@ -5,6 +5,7 @@ const fixtures = require('../../test/common/fixtures');
|
|||||||
const assert = require('node:assert');
|
const assert = require('node:assert');
|
||||||
const { describe, it } = require('node:test');
|
const { describe, it } = require('node:test');
|
||||||
const { join } = require('node:path');
|
const { join } = require('node:path');
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
const basicValidEnvFilePath = fixtures.path('dotenv/basic-valid.env');
|
const basicValidEnvFilePath = fixtures.path('dotenv/basic-valid.env');
|
||||||
const validEnvFilePath = fixtures.path('dotenv/valid.env');
|
const validEnvFilePath = fixtures.path('dotenv/valid.env');
|
||||||
@ -58,7 +59,7 @@ describe('process.loadEnvFile()', () => {
|
|||||||
const originalCwd = process.cwd();
|
const originalCwd = process.cwd();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (common.isMainThread) {
|
if (isMainThread) {
|
||||||
process.chdir(join(originalCwd, 'lib'));
|
process.chdir(join(originalCwd, 'lib'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +67,7 @@ describe('process.loadEnvFile()', () => {
|
|||||||
process.loadEnvFile();
|
process.loadEnvFile();
|
||||||
}, { code: 'ENOENT', syscall: 'open', path: '.env' });
|
}, { code: 'ENOENT', syscall: 'open', path: '.env' });
|
||||||
} finally {
|
} finally {
|
||||||
if (common.isMainThread) {
|
if (isMainThread) {
|
||||||
process.chdir(originalCwd);
|
process.chdir(originalCwd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,16 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
const { isMainThread } = require('worker_threads');
|
||||||
|
|
||||||
if (common.isWindows) {
|
if (common.isWindows) {
|
||||||
assert.strictEqual(process.setgroups, undefined);
|
assert.strictEqual(process.setgroups, undefined);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!common.isMainThread)
|
if (!isMainThread) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
assert.throws(
|
assert.throws(
|
||||||
() => {
|
() => {
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user