From 6304758bf3335332504b7aeb1129ce4d64fb0b5c Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Tue, 29 Dec 2015 18:56:29 -0800 Subject: [PATCH] test: remove unused modules Many tests use require() to import modules that subsequently never gets used. This removes those imports and, in a few cases, removes other unused variables from tests. --- test/addons/at-exit/test.js | 2 +- test/internet/test-dns-ipv4.js | 2 -- test/internet/test-dns-ipv6.js | 2 -- test/message/2100bytes.js | 1 - test/parallel/test-cluster-eaddrinuse.js | 1 - test/parallel/test-cluster-worker-forced-exit.js | 1 - test/parallel/test-crypto-certificate.js | 1 - test/parallel/test-dgram-send-callback-buffer-length.js | 2 -- test/parallel/test-dgram-udp4.js | 3 +-- test/parallel/test-domain-multi.js | 1 - test/parallel/test-eval-require.js | 2 -- test/parallel/test-event-emitter-listeners-side-effects.js | 1 - test/parallel/test-fs-readdir.js | 1 - test/parallel/test-listen-fd-cluster.js | 1 - test/parallel/test-listen-fd-server.js | 1 - test/parallel/test-readline-keys.js | 3 +-- test/parallel/test-tick-processor.js | 1 - test/parallel/test-tls-legacy-onselect.js | 6 ------ test/parallel/test-zlib-dictionary.js | 1 - test/parallel/test-zlib-flush-drain.js | 1 - test/parallel/test-zlib-write-after-flush.js | 1 - test/pummel/test-dtrace-jsstack.js | 3 --- test/pummel/test-http-client-reconnect-bug.js | 1 - test/pummel/test-keep-alive.js | 1 - test/pummel/test-timer-wrap2.js | 3 +-- test/pummel/test-tls-securepair-client.js | 4 ---- test/sequential/test-child-process-execsync.js | 1 - test/sequential/test-regress-GH-1697.js | 3 +-- test/sequential/test-stdout-close-catch.js | 1 - 29 files changed, 5 insertions(+), 47 deletions(-) diff --git a/test/addons/at-exit/test.js b/test/addons/at-exit/test.js index 32264a6604eeb6..c94453cb3b05a4 100644 --- a/test/addons/at-exit/test.js +++ b/test/addons/at-exit/test.js @@ -1,3 +1,3 @@ 'use strict'; require('../../common'); -var binding = require('./build/Release/binding'); +require('./build/Release/binding'); diff --git a/test/internet/test-dns-ipv4.js b/test/internet/test-dns-ipv4.js index 04befca6370e1e..bdca60d1b4fd5d 100644 --- a/test/internet/test-dns-ipv4.js +++ b/test/internet/test-dns-ipv4.js @@ -3,9 +3,7 @@ var common = require('../common'); var assert = require('assert'), dns = require('dns'), net = require('net'), - isIP = net.isIP, isIPv4 = net.isIPv4; -var util = require('util'); var expected = 0, completed = 0, diff --git a/test/internet/test-dns-ipv6.js b/test/internet/test-dns-ipv6.js index 27547edcd84b46..d7c50a1e86b656 100644 --- a/test/internet/test-dns-ipv6.js +++ b/test/internet/test-dns-ipv6.js @@ -3,9 +3,7 @@ var common = require('../common'); var assert = require('assert'), dns = require('dns'), net = require('net'), - isIP = net.isIP, isIPv6 = net.isIPv6; -var util = require('util'); var expected = 0, completed = 0, diff --git a/test/message/2100bytes.js b/test/message/2100bytes.js index 03aca7a6626bce..0f696806be03fe 100644 --- a/test/message/2100bytes.js +++ b/test/message/2100bytes.js @@ -1,6 +1,5 @@ 'use strict'; require('../common'); -var util = require('util'); console.log([ '_______________________________________________50', diff --git a/test/parallel/test-cluster-eaddrinuse.js b/test/parallel/test-cluster-eaddrinuse.js index 6ff68252d9d867..3821551f00a32c 100644 --- a/test/parallel/test-cluster-eaddrinuse.js +++ b/test/parallel/test-cluster-eaddrinuse.js @@ -5,7 +5,6 @@ var common = require('../common'); var assert = require('assert'); -var cluster = require('cluster'); var fork = require('child_process').fork; var net = require('net'); diff --git a/test/parallel/test-cluster-worker-forced-exit.js b/test/parallel/test-cluster-worker-forced-exit.js index 76f5cc69a9f716..ef9f7728bad3a2 100644 --- a/test/parallel/test-cluster-worker-forced-exit.js +++ b/test/parallel/test-cluster-worker-forced-exit.js @@ -2,7 +2,6 @@ require('../common'); var assert = require('assert'); var cluster = require('cluster'); -var net = require('net'); var SENTINEL = 42; diff --git a/test/parallel/test-crypto-certificate.js b/test/parallel/test-crypto-certificate.js index 8286d58d1e44ca..9814b395552e9f 100644 --- a/test/parallel/test-crypto-certificate.js +++ b/test/parallel/test-crypto-certificate.js @@ -11,7 +11,6 @@ var crypto = require('crypto'); crypto.DEFAULT_ENCODING = 'buffer'; var fs = require('fs'); -var path = require('path'); // Test Certificates var spkacValid = fs.readFileSync(common.fixturesDir + '/spkac.valid'); diff --git a/test/parallel/test-dgram-send-callback-buffer-length.js b/test/parallel/test-dgram-send-callback-buffer-length.js index a34c5e2eb6b8db..80c2d23e42ef55 100644 --- a/test/parallel/test-dgram-send-callback-buffer-length.js +++ b/test/parallel/test-dgram-send-callback-buffer-length.js @@ -2,9 +2,7 @@ var common = require('../common'); var assert = require('assert'); -var fs = require('fs'); var dgram = require('dgram'); -var callbacks = 0; var client, timer, buf, len, offset; diff --git a/test/parallel/test-dgram-udp4.js b/test/parallel/test-dgram-udp4.js index 5b1ede414eb1a1..58c8b69839ffe6 100644 --- a/test/parallel/test-dgram-udp4.js +++ b/test/parallel/test-dgram-udp4.js @@ -2,8 +2,7 @@ var common = require('../common'); var assert = require('assert'); -var fs = require('fs'), - dgram = require('dgram'), server, client, +var dgram = require('dgram'), server, client, server_port = common.PORT, message_to_send = 'A message to send', timer; diff --git a/test/parallel/test-domain-multi.js b/test/parallel/test-domain-multi.js index e5f9f6748b178e..ac01d66deee544 100644 --- a/test/parallel/test-domain-multi.js +++ b/test/parallel/test-domain-multi.js @@ -4,7 +4,6 @@ var common = require('../common'); var assert = require('assert'); var domain = require('domain'); -var events = require('events'); var caughtA = false; var caughtB = false; diff --git a/test/parallel/test-eval-require.js b/test/parallel/test-eval-require.js index f966b5a98c80ba..4e2ddf42b6dffa 100644 --- a/test/parallel/test-eval-require.js +++ b/test/parallel/test-eval-require.js @@ -2,8 +2,6 @@ var common = require('../common'); var assert = require('assert'); var spawn = require('child_process').spawn; -var path = require('path'); -var fs = require('fs'); var options = { cwd: common.fixturesDir diff --git a/test/parallel/test-event-emitter-listeners-side-effects.js b/test/parallel/test-event-emitter-listeners-side-effects.js index 8f40d88f34486e..5b9f2f3ddf0f41 100644 --- a/test/parallel/test-event-emitter-listeners-side-effects.js +++ b/test/parallel/test-event-emitter-listeners-side-effects.js @@ -2,7 +2,6 @@ require('../common'); var assert = require('assert'); -var events = require('events'); var EventEmitter = require('events').EventEmitter; var assert = require('assert'); diff --git a/test/parallel/test-fs-readdir.js b/test/parallel/test-fs-readdir.js index b08f42b5c23f85..9a9b85ecaccd2c 100644 --- a/test/parallel/test-fs-readdir.js +++ b/test/parallel/test-fs-readdir.js @@ -2,7 +2,6 @@ const common = require('../common'); const assert = require('assert'); -const path = require('path'); const fs = require('fs'); const readdirDir = common.tmpDir; diff --git a/test/parallel/test-listen-fd-cluster.js b/test/parallel/test-listen-fd-cluster.js index f6d00c72a0f78c..c321f699d7a89d 100644 --- a/test/parallel/test-listen-fd-cluster.js +++ b/test/parallel/test-listen-fd-cluster.js @@ -4,7 +4,6 @@ var assert = require('assert'); var http = require('http'); var net = require('net'); var PORT = common.PORT; -var spawn = require('child_process').spawn; var cluster = require('cluster'); console.error('Cluster listen fd test', process.argv[2] || 'runner'); diff --git a/test/parallel/test-listen-fd-server.js b/test/parallel/test-listen-fd-server.js index d51d51ee8eb4de..3e0fa521f75334 100644 --- a/test/parallel/test-listen-fd-server.js +++ b/test/parallel/test-listen-fd-server.js @@ -4,7 +4,6 @@ var assert = require('assert'); var http = require('http'); var net = require('net'); var PORT = common.PORT; -var spawn = require('child_process').spawn; if (common.isWindows) { console.log('1..0 # Skipped: This test is disabled on windows.'); diff --git a/test/parallel/test-readline-keys.js b/test/parallel/test-readline-keys.js index 5cac38a1d7db42..e026c0b583cd9e 100644 --- a/test/parallel/test-readline-keys.js +++ b/test/parallel/test-readline-keys.js @@ -1,6 +1,5 @@ 'use strict'; require('../common'); -var EventEmitter = require('events').EventEmitter; var PassThrough = require('stream').PassThrough; var assert = require('assert'); var inherits = require('util').inherits; @@ -16,7 +15,7 @@ inherits(FakeInput, PassThrough); var fi = new FakeInput(); var fo = new FakeInput(); -var rli = new Interface({ input: fi, output: fo, terminal: true }); +new Interface({ input: fi, output: fo, terminal: true }); var keys = []; fi.on('keypress', function(s, k) { diff --git a/test/parallel/test-tick-processor.js b/test/parallel/test-tick-processor.js index 796f6ee0aa598a..84146ed4817775 100644 --- a/test/parallel/test-tick-processor.js +++ b/test/parallel/test-tick-processor.js @@ -1,7 +1,6 @@ 'use strict'; var fs = require('fs'); var assert = require('assert'); -var path = require('path'); var cp = require('child_process'); var common = require('../common'); diff --git a/test/parallel/test-tls-legacy-onselect.js b/test/parallel/test-tls-legacy-onselect.js index a21d6341ea8ac4..d3b20d5d8a4cef 100644 --- a/test/parallel/test-tls-legacy-onselect.js +++ b/test/parallel/test-tls-legacy-onselect.js @@ -9,14 +9,8 @@ if (!common.hasCrypto) { var tls = require('tls'); var net = require('net'); -var fs = require('fs'); - var success = false; -function filenamePEM(n) { - return require('path').join(common.fixturesDir, 'keys', n + '.pem'); -} - var server = net.Server(function(raw) { var pair = tls.createSecurePair(null, true, false, false); pair.on('error', function() {}); diff --git a/test/parallel/test-zlib-dictionary.js b/test/parallel/test-zlib-dictionary.js index 8b465749ed02c7..1a491c2ca1f261 100644 --- a/test/parallel/test-zlib-dictionary.js +++ b/test/parallel/test-zlib-dictionary.js @@ -4,7 +4,6 @@ require('../common'); const assert = require('assert'); const zlib = require('zlib'); -const path = require('path'); const spdyDict = new Buffer([ 'optionsgetheadpostputdeletetraceacceptaccept-charsetaccept-encodingaccept-', diff --git a/test/parallel/test-zlib-flush-drain.js b/test/parallel/test-zlib-flush-drain.js index 26285c04739a25..f04dac9f0699ac 100644 --- a/test/parallel/test-zlib-flush-drain.js +++ b/test/parallel/test-zlib-flush-drain.js @@ -2,7 +2,6 @@ require('../common'); const assert = require('assert'); const zlib = require('zlib'); -const path = require('path'); const bigData = new Buffer(10240).fill('x'); diff --git a/test/parallel/test-zlib-write-after-flush.js b/test/parallel/test-zlib-write-after-flush.js index 53fa715a673f7e..fa70c5f14dee6c 100644 --- a/test/parallel/test-zlib-write-after-flush.js +++ b/test/parallel/test-zlib-write-after-flush.js @@ -2,7 +2,6 @@ require('../common'); var assert = require('assert'); var zlib = require('zlib'); -var fs = require('fs'); var gzip = zlib.createGzip(); var gunz = zlib.createUnzip(); diff --git a/test/pummel/test-dtrace-jsstack.js b/test/pummel/test-dtrace-jsstack.js index 513cbeb0ee7f96..b558dd28020c07 100644 --- a/test/pummel/test-dtrace-jsstack.js +++ b/test/pummel/test-dtrace-jsstack.js @@ -2,7 +2,6 @@ require('../common'); var assert = require('assert'); var os = require('os'); -var util = require('util'); if (os.type() != 'SunOS') { console.log('1..0 # Skipped: no DTRACE support'); @@ -13,7 +12,6 @@ if (os.type() != 'SunOS') { * Some functions to create a recognizable stack. */ var frames = [ 'stalloogle', 'bagnoogle', 'doogle' ]; -var expected; var stalloogle = function(str) { expected = str; @@ -35,7 +33,6 @@ var doogle = function() { var spawn = require('child_process').spawn; var prefix = '/var/tmp/node'; -var corefile = prefix + '.' + process.pid; /* * We're going to use DTrace to stop us, gcore us, and set us running again diff --git a/test/pummel/test-http-client-reconnect-bug.js b/test/pummel/test-http-client-reconnect-bug.js index bd852e45f19410..12a6fecc7050e8 100644 --- a/test/pummel/test-http-client-reconnect-bug.js +++ b/test/pummel/test-http-client-reconnect-bug.js @@ -3,7 +3,6 @@ var common = require('../common'); var assert = require('assert'); var net = require('net'), - util = require('util'), http = require('http'); var errorCount = 0; diff --git a/test/pummel/test-keep-alive.js b/test/pummel/test-keep-alive.js index c2ec7fd81f1691..46190555b27263 100644 --- a/test/pummel/test-keep-alive.js +++ b/test/pummel/test-keep-alive.js @@ -5,7 +5,6 @@ var common = require('../common'); var assert = require('assert'); var spawn = require('child_process').spawn; var http = require('http'); -var path = require('path'); var url = require('url'); if (common.isWindows) { diff --git a/test/pummel/test-timer-wrap2.js b/test/pummel/test-timer-wrap2.js index 9f62bd95d01974..87497b2685f5d3 100644 --- a/test/pummel/test-timer-wrap2.js +++ b/test/pummel/test-timer-wrap2.js @@ -1,9 +1,8 @@ 'use strict'; require('../common'); -var assert = require('assert'); // Test that allocating a timer does not increase the loop's reference // count. var Timer = process.binding('timer_wrap').Timer; -var t = new Timer(); +new Timer(); diff --git a/test/pummel/test-tls-securepair-client.js b/test/pummel/test-tls-securepair-client.js index aaf8e628d6a2bc..3d33ef8f21623f 100644 --- a/test/pummel/test-tls-securepair-client.js +++ b/test/pummel/test-tls-securepair-client.js @@ -17,9 +17,7 @@ var join = require('path').join; var net = require('net'); var assert = require('assert'); var fs = require('fs'); -var crypto = require('crypto'); var tls = require('tls'); -var exec = require('child_process').exec; var spawn = require('child_process').spawn; test1(); @@ -47,8 +45,6 @@ function test(keyfn, certfn, check, next) { // EADDRINUSE. var PORT = common.PORT + 5; - var connections = 0; - keyfn = join(common.fixturesDir, keyfn); var key = fs.readFileSync(keyfn).toString(); diff --git a/test/sequential/test-child-process-execsync.js b/test/sequential/test-child-process-execsync.js index 0bc4e02c65edb8..205485c9ebbc48 100644 --- a/test/sequential/test-child-process-execsync.js +++ b/test/sequential/test-child-process-execsync.js @@ -1,7 +1,6 @@ 'use strict'; var common = require('../common'); var assert = require('assert'); -var os = require('os'); var execSync = require('child_process').execSync; var execFileSync = require('child_process').execFileSync; diff --git a/test/sequential/test-regress-GH-1697.js b/test/sequential/test-regress-GH-1697.js index ff5754f357dfc1..ba7f90ecf00951 100644 --- a/test/sequential/test-regress-GH-1697.js +++ b/test/sequential/test-regress-GH-1697.js @@ -1,8 +1,7 @@ 'use strict'; var common = require('../common'); var net = require('net'), - cp = require('child_process'), - util = require('util'); + cp = require('child_process'); if (process.argv[2] === 'server') { // Server diff --git a/test/sequential/test-stdout-close-catch.js b/test/sequential/test-stdout-close-catch.js index f0ecf9a7c4b725..470fa9843cb9de 100644 --- a/test/sequential/test-stdout-close-catch.js +++ b/test/sequential/test-stdout-close-catch.js @@ -3,7 +3,6 @@ var common = require('../common'); var assert = require('assert'); var path = require('path'); var child_process = require('child_process'); -var fs = require('fs'); var testScript = path.join(common.fixturesDir, 'catch-stdout-error.js');