Skip to content

Commit 9c3d521

Browse files
Dennis SchwartzFishrock123
authored andcommitted
test: improve child_process tests
Replaced var keyword with const and let in the tests for child process stdin and stdio. PR-URL: #8617 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>
1 parent 07d97f4 commit 9c3d521

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
'use strict';
2-
var common = require('../common');
3-
var assert = require('assert');
2+
const common = require('../common');
3+
const assert = require('assert');
44

5-
var spawn = require('child_process').spawn;
5+
const spawn = require('child_process').spawn;
66

7-
var cat = spawn(common.isWindows ? 'more' : 'cat');
7+
const cat = spawn(common.isWindows ? 'more' : 'cat');
88
cat.stdin.write('hello');
99
cat.stdin.write(' ');
1010
cat.stdin.write('world');
@@ -14,7 +14,7 @@ assert.ok(!cat.stdin.readable);
1414

1515
cat.stdin.end();
1616

17-
var response = '';
17+
let response = '';
1818

1919
cat.stdout.setEncoding('utf8');
2020
cat.stdout.on('data', function(chunk) {

test/parallel/test-child-process-stdio-big-write-end.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22
require('../common');
3-
var assert = require('assert');
4-
var BUFSIZE = 1024;
3+
const assert = require('assert');
4+
const BUFSIZE = 1024;
55

66
switch (process.argv[2]) {
77
case undefined:
@@ -13,11 +13,11 @@ switch (process.argv[2]) {
1313
}
1414

1515
function parent() {
16-
var spawn = require('child_process').spawn;
17-
var child = spawn(process.execPath, [__filename, 'child']);
18-
var sent = 0;
16+
const spawn = require('child_process').spawn;
17+
const child = spawn(process.execPath, [__filename, 'child']);
18+
let sent = 0;
1919

20-
var n = '';
20+
let n = '';
2121
child.stdout.setEncoding('ascii');
2222
child.stdout.on('data', function(c) {
2323
n += c;
@@ -34,7 +34,7 @@ function parent() {
3434
} while (child.stdin.write(buf));
3535

3636
// then write a bunch more times.
37-
for (var i = 0; i < 100; i++) {
37+
for (let i = 0; i < 100; i++) {
3838
const buf = Buffer.alloc(BUFSIZE, '.');
3939
sent += BUFSIZE;
4040
child.stdin.write(buf);
@@ -47,7 +47,7 @@ function parent() {
4747
}
4848

4949
function child() {
50-
var received = 0;
50+
let received = 0;
5151
process.stdin.on('data', function(c) {
5252
received += c.length;
5353
});

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
'use strict';
2-
var common = require('../common');
3-
var assert = require('assert');
2+
const common = require('../common');
3+
const assert = require('assert');
44

5-
var options = {stdio: ['pipe']};
6-
var child = common.spawnPwd(options);
5+
let options = {stdio: ['pipe']};
6+
let child = common.spawnPwd(options);
77

88
assert.notEqual(child.stdout, null);
99
assert.notEqual(child.stderr, null);

0 commit comments

Comments
 (0)