From dffe83ccd656d0ad498160ea95509233b88501c8 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. PR-URL: https://github.com/nodejs/node/pull/4684 Reviewed-By: Myles Borins --- 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 - .../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-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-tls-legacy-onselect.js | 10 ---------- 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 - 28 files changed, 5 insertions(+), 50 deletions(-) diff --git a/test/addons/at-exit/test.js b/test/addons/at-exit/test.js index 32264a6604..c94453cb3b 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 04befca637..bdca60d1b4 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 27547edcd8..d7c50a1e86 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 03aca7a662..0f696806be 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 6ff68252d9..3821551f00 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 76f5cc69a9..ef9f7728ba 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 8286d58d1e..9814b39555 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 a34c5e2eb6..80c2d23e42 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 5b1ede414e..58c8b69839 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 e5f9f6748b..ac01d66dee 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 f966b5a98c..4e2ddf42b6 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 8f40d88f34..5b9f2f3ddf 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 b08f42b5c2..9a9b85ecac 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 f6d00c72a0..c321f699d7 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 d51d51ee8e..3e0fa521f7 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 5cac38a1d7..e026c0b583 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-tls-legacy-onselect.js b/test/parallel/test-tls-legacy-onselect.js index 6f1e9a91a8..d3b20d5d8a 100644 --- a/test/parallel/test-tls-legacy-onselect.js +++ b/test/parallel/test-tls-legacy-onselect.js @@ -9,18 +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'); -} - -function loadPEM(n) { - return fs.readFileSync(filenamePEM(n)); -} - 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 d190ff51a5..f8ce5bfbe8 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'); var 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 26285c0473..f04dac9f06 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 53fa715a67..fa70c5f14d 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 513cbeb0ee..b558dd2802 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 bd852e45f1..12a6fecc70 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 c2ec7fd81f..46190555b2 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 9f62bd95d0..87497b2685 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 aaf8e628d6..3d33ef8f21 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 0bc4e02c65..205485c9eb 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 ff5754f357..ba7f90ecf0 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 f0ecf9a7c4..470fa9843c 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');