From da9d767ace5470f5824b3a261c2f3f8e7ab7d9c8 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 25 Dec 2015 21:52:52 -0800 Subject: [PATCH] test: remove unused vars in ChildProcess tests In addition to removing unused vars, this also fixes an instance where booleans were set presumably to check something but then never used. This now confirms that the events that were setting the booleans are fired. --- test/parallel/test-child-process-buffering.js | 2 -- test/parallel/test-child-process-cwd.js | 2 -- test/parallel/test-child-process-exec-buffer.js | 2 +- test/parallel/test-child-process-exec-cwd.js | 2 +- test/parallel/test-child-process-fork-dgram.js | 1 - test/parallel/test-child-process-fork-exec-path.js | 1 - test/parallel/test-child-process-fork-ref2.js | 1 - test/parallel/test-child-process-spawn-error.js | 1 - test/parallel/test-child-process-stdin.js | 14 ++------------ test/parallel/test-child-process-stdio-inherit.js | 2 +- test/parallel/test-child-process-stdio.js | 1 - .../test-child-process-stdout-flush-exit.js | 1 - 12 files changed, 5 insertions(+), 25 deletions(-) diff --git a/test/parallel/test-child-process-buffering.js b/test/parallel/test-child-process-buffering.js index a37e1dbbbd75..1efa5a65f9ce 100644 --- a/test/parallel/test-child-process-buffering.js +++ b/test/parallel/test-child-process-buffering.js @@ -2,8 +2,6 @@ var common = require('../common'); var assert = require('assert'); -var spawn = require('child_process').spawn; - var pwd_called = false; var childClosed = false; var childExited = false; diff --git a/test/parallel/test-child-process-cwd.js b/test/parallel/test-child-process-cwd.js index e0e83b6007a8..f13da684fbdf 100644 --- a/test/parallel/test-child-process-cwd.js +++ b/test/parallel/test-child-process-cwd.js @@ -1,8 +1,6 @@ 'use strict'; var common = require('../common'); var assert = require('assert'); -var spawn = require('child_process').spawn; -var path = require('path'); var returns = 0; diff --git a/test/parallel/test-child-process-exec-buffer.js b/test/parallel/test-child-process-exec-buffer.js index 0ab05080a2cb..b9727f0c63ad 100644 --- a/test/parallel/test-child-process-exec-buffer.js +++ b/test/parallel/test-child-process-exec-buffer.js @@ -9,7 +9,7 @@ var success_count = 0; var str = 'hello'; // default encoding -var child = exec('echo ' + str, function(err, stdout, stderr) { +exec('echo ' + str, function(err, stdout, stderr) { assert.ok('string', typeof(stdout), 'Expected stdout to be a string'); assert.ok('string', typeof(stderr), 'Expected stderr to be a string'); assert.equal(str + os.EOL, stdout); diff --git a/test/parallel/test-child-process-exec-cwd.js b/test/parallel/test-child-process-exec-cwd.js index e253399b96ac..c259ffffda3d 100644 --- a/test/parallel/test-child-process-exec-cwd.js +++ b/test/parallel/test-child-process-exec-cwd.js @@ -16,7 +16,7 @@ if (common.isWindows) { dir = '/dev'; } -var child = exec(pwdcommand, {cwd: dir}, function(err, stdout, stderr) { +exec(pwdcommand, {cwd: dir}, function(err, stdout, stderr) { if (err) { error_count++; console.log('error!: ' + err.code); diff --git a/test/parallel/test-child-process-fork-dgram.js b/test/parallel/test-child-process-fork-dgram.js index f700960490cb..86cd6576c73b 100644 --- a/test/parallel/test-child-process-fork-dgram.js +++ b/test/parallel/test-child-process-fork-dgram.js @@ -25,7 +25,6 @@ if (common.isWindows) { } if (process.argv[2] === 'child') { - var childCollected = 0; var server; process.on('message', function removeMe(msg, clusterServer) { diff --git a/test/parallel/test-child-process-fork-exec-path.js b/test/parallel/test-child-process-fork-exec-path.js index 6a61bddd8a19..35a730b0da6c 100644 --- a/test/parallel/test-child-process-fork-exec-path.js +++ b/test/parallel/test-child-process-fork-exec-path.js @@ -1,6 +1,5 @@ 'use strict'; var assert = require('assert'); -var cp = require('child_process'); var fs = require('fs'); var path = require('path'); var common = require('../common'); diff --git a/test/parallel/test-child-process-fork-ref2.js b/test/parallel/test-child-process-fork-ref2.js index b7addea8f9c7..42c43ed8882b 100644 --- a/test/parallel/test-child-process-fork-ref2.js +++ b/test/parallel/test-child-process-fork-ref2.js @@ -1,6 +1,5 @@ 'use strict'; require('../common'); -var assert = require('assert'); var fork = require('child_process').fork; if (process.argv[2] === 'child') { diff --git a/test/parallel/test-child-process-spawn-error.js b/test/parallel/test-child-process-spawn-error.js index 1398dac16531..4eaa45ee7aef 100644 --- a/test/parallel/test-child-process-spawn-error.js +++ b/test/parallel/test-child-process-spawn-error.js @@ -1,6 +1,5 @@ 'use strict'; var common = require('../common'); -var fs = require('fs'); var spawn = require('child_process').spawn; var assert = require('assert'); diff --git a/test/parallel/test-child-process-stdin.js b/test/parallel/test-child-process-stdin.js index c12b24579375..4a371b83fb04 100644 --- a/test/parallel/test-child-process-stdin.js +++ b/test/parallel/test-child-process-stdin.js @@ -18,30 +18,20 @@ var response = ''; var exitStatus = -1; var closed = false; -var gotStdoutEOF = false; - cat.stdout.setEncoding('utf8'); cat.stdout.on('data', function(chunk) { console.log('stdout: ' + chunk); response += chunk; }); -cat.stdout.on('end', function() { - gotStdoutEOF = true; -}); - - -var gotStderrEOF = false; +cat.stdout.on('end', common.mustCall(function() {})); cat.stderr.on('data', function(chunk) { // shouldn't get any stderr output assert.ok(false); }); -cat.stderr.on('end', function(chunk) { - gotStderrEOF = true; -}); - +cat.stderr.on('end', common.mustCall(function() {})); cat.on('exit', function(status) { console.log('exit event'); diff --git a/test/parallel/test-child-process-stdio-inherit.js b/test/parallel/test-child-process-stdio-inherit.js index 8cf08a7bd5fa..409c0af7ca0d 100644 --- a/test/parallel/test-child-process-stdio-inherit.js +++ b/test/parallel/test-child-process-stdio-inherit.js @@ -31,5 +31,5 @@ function grandparent() { function parent() { // should not immediately exit. - var child = common.spawnCat({ stdio: 'inherit' }); + common.spawnCat({ stdio: 'inherit' }); } diff --git a/test/parallel/test-child-process-stdio.js b/test/parallel/test-child-process-stdio.js index 1ff6e4d914f7..d5fe6d43b64d 100644 --- a/test/parallel/test-child-process-stdio.js +++ b/test/parallel/test-child-process-stdio.js @@ -1,7 +1,6 @@ 'use strict'; var common = require('../common'); var assert = require('assert'); -var spawn = require('child_process').spawn; var options = {stdio: ['pipe']}; var child = common.spawnPwd(options); diff --git a/test/parallel/test-child-process-stdout-flush-exit.js b/test/parallel/test-child-process-stdout-flush-exit.js index 577a33a05082..b76a7cb5e5a8 100644 --- a/test/parallel/test-child-process-stdout-flush-exit.js +++ b/test/parallel/test-child-process-stdout-flush-exit.js @@ -1,7 +1,6 @@ 'use strict'; var common = require('../common'); var assert = require('assert'); -var path = require('path'); // if child process output to console and exit if (process.argv[2] === 'child') {