Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8552bb4

Browse filesBrowse files
richardlauMylesBorins
authored andcommitted
test: enable trace-events tests for workers
Use the `cwd` option for `child_process` instead of `process.chdir()` to enable the trace events tests to run on workers. Conflicts: test/parallel/test-trace-events-binding.js test/parallel/test-trace-events-category-used.js Backport-PR-URL: #23882 PR-URL: #23698 Refs: #23674 (comment) Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent d1102f8 commit 8552bb4
Copy full SHA for 8552bb4
Expand file treeCollapse file tree

15 files changed

+48
-84
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-trace-events-all.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-trace-events-all.js
+4-6Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,18 @@ const common = require('../common');
33
const assert = require('assert');
44
const cp = require('child_process');
55
const fs = require('fs');
6-
7-
if (!common.isMainThread)
8-
common.skip('process.chdir is not available in Workers');
6+
const path = require('path');
97

108
const CODE =
119
'setTimeout(() => { for (var i = 0; i < 100000; i++) { "test" + i } }, 1)';
12-
const FILE_NAME = 'node_trace.1.log';
1310

1411
const tmpdir = require('../common/tmpdir');
1512
tmpdir.refresh();
16-
process.chdir(tmpdir.path);
13+
const FILE_NAME = path.join(tmpdir.path, 'node_trace.1.log');
1714

1815
const proc = cp.spawn(process.execPath,
19-
[ '--trace-events-enabled', '-e', CODE ]);
16+
[ '--trace-events-enabled', '-e', CODE ],
17+
{ cwd: tmpdir.path });
2018

2119
proc.once('exit', common.mustCall(() => {
2220
assert(fs.existsSync(FILE_NAME));
Collapse file

‎test/parallel/test-trace-events-api.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-trace-events-api.js
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ const common = require('../common');
55

66
if (!process.binding('config').hasTracing)
77
common.skip('missing trace events');
8-
if (!common.isMainThread)
9-
common.skip('process.chdir is not available in Workers');
8+
common.skipIfWorker(); // https://github.com/nodejs/node/issues/22767
109

1110
const assert = require('assert');
1211
const cp = require('child_process');
Collapse file

‎test/parallel/test-trace-events-async-hooks.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-trace-events-async-hooks.js
+4-6Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,20 @@ const common = require('../common');
33
const assert = require('assert');
44
const cp = require('child_process');
55
const fs = require('fs');
6+
const path = require('path');
67
const util = require('util');
78

8-
if (!common.isMainThread)
9-
common.skip('process.chdir is not available in Workers');
10-
119
const CODE =
1210
'setTimeout(() => { for (var i = 0; i < 100000; i++) { "test" + i } }, 1)';
13-
const FILE_NAME = 'node_trace.1.log';
1411

1512
const tmpdir = require('../common/tmpdir');
1613
tmpdir.refresh();
17-
process.chdir(tmpdir.path);
14+
const FILE_NAME = path.join(tmpdir.path, 'node_trace.1.log');
1815

1916
const proc = cp.spawn(process.execPath,
2017
[ '--trace-event-categories', 'node.async_hooks',
21-
'-e', CODE ]);
18+
'-e', CODE ],
19+
{ cwd: tmpdir.path });
2220

2321
proc.once('exit', common.mustCall(() => {
2422
assert(fs.existsSync(FILE_NAME));
Collapse file

‎test/parallel/test-trace-events-binding.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-trace-events-binding.js
+4-6Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ const common = require('../common');
33
const assert = require('assert');
44
const cp = require('child_process');
55
const fs = require('fs');
6-
7-
if (!common.isMainThread)
8-
common.skip('process.chdir is not available in Workers');
6+
const path = require('path');
97

108
const CODE = `
119
process.binding("trace_events").emit(
@@ -21,15 +19,15 @@ const CODE = `
2119
'b'.charCodeAt(0), 'missing',
2220
'type-value', 10, 'extra-value', 20);
2321
`;
24-
const FILE_NAME = 'node_trace.1.log';
2522

2623
const tmpdir = require('../common/tmpdir');
2724
tmpdir.refresh();
28-
process.chdir(tmpdir.path);
25+
const FILE_NAME = path.join(tmpdir.path, 'node_trace.1.log');
2926

3027
const proc = cp.spawn(process.execPath,
3128
[ '--trace-event-categories', 'custom',
32-
'-e', CODE ]);
29+
'-e', CODE ],
30+
{ cwd: tmpdir.path });
3331

3432
proc.once('exit', common.mustCall(() => {
3533
assert(fs.existsSync(FILE_NAME));
Collapse file

‎test/parallel/test-trace-events-bootstrap.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-trace-events-bootstrap.js
+2-5Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,10 @@
22
const common = require('../common');
33
const assert = require('assert');
44
const cp = require('child_process');
5-
const path = require('path');
65
const fs = require('fs');
6+
const path = require('path');
77
const tmpdir = require('../common/tmpdir');
88

9-
if (!common.isMainThread)
10-
common.skip('process.chdir is not available in Workers');
11-
129
const names = [
1310
'environment',
1411
'nodeStart',
@@ -30,10 +27,10 @@ if (process.argv[2] === 'child') {
3027
1 + 1;
3128
} else {
3229
tmpdir.refresh();
33-
process.chdir(tmpdir.path);
3430

3531
const proc = cp.fork(__filename,
3632
[ 'child' ], {
33+
cwd: tmpdir.path,
3734
execArgv: [
3835
'--trace-event-categories',
3936
'node.bootstrap'
Collapse file

‎test/parallel/test-trace-events-category-used.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-trace-events-category-used.js
+4-6Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,17 @@ const common = require('../common');
33
const assert = require('assert');
44
const cp = require('child_process');
55

6-
if (!common.isMainThread)
7-
common.skip('process.chdir is not available in Workers');
8-
96
const CODE = `console.log(
107
process.binding("trace_events").categoryGroupEnabled("custom")
118
);`;
129

1310
const tmpdir = require('../common/tmpdir');
1411
tmpdir.refresh();
15-
process.chdir(tmpdir.path);
1612

1713
const procEnabled = cp.spawn(
1814
process.execPath,
19-
[ '--trace-event-categories', 'custom', '-e', CODE ]
15+
[ '--trace-event-categories', 'custom', '-e', CODE ],
16+
{ cwd: tmpdir.path }
2017
);
2118
let procEnabledOutput = '';
2219

@@ -28,7 +25,8 @@ procEnabled.once('exit', common.mustCall(() => {
2825

2926
const procDisabled = cp.spawn(
3027
process.execPath,
31-
[ '--trace-event-categories', 'other', '-e', CODE ]
28+
[ '--trace-event-categories', 'other', '-e', CODE ],
29+
{ cwd: tmpdir.path }
3230
);
3331
let procDisabledOutput = '';
3432

Collapse file

‎test/parallel/test-trace-events-file-pattern.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-trace-events-file-pattern.js
+4-6Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,9 @@ const tmpdir = require('../common/tmpdir');
44
const assert = require('assert');
55
const cp = require('child_process');
66
const fs = require('fs');
7-
8-
if (!common.isMainThread)
9-
common.skip('process.chdir is not available in Workers');
7+
const path = require('path');
108

119
tmpdir.refresh();
12-
process.chdir(tmpdir.path);
1310

1411
const CODE =
1512
'setTimeout(() => { for (var i = 0; i < 100000; i++) { "test" + i } }, 1)';
@@ -20,10 +17,11 @@ const proc = cp.spawn(process.execPath, [
2017
// eslint-disable-next-line no-template-curly-in-string
2118
'${pid}-${rotation}-${pid}-${rotation}.tracing.log',
2219
'-e', CODE
23-
]);
20+
], { cwd: tmpdir.path });
2421

2522
proc.once('exit', common.mustCall(() => {
26-
const expectedFilename = `${proc.pid}-1-${proc.pid}-1.tracing.log`;
23+
const expectedFilename = path.join(tmpdir.path,
24+
`${proc.pid}-1-${proc.pid}-1.tracing.log`);
2725

2826
assert(fs.existsSync(expectedFilename));
2927
fs.readFile(expectedFilename, common.mustCall((err, data) => {
Collapse file

‎test/parallel/test-trace-events-fs-sync.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-trace-events-fs-sync.js
+3-6Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@ const common = require('../common');
33
const assert = require('assert');
44
const cp = require('child_process');
55
const fs = require('fs');
6+
const path = require('path');
67
const util = require('util');
78

8-
if (!common.isMainThread)
9-
common.skip('process.chdir is not available in Workers');
10-
119
const tests = new Array();
12-
const traceFile = 'node_trace.1.log';
1310

1411
let gid = 1;
1512
let uid = 1;
@@ -119,14 +116,14 @@ if (common.canCreateSymLink()) {
119116

120117
const tmpdir = require('../common/tmpdir');
121118
tmpdir.refresh();
122-
process.chdir(tmpdir.path);
119+
const traceFile = path.join(tmpdir.path, 'node_trace.1.log');
123120

124121
for (const tr in tests) {
125122
const proc = cp.spawnSync(process.execPath,
126123
[ '--trace-events-enabled',
127124
'--trace-event-categories', 'node.fs.sync',
128125
'-e', tests[tr] ],
129-
{ encoding: 'utf8' });
126+
{ cwd: tmpdir.path, encoding: 'utf8' });
130127
// Some AIX versions don't support futimes or utimes, so skip.
131128
if (common.isAIX && proc.status !== 0 && tr === 'fs.sync.futimes') {
132129
continue;
Collapse file

‎test/parallel/test-trace-events-metadata.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-trace-events-metadata.js
+4-6Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,21 @@ const common = require('../common');
33
const assert = require('assert');
44
const cp = require('child_process');
55
const fs = require('fs');
6-
7-
if (!common.isMainThread)
8-
common.skip('process.chdir is not available in Workers');
6+
const path = require('path');
97

108
const CODE =
119
'setTimeout(() => { for (var i = 0; i < 100000; i++) { "test" + i } }, 1);' +
1210
'process.title = "foo"';
13-
const FILE_NAME = 'node_trace.1.log';
1411

1512
const tmpdir = require('../common/tmpdir');
1613
tmpdir.refresh();
17-
process.chdir(tmpdir.path);
14+
const FILE_NAME = path.join(tmpdir.path, 'node_trace.1.log');
1815

1916
const proc = cp.spawn(process.execPath,
2017
[ '--trace-event-categories', 'node.perf.usertiming',
2118
'--title=bar',
22-
'-e', CODE ]);
19+
'-e', CODE ],
20+
{ cwd: tmpdir.path });
2321
proc.once('exit', common.mustCall(() => {
2422
assert(fs.existsSync(FILE_NAME));
2523
fs.readFile(FILE_NAME, common.mustCall((err, data) => {
Collapse file

‎test/parallel/test-trace-events-none.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-trace-events-none.js
+4-6Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,19 @@ const common = require('../common');
33
const assert = require('assert');
44
const cp = require('child_process');
55
const fs = require('fs');
6-
7-
if (!common.isMainThread)
8-
common.skip('process.chdir is not available in Workers');
6+
const path = require('path');
97

108
const CODE =
119
'setTimeout(() => { for (var i = 0; i < 100000; i++) { "test" + i } }, 1)';
12-
const FILE_NAME = 'node_trace.1.log';
1310

1411
const tmpdir = require('../common/tmpdir');
1512
tmpdir.refresh();
16-
process.chdir(tmpdir.path);
13+
const FILE_NAME = path.join(tmpdir.path, 'node_trace.1.log');
1714

1815
const proc_no_categories = cp.spawn(
1916
process.execPath,
20-
[ '--trace-event-categories', '""', '-e', CODE ]
17+
[ '--trace-event-categories', '""', '-e', CODE ],
18+
{ cwd: tmpdir.path }
2119
);
2220

2321
proc_no_categories.once('exit', common.mustCall(() => {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.