GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: rewrite test-child-process-spawn-args · nodejs/node@34e86f9

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test/parallel
    • test-child-process-spawn-args.js
    • test-child-process-spawn-args.mjs
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/parallel/test-child-process-spawn-args.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-child-process-spawn-args.js
-55Lines changed: 0 additions & 55 deletions
This file was deleted.
Collapse file

‎test/parallel/test-child-process-spawn-args.mjs‎

Copy file name to clipboard
+50Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// This test confirms that `undefined`, `null`, and `[]`
2+
// can be used as a placeholder for the second argument (`args`) of `spawn()`.
3+
// Previously, there was a bug where using `undefined` for the second argument
4+
// caused the third argument (`options`) to be ignored.
5+
// See https://github.com/nodejs/node/issues/24912.
6+
7+
import * as common from '../common/index.mjs';
8+
import tmpdir from '../common/tmpdir.js';
9+
10+
import assert from 'node:assert';
11+
import { spawn } from 'node:child_process';
12+
import { once } from 'node:events';
13+
14+
tmpdir.refresh();
15+
16+
const command = common.isWindows ? 'cd' : 'pwd';
17+
const options = { cwd: tmpdir.path };
18+
19+
if (common.isWindows) {
20+
// This test is not the case for Windows based systems
21+
// unless the `shell` options equals to `true`
22+
options.shell = true;
23+
}
24+
25+
const testCases = [
26+
undefined,
27+
null,
28+
[],
29+
];
30+
31+
const expectedResult = new Set([tmpdir.path.trim().toLowerCase()]);
32+
33+
const actualResults = new Set();
34+
35+
for (const testCase of testCases) {
36+
const subprocess = spawn(command, testCase, options);
37+
38+
let accumulatedData = '';
39+
40+
subprocess.stdout.setEncoding('utf8');
41+
subprocess.stdout.on('data', common.mustCall((data) => {
42+
accumulatedData += data;
43+
}));
44+
45+
await once(subprocess.stdout, 'end');
46+
47+
actualResults.add(accumulatedData.trim().toLowerCase());
48+
}
49+
50+
assert.deepStrictEqual(actualResults, expectedResult);

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.