summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/parallel/test-trace-events-all.js10
-rw-r--r--test/parallel/test-trace-events-api.js3
-rw-r--r--test/parallel/test-trace-events-async-hooks.js10
-rw-r--r--test/parallel/test-trace-events-binding.js10
-rw-r--r--test/parallel/test-trace-events-bootstrap.js7
-rw-r--r--test/parallel/test-trace-events-category-used.js10
-rw-r--r--test/parallel/test-trace-events-file-pattern.js10
-rw-r--r--test/parallel/test-trace-events-fs-sync.js9
-rw-r--r--test/parallel/test-trace-events-metadata.js10
-rw-r--r--test/parallel/test-trace-events-none.js10
-rw-r--r--test/parallel/test-trace-events-perf.js7
-rw-r--r--test/parallel/test-trace-events-process-exit.js12
-rw-r--r--test/parallel/test-trace-events-promises.js7
-rw-r--r--test/parallel/test-trace-events-v8.js10
-rw-r--r--test/parallel/test-trace-events-vm.js7
15 files changed, 48 insertions, 84 deletions
diff --git a/test/parallel/test-trace-events-all.js b/test/parallel/test-trace-events-all.js
index 7434715973..d0cdd4a874 100644
--- a/test/parallel/test-trace-events-all.js
+++ b/test/parallel/test-trace-events-all.js
@@ -3,20 +3,18 @@ const common = require('../common');
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 path = require('path');
const CODE =
'setTimeout(() => { for (var i = 0; i < 100000; i++) { "test" + i } }, 1)';
-const FILE_NAME = 'node_trace.1.log';
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
-process.chdir(tmpdir.path);
+const FILE_NAME = path.join(tmpdir.path, 'node_trace.1.log');
const proc = cp.spawn(process.execPath,
- [ '--trace-events-enabled', '-e', CODE ]);
+ [ '--trace-events-enabled', '-e', CODE ],
+ { cwd: tmpdir.path });
proc.once('exit', common.mustCall(() => {
assert(fs.existsSync(FILE_NAME));
diff --git a/test/parallel/test-trace-events-api.js b/test/parallel/test-trace-events-api.js
index f7d7ec35b0..2810ac0dd0 100644
--- a/test/parallel/test-trace-events-api.js
+++ b/test/parallel/test-trace-events-api.js
@@ -5,8 +5,7 @@ const common = require('../common');
if (!process.binding('config').hasTracing)
common.skip('missing trace events');
-if (!common.isMainThread)
- common.skip('process.chdir is not available in Workers');
+common.skipIfWorker(); // https://github.com/nodejs/node/issues/22767
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 7c82eb9364..09017e4774 100644
--- a/test/parallel/test-trace-events-async-hooks.js
+++ b/test/parallel/test-trace-events-async-hooks.js
@@ -3,22 +3,20 @@ const common = require('../common');
const assert = require('assert');
const cp = require('child_process');
const fs = require('fs');
+const path = require('path');
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';
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
-process.chdir(tmpdir.path);
+const FILE_NAME = path.join(tmpdir.path, 'node_trace.1.log');
const proc = cp.spawn(process.execPath,
[ '--trace-event-categories', 'node.async_hooks',
- '-e', CODE ]);
+ '-e', CODE ],
+ { cwd: tmpdir.path });
proc.once('exit', common.mustCall(() => {
assert(fs.existsSync(FILE_NAME));
diff --git a/test/parallel/test-trace-events-binding.js b/test/parallel/test-trace-events-binding.js
index 163d9c4cbd..a6994d47b3 100644
--- a/test/parallel/test-trace-events-binding.js
+++ b/test/parallel/test-trace-events-binding.js
@@ -3,9 +3,7 @@ const common = require('../common');
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 path = require('path');
const CODE = `
const { internalBinding } = require('internal/test/binding');
@@ -18,17 +16,17 @@ const CODE = `
trace('b'.charCodeAt(0), 'missing',
'type-value', 10, {'extra-value': 20 });
`;
-const FILE_NAME = 'node_trace.1.log';
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
-process.chdir(tmpdir.path);
+const FILE_NAME = path.join(tmpdir.path, 'node_trace.1.log');
const proc = cp.spawn(process.execPath,
[ '--trace-event-categories', 'custom',
'--no-warnings',
'--expose-internals',
- '-e', CODE ]);
+ '-e', CODE ],
+ { cwd: tmpdir.path });
proc.once('exit', common.mustCall(() => {
assert(fs.existsSync(FILE_NAME));
diff --git a/test/parallel/test-trace-events-bootstrap.js b/test/parallel/test-trace-events-bootstrap.js
index 8d5e00f00f..087fbd2f18 100644
--- a/test/parallel/test-trace-events-bootstrap.js
+++ b/test/parallel/test-trace-events-bootstrap.js
@@ -2,13 +2,10 @@
const common = require('../common');
const assert = require('assert');
const cp = require('child_process');
-const path = require('path');
const fs = require('fs');
+const path = require('path');
const tmpdir = require('../common/tmpdir');
-if (!common.isMainThread)
- common.skip('process.chdir is not available in Workers');
-
const names = [
'environment',
'nodeStart',
@@ -30,10 +27,10 @@ if (process.argv[2] === 'child') {
1 + 1;
} else {
tmpdir.refresh();
- process.chdir(tmpdir.path);
const proc = cp.fork(__filename,
[ 'child' ], {
+ cwd: tmpdir.path,
execArgv: [
'--trace-event-categories',
'node.bootstrap'
diff --git a/test/parallel/test-trace-events-category-used.js b/test/parallel/test-trace-events-category-used.js
index 249ccd4aa3..bedc27bac4 100644
--- a/test/parallel/test-trace-events-category-used.js
+++ b/test/parallel/test-trace-events-category-used.js
@@ -3,9 +3,6 @@ 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 = `
const { internalBinding } = require('internal/test/binding');
const { isTraceCategoryEnabled } = internalBinding('trace_events');
@@ -16,7 +13,6 @@ const CODE = `
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
-process.chdir(tmpdir.path);
const procEnabled = cp.spawn(
process.execPath,
@@ -25,7 +21,8 @@ const procEnabled = cp.spawn(
// emits a warning.
'--no-warnings',
'--expose-internals',
- '-e', CODE ]
+ '-e', CODE ],
+ { cwd: tmpdir.path }
);
let procEnabledOutput = '';
@@ -42,7 +39,8 @@ const procDisabled = cp.spawn(
// emits a warning.
'--no-warnings',
'--expose-internals',
- '-e', CODE ]
+ '-e', CODE ],
+ { cwd: tmpdir.path }
);
let procDisabledOutput = '';
diff --git a/test/parallel/test-trace-events-file-pattern.js b/test/parallel/test-trace-events-file-pattern.js
index 60a3296c64..a60559b7f9 100644
--- a/test/parallel/test-trace-events-file-pattern.js
+++ b/test/parallel/test-trace-events-file-pattern.js
@@ -4,12 +4,9 @@ const tmpdir = require('../common/tmpdir');
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 path = require('path');
tmpdir.refresh();
-process.chdir(tmpdir.path);
const CODE =
'setTimeout(() => { for (var i = 0; i < 100000; i++) { "test" + i } }, 1)';
@@ -20,10 +17,11 @@ const proc = cp.spawn(process.execPath, [
// eslint-disable-next-line no-template-curly-in-string
'${pid}-${rotation}-${pid}-${rotation}.tracing.log',
'-e', CODE
-]);
+], { cwd: tmpdir.path });
proc.once('exit', common.mustCall(() => {
- const expectedFilename = `${proc.pid}-1-${proc.pid}-1.tracing.log`;
+ const expectedFilename = path.join(tmpdir.path,
+ `${proc.pid}-1-${proc.pid}-1.tracing.log`);
assert(fs.existsSync(expectedFilename));
fs.readFile(expectedFilename, common.mustCall((err, data) => {
diff --git a/test/parallel/test-trace-events-fs-sync.js b/test/parallel/test-trace-events-fs-sync.js
index 54222bcb33..d8e9ca30a8 100644
--- a/test/parallel/test-trace-events-fs-sync.js
+++ b/test/parallel/test-trace-events-fs-sync.js
@@ -3,13 +3,10 @@ const common = require('../common');
const assert = require('assert');
const cp = require('child_process');
const fs = require('fs');
+const path = require('path');
const util = require('util');
-if (!common.isMainThread)
- common.skip('process.chdir is not available in Workers');
-
const tests = new Array();
-const traceFile = 'node_trace.1.log';
let gid = 1;
let uid = 1;
@@ -119,14 +116,14 @@ if (common.canCreateSymLink()) {
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
-process.chdir(tmpdir.path);
+const traceFile = path.join(tmpdir.path, 'node_trace.1.log');
for (const tr in tests) {
const proc = cp.spawnSync(process.execPath,
[ '--trace-events-enabled',
'--trace-event-categories', 'node.fs.sync',
'-e', tests[tr] ],
- { encoding: 'utf8' });
+ { cwd: tmpdir.path, encoding: 'utf8' });
// Some AIX versions don't support futimes or utimes, so skip.
if (common.isAIX && proc.status !== 0 && tr === 'fs.sync.futimes') {
continue;
diff --git a/test/parallel/test-trace-events-metadata.js b/test/parallel/test-trace-events-metadata.js
index 0857d9c099..951f398404 100644
--- a/test/parallel/test-trace-events-metadata.js
+++ b/test/parallel/test-trace-events-metadata.js
@@ -3,23 +3,21 @@ const common = require('../common');
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 path = require('path');
const CODE =
'setTimeout(() => { for (var i = 0; i < 100000; i++) { "test" + i } }, 1);' +
'process.title = "foo"';
-const FILE_NAME = 'node_trace.1.log';
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
-process.chdir(tmpdir.path);
+const FILE_NAME = path.join(tmpdir.path, 'node_trace.1.log');
const proc = cp.spawn(process.execPath,
[ '--trace-event-categories', 'node.perf.usertiming',
'--title=bar',
- '-e', CODE ]);
+ '-e', CODE ],
+ { cwd: tmpdir.path });
proc.once('exit', common.mustCall(() => {
assert(fs.existsSync(FILE_NAME));
fs.readFile(FILE_NAME, common.mustCall((err, data) => {
diff --git a/test/parallel/test-trace-events-none.js b/test/parallel/test-trace-events-none.js
index 4c2fe0ca21..dfe77e4b39 100644
--- a/test/parallel/test-trace-events-none.js
+++ b/test/parallel/test-trace-events-none.js
@@ -3,21 +3,19 @@ const common = require('../common');
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 path = require('path');
const CODE =
'setTimeout(() => { for (var i = 0; i < 100000; i++) { "test" + i } }, 1)';
-const FILE_NAME = 'node_trace.1.log';
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
-process.chdir(tmpdir.path);
+const FILE_NAME = path.join(tmpdir.path, 'node_trace.1.log');
const proc_no_categories = cp.spawn(
process.execPath,
- [ '--trace-event-categories', '""', '-e', CODE ]
+ [ '--trace-event-categories', '""', '-e', CODE ],
+ { cwd: tmpdir.path }
);
proc_no_categories.once('exit', common.mustCall(() => {
diff --git a/test/parallel/test-trace-events-perf.js b/test/parallel/test-trace-events-perf.js
index 27eef28fb1..2403a8078a 100644
--- a/test/parallel/test-trace-events-perf.js
+++ b/test/parallel/test-trace-events-perf.js
@@ -2,13 +2,10 @@
const common = require('../common');
const assert = require('assert');
const cp = require('child_process');
-const path = require('path');
const fs = require('fs');
+const path = require('path');
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');
@@ -25,7 +22,6 @@ if (process.argv[2] === 'child') {
ff(); // Will emit a timerify trace event
} else {
tmpdir.refresh();
- process.chdir(tmpdir.path);
const expectedMarks = ['A', 'B'];
const expectedBegins = [
@@ -41,6 +37,7 @@ if (process.argv[2] === 'child') {
[
'child'
], {
+ cwd: tmpdir.path,
execArgv: [
'--trace-event-categories',
'node.perf'
diff --git a/test/parallel/test-trace-events-process-exit.js b/test/parallel/test-trace-events-process-exit.js
index 254963c2d3..1a39b889a3 100644
--- a/test/parallel/test-trace-events-process-exit.js
+++ b/test/parallel/test-trace-events-process-exit.js
@@ -3,20 +3,16 @@ const common = require('../common');
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 path = require('path');
const tmpdir = require('../common/tmpdir');
-
-const FILE_NAME = 'node_trace.1.log';
-
tmpdir.refresh();
-process.chdir(tmpdir.path);
+const FILE_NAME = path.join(tmpdir.path, 'node_trace.1.log');
const proc = cp.spawn(process.execPath,
[ '--trace-events-enabled',
- '-e', 'process.exit()' ]);
+ '-e', 'process.exit()' ],
+ { cwd: tmpdir.path });
proc.once('exit', common.mustCall(() => {
assert(fs.existsSync(FILE_NAME));
diff --git a/test/parallel/test-trace-events-promises.js b/test/parallel/test-trace-events-promises.js
index 3088be5296..0dd4fddc6d 100644
--- a/test/parallel/test-trace-events-promises.js
+++ b/test/parallel/test-trace-events-promises.js
@@ -2,15 +2,12 @@
const common = require('../common');
const assert = require('assert');
const cp = require('child_process');
-const path = require('path');
const fs = require('fs');
+const path = require('path');
const tmpdir = require('../common/tmpdir');
common.disableCrashOnUnhandledRejection();
-if (!common.isMainThread)
- common.skip('process.chdir is not available in Workers');
-
if (process.argv[2] === 'child') {
const p = Promise.reject(1); // Handled later
Promise.reject(2); // Unhandled
@@ -19,10 +16,10 @@ if (process.argv[2] === 'child') {
});
} else {
tmpdir.refresh();
- process.chdir(tmpdir.path);
const proc = cp.fork(__filename,
[ 'child' ], {
+ cwd: tmpdir.path,
execArgv: [
'--no-warnings',
'--trace-event-categories',
diff --git a/test/parallel/test-trace-events-v8.js b/test/parallel/test-trace-events-v8.js
index 3c1fd48d67..d79838892b 100644
--- a/test/parallel/test-trace-events-v8.js
+++ b/test/parallel/test-trace-events-v8.js
@@ -3,22 +3,20 @@ const common = require('../common');
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 path = require('path');
const CODE =
'setTimeout(() => { for (var i = 0; i < 100000; i++) { "test" + i } }, 1)';
-const FILE_NAME = 'node_trace.1.log';
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
-process.chdir(tmpdir.path);
+const FILE_NAME = path.join(tmpdir.path, 'node_trace.1.log');
const proc = cp.spawn(process.execPath,
[ '--trace-events-enabled',
'--trace-event-categories', 'v8',
- '-e', CODE ]);
+ '-e', CODE ],
+ { cwd: tmpdir.path });
proc.once('exit', common.mustCall(() => {
assert(fs.existsSync(FILE_NAME));
diff --git a/test/parallel/test-trace-events-vm.js b/test/parallel/test-trace-events-vm.js
index 758de3e964..3e5d32b6c3 100644
--- a/test/parallel/test-trace-events-vm.js
+++ b/test/parallel/test-trace-events-vm.js
@@ -2,13 +2,10 @@
const common = require('../common');
const assert = require('assert');
const cp = require('child_process');
-const path = require('path');
const fs = require('fs');
+const path = require('path');
const tmpdir = require('../common/tmpdir');
-if (!common.isMainThread)
- common.skip('process.chdir is not available in Workers');
-
const names = [
'ContextifyScript::New',
'RunInThisContext',
@@ -20,10 +17,10 @@ if (process.argv[2] === 'child') {
vm.runInNewContext('1 + 1');
} else {
tmpdir.refresh();
- process.chdir(tmpdir.path);
const proc = cp.fork(__filename,
[ 'child' ], {
+ cwd: tmpdir.path,
execArgv: [
'--trace-event-categories',
'node.vm.script'