A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/nodejs/node/commit/34e86f91aa below:

rewrite test-child-process-spawn-args · nodejs/node@34e86f9 · GitHub

File tree Expand file treeCollapse file tree 2 files changed

+50

-55

lines changed

Filter options

Expand file treeCollapse file tree 2 files changed

+50

-55

lines changed Original file line number Diff line number Diff 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);

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4