Skip to content

Commit bb2de4a

Browse files
vsemozhetbytMylesBorins
authored andcommitted
test: do not use more command on Windows
PR-URL: #11953 Fixes: #11469 Reviewed-By: João Reis <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent 924f346 commit bb2de4a

7 files changed

+8
-45
lines changed

test/README.md

-12
Original file line numberDiff line numberDiff line change
@@ -376,24 +376,12 @@ Path to the 'root' directory. either `/` or `c:\\` (windows)
376376

377377
Logs '1..0 # Skipped: ' + `msg`
378378

379-
### spawnCat(options)
380-
* `options` [&lt;Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
381-
* return [&lt;Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
382-
383-
Platform normalizes the `cat` command.
384-
385379
### spawnPwd(options)
386380
* `options` [&lt;Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
387381
* return [&lt;Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
388382

389383
Platform normalizes the `pwd` command.
390384

391-
### spawnSyncCat(options)
392-
* `options` [&lt;Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
393-
* return [&lt;Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
394-
395-
Synchronous version of `spawnCat`.
396-
397385
### spawnSyncPwd(options)
398386
* `options` [&lt;Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
399387
* return [&lt;Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)

test/common.js

-22
Original file line numberDiff line numberDiff line change
@@ -237,28 +237,6 @@ exports.ddCommand = function(filename, kilobytes) {
237237
};
238238

239239

240-
exports.spawnCat = function(options) {
241-
const spawn = require('child_process').spawn;
242-
243-
if (exports.isWindows) {
244-
return spawn('more', [], options);
245-
} else {
246-
return spawn('cat', [], options);
247-
}
248-
};
249-
250-
251-
exports.spawnSyncCat = function(options) {
252-
const spawnSync = require('child_process').spawnSync;
253-
254-
if (exports.isWindows) {
255-
return spawnSync('more', [], options);
256-
} else {
257-
return spawnSync('cat', [], options);
258-
}
259-
};
260-
261-
262240
exports.spawnPwd = function(options) {
263241
const spawn = require('child_process').spawn;
264242

test/parallel/test-child-process-spawn-shell.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ echo.on('close', common.mustCall((code, signal) => {
3434
}));
3535

3636
// Verify that shell features can be used
37-
const cmd = common.isWindows ? 'echo bar | more' : 'echo bar | cat';
37+
const cmd = 'echo bar | cat';
3838
const command = cp.spawn(cmd, {
3939
encoding: 'utf8',
4040
shell: true

test/parallel/test-child-process-spawnsync-shell.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ assert.strictEqual(echo.args[echo.args.length - 1].replace(/"/g, ''),
2323
assert.strictEqual(echo.stdout.toString().trim(), 'foo');
2424

2525
// Verify that shell features can be used
26-
const cmd = common.isWindows ? 'echo bar | more' : 'echo bar | cat';
26+
const cmd = 'echo bar | cat';
2727
const command = cp.spawnSync(cmd, {shell: true});
2828

2929
assert.strictEqual(command.stdout.toString().trim(), 'bar');

test/parallel/test-child-process-stdin.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const assert = require('assert');
44

55
const spawn = require('child_process').spawn;
66

7-
const cat = spawn(common.isWindows ? 'more' : 'cat');
7+
const cat = spawn('cat');
88
cat.stdin.write('hello');
99
cat.stdin.write(' ');
1010
cat.stdin.write('world');
@@ -33,9 +33,5 @@ cat.on('exit', common.mustCall(function(status) {
3333
}));
3434

3535
cat.on('close', common.mustCall(function() {
36-
if (common.isWindows) {
37-
assert.strictEqual('hello world\r\n', response);
38-
} else {
39-
assert.strictEqual('hello world', response);
40-
}
36+
assert.strictEqual('hello world', response);
4137
}));

test/parallel/test-child-process-stdio-inherit.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict';
2-
const common = require('../common');
2+
require('../common');
33
const assert = require('assert');
44
const spawn = require('child_process').spawn;
55

@@ -31,5 +31,5 @@ function grandparent() {
3131

3232
function parent() {
3333
// should not immediately exit.
34-
common.spawnCat({ stdio: 'inherit' });
34+
spawn('cat', [], { stdio: 'inherit' });
3535
}

test/parallel/test-child-process-stdio.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22
const common = require('../common');
33
const assert = require('assert');
4+
const spawnSync = require('child_process').spawnSync;
45

56
let options = {stdio: ['pipe']};
67
let child = common.spawnPwd(options);
@@ -15,7 +16,7 @@ assert.strictEqual(child.stdout, null);
1516
assert.strictEqual(child.stderr, null);
1617

1718
options = {stdio: 'ignore'};
18-
child = common.spawnSyncCat(options);
19+
child = spawnSync('cat', [], options);
1920
assert.deepStrictEqual(options, {stdio: 'ignore'});
2021

2122
assert.throws(() => {

0 commit comments

Comments
 (0)