From 02fe8215f09ce8a89a5cd4e76cbd78a59771c96e Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 27 Sep 2015 15:31:36 -0700 Subject: [PATCH] test: load common.js to test for global leaks common.js contains code that checks for variables leaking into the global namespace. Load common.js in all tests that do not intentionally leak variables. PR-URL: https://github.com/nodejs/node/pull/3095 Reviewed-By: Jeremiah Senkpiel Reviewed-By: Sakthipriyan Vairamani --- test/parallel/test-arm-math-exp-regress-1376.js | 1 + test/parallel/test-bad-unicode.js | 1 + test/parallel/test-beforeexit-event-exit.js | 1 + test/parallel/test-child-process-fork-exec-argv.js | 1 + test/parallel/test-cluster-disconnect-before-exit.js | 1 + test/parallel/test-cluster-disconnect-unshared-tcp.js | 1 + test/parallel/test-cluster-disconnect-with-no-workers.js | 1 + test/parallel/test-cluster-worker-events.js | 1 + test/parallel/test-cluster-worker-forced-exit.js | 1 + test/parallel/test-cluster-worker-isconnected.js | 1 + test/parallel/test-cluster-worker-isdead.js | 1 + test/parallel/test-domain-enter-exit.js | 1 + test/parallel/test-domain-nested.js | 1 + test/parallel/test-domain-safe-exit.js | 1 + test/parallel/test-event-emitter-errors.js | 1 + test/parallel/test-freelist.js | 1 + test/parallel/test-http-client-read-in-error.js | 1 + test/parallel/test-next-tick-doesnt-hang.js | 1 + test/parallel/test-path-parse-format.js | 1 + test/parallel/test-process-argv-0.js | 1 + test/parallel/test-process-binding.js | 1 + test/parallel/test-process-exec-argv.js | 1 + test/parallel/test-process-exit-recursive.js | 1 + test/parallel/test-readline-interface.js | 1 + test/parallel/test-readline-keys.js | 1 + test/parallel/test-readline-set-raw-mode.js | 1 + test/parallel/test-readline-undefined-columns.js | 1 + test/parallel/test-regress-GH-4256.js | 1 + test/parallel/test-regress-GH-5927.js | 1 + test/parallel/test-regress-GH-io-1068.js | 1 + test/parallel/test-regress-GH-io-1811.js | 1 + test/parallel/test-regress-GH-node-9326.js | 1 + test/parallel/test-repl-tab.js | 1 + test/parallel/test-require-json.js | 1 + test/parallel/test-require-process.js | 1 + test/parallel/test-stdin-pause-resume-sync.js | 1 + test/parallel/test-stdin-pause-resume.js | 1 + test/parallel/test-stdin-resume-pause.js | 1 + test/parallel/test-string-decoder-end.js | 1 + test/parallel/test-sync-io-option.js | 1 + test/parallel/test-timer-close.js | 1 + test/parallel/test-timers-non-integer-delay.js | 1 + test/parallel/test-timers-this.js | 1 + test/parallel/test-timers-unref-leak.js | 1 + test/parallel/test-timers-unrefd-interval-still-fires.js | 1 + test/parallel/test-util-log.js | 1 + test/sequential/test-cluster-listening-port.js | 1 + test/sequential/test-vm-timeout-rethrow.js | 1 + 48 files changed, 48 insertions(+) diff --git a/test/parallel/test-arm-math-exp-regress-1376.js b/test/parallel/test-arm-math-exp-regress-1376.js index c1011c564d..c947208bd4 100644 --- a/test/parallel/test-arm-math-exp-regress-1376.js +++ b/test/parallel/test-arm-math-exp-regress-1376.js @@ -2,6 +2,7 @@ // See https://github.com/nodejs/node/issues/1376 // and https://code.google.com/p/v8/issues/detail?id=4019 +require('../common'); Math.abs(-0.5); Math.acos(-0.5); Math.acosh(-0.5); diff --git a/test/parallel/test-bad-unicode.js b/test/parallel/test-bad-unicode.js index 6dcabc8fd4..d2ce9ef010 100644 --- a/test/parallel/test-bad-unicode.js +++ b/test/parallel/test-bad-unicode.js @@ -1,4 +1,5 @@ 'use strict'; +require('../common'); var assert = require('assert'), exception = null; diff --git a/test/parallel/test-beforeexit-event-exit.js b/test/parallel/test-beforeexit-event-exit.js index 43d213a8f9..67676a7990 100644 --- a/test/parallel/test-beforeexit-event-exit.js +++ b/test/parallel/test-beforeexit-event-exit.js @@ -1,4 +1,5 @@ 'use strict'; +require('../common'); var assert = require('assert'); process.on('beforeExit', function() { diff --git a/test/parallel/test-child-process-fork-exec-argv.js b/test/parallel/test-child-process-fork-exec-argv.js index 94703a736a..a7a58452f9 100644 --- a/test/parallel/test-child-process-fork-exec-argv.js +++ b/test/parallel/test-child-process-fork-exec-argv.js @@ -1,4 +1,5 @@ 'use strict'; +require('../common'); var assert = require('assert'); var child_process = require('child_process'); var spawn = child_process.spawn; diff --git a/test/parallel/test-cluster-disconnect-before-exit.js b/test/parallel/test-cluster-disconnect-before-exit.js index 8f63bcd113..eb9ef45fbe 100644 --- a/test/parallel/test-cluster-disconnect-before-exit.js +++ b/test/parallel/test-cluster-disconnect-before-exit.js @@ -1,4 +1,5 @@ 'use strict'; +require('../common'); var cluster = require('cluster'); if (cluster.isMaster) { diff --git a/test/parallel/test-cluster-disconnect-unshared-tcp.js b/test/parallel/test-cluster-disconnect-unshared-tcp.js index a927b5da9f..e05cbf42cf 100644 --- a/test/parallel/test-cluster-disconnect-unshared-tcp.js +++ b/test/parallel/test-cluster-disconnect-unshared-tcp.js @@ -1,4 +1,5 @@ 'use strict'; +require('../common'); process.env.NODE_CLUSTER_SCHED_POLICY = 'none'; var cluster = require('cluster'); diff --git a/test/parallel/test-cluster-disconnect-with-no-workers.js b/test/parallel/test-cluster-disconnect-with-no-workers.js index 1c99461bfa..4c2425d82d 100644 --- a/test/parallel/test-cluster-disconnect-with-no-workers.js +++ b/test/parallel/test-cluster-disconnect-with-no-workers.js @@ -1,4 +1,5 @@ 'use strict'; +require('../common'); var assert = require('assert'); var cluster = require('cluster'); diff --git a/test/parallel/test-cluster-worker-events.js b/test/parallel/test-cluster-worker-events.js index eb986556b6..0efad0e963 100644 --- a/test/parallel/test-cluster-worker-events.js +++ b/test/parallel/test-cluster-worker-events.js @@ -1,4 +1,5 @@ 'use strict'; +require('../common'); var assert = require('assert'); var cluster = require('cluster'); diff --git a/test/parallel/test-cluster-worker-forced-exit.js b/test/parallel/test-cluster-worker-forced-exit.js index 54d2ce8a47..76f5cc69a9 100644 --- a/test/parallel/test-cluster-worker-forced-exit.js +++ b/test/parallel/test-cluster-worker-forced-exit.js @@ -1,4 +1,5 @@ 'use strict'; +require('../common'); var assert = require('assert'); var cluster = require('cluster'); var net = require('net'); diff --git a/test/parallel/test-cluster-worker-isconnected.js b/test/parallel/test-cluster-worker-isconnected.js index 4477278e31..eb3c5892bb 100644 --- a/test/parallel/test-cluster-worker-isconnected.js +++ b/test/parallel/test-cluster-worker-isconnected.js @@ -1,4 +1,5 @@ 'use strict'; +require('../common'); var cluster = require('cluster'); var assert = require('assert'); var util = require('util'); diff --git a/test/parallel/test-cluster-worker-isdead.js b/test/parallel/test-cluster-worker-isdead.js index 045a620a9e..70a9653985 100644 --- a/test/parallel/test-cluster-worker-isdead.js +++ b/test/parallel/test-cluster-worker-isdead.js @@ -1,4 +1,5 @@ 'use strict'; +require('../common'); var cluster = require('cluster'); var assert = require('assert'); var net = require('net'); diff --git a/test/parallel/test-domain-enter-exit.js b/test/parallel/test-domain-enter-exit.js index 5cf0d9c54a..4fcd826c7c 100644 --- a/test/parallel/test-domain-enter-exit.js +++ b/test/parallel/test-domain-enter-exit.js @@ -1,6 +1,7 @@ 'use strict'; // Make sure the domain stack is a stack +require('../common'); var assert = require('assert'); var domain = require('domain'); diff --git a/test/parallel/test-domain-nested.js b/test/parallel/test-domain-nested.js index d0ef072339..68c56d0c3c 100644 --- a/test/parallel/test-domain-nested.js +++ b/test/parallel/test-domain-nested.js @@ -1,6 +1,7 @@ 'use strict'; // Make sure that the nested domains don't cause the domain stack to grow +require('../common'); var assert = require('assert'); var domain = require('domain'); diff --git a/test/parallel/test-domain-safe-exit.js b/test/parallel/test-domain-safe-exit.js index 6661c577b3..f5b03f6ab7 100644 --- a/test/parallel/test-domain-safe-exit.js +++ b/test/parallel/test-domain-safe-exit.js @@ -1,6 +1,7 @@ 'use strict'; // Make sure the domain stack doesn't get clobbered by un-matched .exit() +require('../common'); var assert = require('assert'); var domain = require('domain'); diff --git a/test/parallel/test-event-emitter-errors.js b/test/parallel/test-event-emitter-errors.js index 49203961ac..3effb999b3 100644 --- a/test/parallel/test-event-emitter-errors.js +++ b/test/parallel/test-event-emitter-errors.js @@ -1,4 +1,5 @@ 'use strict'; +require('../common'); var EventEmitter = require('events'); var assert = require('assert'); diff --git a/test/parallel/test-freelist.js b/test/parallel/test-freelist.js index 9a847a5f1f..4f95a3d9b5 100644 --- a/test/parallel/test-freelist.js +++ b/test/parallel/test-freelist.js @@ -2,6 +2,7 @@ // Flags: --expose-internals +require('../common'); const assert = require('assert'); const freelist = require('freelist'); const internalFreelist = require('internal/freelist'); diff --git a/test/parallel/test-http-client-read-in-error.js b/test/parallel/test-http-client-read-in-error.js index 8d74aecb51..142c0ee371 100644 --- a/test/parallel/test-http-client-read-in-error.js +++ b/test/parallel/test-http-client-read-in-error.js @@ -1,4 +1,5 @@ 'use strict'; +require('../common'); var net = require('net'); var http = require('http'); var util = require('util'); diff --git a/test/parallel/test-next-tick-doesnt-hang.js b/test/parallel/test-next-tick-doesnt-hang.js index 5e63463d4d..28797b4280 100644 --- a/test/parallel/test-next-tick-doesnt-hang.js +++ b/test/parallel/test-next-tick-doesnt-hang.js @@ -4,6 +4,7 @@ * does not hang the event loop. If this test times out it has failed. */ +require('../common'); process.nextTick(function() { // Nothing }); diff --git a/test/parallel/test-path-parse-format.js b/test/parallel/test-path-parse-format.js index e90fe217de..709ede698a 100644 --- a/test/parallel/test-path-parse-format.js +++ b/test/parallel/test-path-parse-format.js @@ -1,4 +1,5 @@ 'use strict'; +require('../common'); var assert = require('assert'); var path = require('path'); diff --git a/test/parallel/test-process-argv-0.js b/test/parallel/test-process-argv-0.js index fb6df310e1..3299ec74ea 100644 --- a/test/parallel/test-process-argv-0.js +++ b/test/parallel/test-process-argv-0.js @@ -1,4 +1,5 @@ 'use strict'; +require('../common'); var path = require('path'); var assert = require('assert'); var spawn = require('child_process').spawn; diff --git a/test/parallel/test-process-binding.js b/test/parallel/test-process-binding.js index dad2816d40..5350a8c669 100644 --- a/test/parallel/test-process-binding.js +++ b/test/parallel/test-process-binding.js @@ -1,4 +1,5 @@ 'use strict'; +require('../common'); var assert = require('assert'); assert.throws( diff --git a/test/parallel/test-process-exec-argv.js b/test/parallel/test-process-exec-argv.js index 59c4264ee3..c2b663ac67 100644 --- a/test/parallel/test-process-exec-argv.js +++ b/test/parallel/test-process-exec-argv.js @@ -1,4 +1,5 @@ 'use strict'; +require('../common'); var assert = require('assert'); var spawn = require('child_process').spawn; diff --git a/test/parallel/test-process-exit-recursive.js b/test/parallel/test-process-exit-recursive.js index c1ee13370b..53426a6b1c 100644 --- a/test/parallel/test-process-exit-recursive.js +++ b/test/parallel/test-process-exit-recursive.js @@ -1,4 +1,5 @@ 'use strict'; +require('../common'); var assert = require('assert'); // recursively calling .exit() should not overflow the call stack diff --git a/test/parallel/test-readline-interface.js b/test/parallel/test-readline-interface.js index 5880d02250..6d79879615 100644 --- a/test/parallel/test-readline-interface.js +++ b/test/parallel/test-readline-interface.js @@ -1,4 +1,5 @@ 'use strict'; +require('../common'); var assert = require('assert'); var readline = require('readline'); var EventEmitter = require('events').EventEmitter; diff --git a/test/parallel/test-readline-keys.js b/test/parallel/test-readline-keys.js index 150273f799..5cac38a1d7 100644 --- a/test/parallel/test-readline-keys.js +++ b/test/parallel/test-readline-keys.js @@ -1,4 +1,5 @@ 'use strict'; +require('../common'); var EventEmitter = require('events').EventEmitter; var PassThrough = require('stream').PassThrough; var assert = require('assert'); diff --git a/test/parallel/test-readline-set-raw-mode.js b/test/parallel/test-readline-set-raw-mode.js index f9d5111581..7810dfeda8 100644 --- a/test/parallel/test-readline-set-raw-mode.js +++ b/test/parallel/test-readline-set-raw-mode.js @@ -1,4 +1,5 @@ 'use strict'; +require('../common'); var assert = require('assert'); var readline = require('readline'); var Stream = require('stream'); diff --git a/test/parallel/test-readline-undefined-columns.js b/test/parallel/test-readline-undefined-columns.js index f2baf92184..73945af8bc 100644 --- a/test/parallel/test-readline-undefined-columns.js +++ b/test/parallel/test-readline-undefined-columns.js @@ -1,5 +1,6 @@ 'use strict'; +require('../common'); const assert = require('assert'); const PassThrough = require('stream').PassThrough; const readline = require('readline'); diff --git a/test/parallel/test-regress-GH-4256.js b/test/parallel/test-regress-GH-4256.js index f512e61316..1a4a78b3c0 100644 --- a/test/parallel/test-regress-GH-4256.js +++ b/test/parallel/test-regress-GH-4256.js @@ -1,4 +1,5 @@ 'use strict'; +require('../common'); process.domain = null; var timer = setTimeout(function() { console.log('this console.log statement should not make node crash'); diff --git a/test/parallel/test-regress-GH-5927.js b/test/parallel/test-regress-GH-5927.js index 541820c7a2..a23c947c32 100644 --- a/test/parallel/test-regress-GH-5927.js +++ b/test/parallel/test-regress-GH-5927.js @@ -1,4 +1,5 @@ 'use strict'; +require('../common'); var assert = require('assert'); var readline = require('readline'); diff --git a/test/parallel/test-regress-GH-io-1068.js b/test/parallel/test-regress-GH-io-1068.js index cc91fe28df..a92bb3e752 100644 --- a/test/parallel/test-regress-GH-io-1068.js +++ b/test/parallel/test-regress-GH-io-1068.js @@ -1,2 +1,3 @@ 'use strict'; +require('../common'); process.stdin.emit('end'); diff --git a/test/parallel/test-regress-GH-io-1811.js b/test/parallel/test-regress-GH-io-1811.js index b7c99a17a5..bfbf992433 100644 --- a/test/parallel/test-regress-GH-io-1811.js +++ b/test/parallel/test-regress-GH-io-1811.js @@ -1,5 +1,6 @@ 'use strict'; +require('../common'); const assert = require('assert'); // Change kMaxLength for zlib to trigger the error without having to allocate diff --git a/test/parallel/test-regress-GH-node-9326.js b/test/parallel/test-regress-GH-node-9326.js index 5dc73e044e..bb55050d2c 100644 --- a/test/parallel/test-regress-GH-node-9326.js +++ b/test/parallel/test-regress-GH-node-9326.js @@ -1,4 +1,5 @@ 'use strict'; +require('../common'); var assert = require('assert'); var child_process = require('child_process'); diff --git a/test/parallel/test-repl-tab.js b/test/parallel/test-repl-tab.js index badab2133b..1ab3b47439 100644 --- a/test/parallel/test-repl-tab.js +++ b/test/parallel/test-repl-tab.js @@ -1,4 +1,5 @@ 'use strict'; +require('../common'); var assert = require('assert'); var util = require('util'); var repl = require('repl'); diff --git a/test/parallel/test-require-json.js b/test/parallel/test-require-json.js index 4c17fc8d02..bcb7f6ab7f 100644 --- a/test/parallel/test-require-json.js +++ b/test/parallel/test-require-json.js @@ -1,4 +1,5 @@ 'use strict'; +require('../common'); var assert = require('assert'); try { diff --git a/test/parallel/test-require-process.js b/test/parallel/test-require-process.js index fdd921a611..33634930b4 100644 --- a/test/parallel/test-require-process.js +++ b/test/parallel/test-require-process.js @@ -1,4 +1,5 @@ 'use strict'; +require('../common'); var assert = require('assert'); var nativeProcess = require('process'); diff --git a/test/parallel/test-stdin-pause-resume-sync.js b/test/parallel/test-stdin-pause-resume-sync.js index 4fe4d445a2..c0f41e92de 100644 --- a/test/parallel/test-stdin-pause-resume-sync.js +++ b/test/parallel/test-stdin-pause-resume-sync.js @@ -1,4 +1,5 @@ 'use strict'; +require('../common'); console.error('before opening stdin'); process.stdin.resume(); console.error('stdin opened'); diff --git a/test/parallel/test-stdin-pause-resume.js b/test/parallel/test-stdin-pause-resume.js index 2685deb0e9..a07bf1327d 100644 --- a/test/parallel/test-stdin-pause-resume.js +++ b/test/parallel/test-stdin-pause-resume.js @@ -1,4 +1,5 @@ 'use strict'; +require('../common'); console.error('before opening stdin'); process.stdin.resume(); console.error('stdin opened'); diff --git a/test/parallel/test-stdin-resume-pause.js b/test/parallel/test-stdin-resume-pause.js index 963fd989f0..25bd3d7a2e 100644 --- a/test/parallel/test-stdin-resume-pause.js +++ b/test/parallel/test-stdin-resume-pause.js @@ -1,3 +1,4 @@ 'use strict'; +require('../common'); process.stdin.resume(); process.stdin.pause(); diff --git a/test/parallel/test-string-decoder-end.js b/test/parallel/test-string-decoder-end.js index f931c6abb9..c3afb88d77 100644 --- a/test/parallel/test-string-decoder-end.js +++ b/test/parallel/test-string-decoder-end.js @@ -3,6 +3,7 @@ // the whole buffer at once, and that both match the .toString(enc) // result of the entire buffer. +require('../common'); var assert = require('assert'); var SD = require('string_decoder').StringDecoder; var encodings = ['base64', 'hex', 'utf8', 'utf16le', 'ucs2']; diff --git a/test/parallel/test-sync-io-option.js b/test/parallel/test-sync-io-option.js index bb779a0aa6..d005a3fb69 100644 --- a/test/parallel/test-sync-io-option.js +++ b/test/parallel/test-sync-io-option.js @@ -1,5 +1,6 @@ 'use strict'; +require('../common'); const assert = require('assert'); const execFile = require('child_process').execFile; diff --git a/test/parallel/test-timer-close.js b/test/parallel/test-timer-close.js index 79f06dffa9..9eb70041eb 100644 --- a/test/parallel/test-timer-close.js +++ b/test/parallel/test-timer-close.js @@ -1,4 +1,5 @@ 'use strict'; +require('../common'); var assert = require('assert'); var t = new (process.binding('timer_wrap').Timer); diff --git a/test/parallel/test-timers-non-integer-delay.js b/test/parallel/test-timers-non-integer-delay.js index a3e5420a5e..97b2c0734f 100644 --- a/test/parallel/test-timers-non-integer-delay.js +++ b/test/parallel/test-timers-non-integer-delay.js @@ -15,6 +15,7 @@ * it 100%. */ +require('../common'); var assert = require('assert'); var TIMEOUT_DELAY = 1.1; diff --git a/test/parallel/test-timers-this.js b/test/parallel/test-timers-this.js index df710b9cb8..1882f116fe 100644 --- a/test/parallel/test-timers-this.js +++ b/test/parallel/test-timers-this.js @@ -1,4 +1,5 @@ 'use strict'; +require('../common'); var assert = require('assert'); var immediateThis, intervalThis, timeoutThis, diff --git a/test/parallel/test-timers-unref-leak.js b/test/parallel/test-timers-unref-leak.js index 55907d9bc4..a1b1265763 100644 --- a/test/parallel/test-timers-unref-leak.js +++ b/test/parallel/test-timers-unref-leak.js @@ -1,4 +1,5 @@ 'use strict'; +require('../common'); var assert = require('assert'); var called = 0; diff --git a/test/parallel/test-timers-unrefd-interval-still-fires.js b/test/parallel/test-timers-unrefd-interval-still-fires.js index 50a473b9c8..98bd278b45 100644 --- a/test/parallel/test-timers-unrefd-interval-still-fires.js +++ b/test/parallel/test-timers-unrefd-interval-still-fires.js @@ -2,6 +2,7 @@ /* * This test is a regression test for joyent/node#8900. */ +require('../common'); var assert = require('assert'); var N = 5; diff --git a/test/parallel/test-util-log.js b/test/parallel/test-util-log.js index 9285e3e340..fbea5e5a31 100644 --- a/test/parallel/test-util-log.js +++ b/test/parallel/test-util-log.js @@ -1,4 +1,5 @@ 'use strict'; +require('../common'); var assert = require('assert'); var util = require('util'); diff --git a/test/sequential/test-cluster-listening-port.js b/test/sequential/test-cluster-listening-port.js index eb8a974d04..c9c6538903 100644 --- a/test/sequential/test-cluster-listening-port.js +++ b/test/sequential/test-cluster-listening-port.js @@ -1,4 +1,5 @@ 'use strict'; +require('../common'); var assert = require('assert'); var cluster = require('cluster'); var net = require('net'); diff --git a/test/sequential/test-vm-timeout-rethrow.js b/test/sequential/test-vm-timeout-rethrow.js index 4f3af900ee..dd513b5a69 100644 --- a/test/sequential/test-vm-timeout-rethrow.js +++ b/test/sequential/test-vm-timeout-rethrow.js @@ -1,4 +1,5 @@ 'use strict'; +require('../common'); var assert = require('assert'); var vm = require('vm'); var spawn = require('child_process').spawn;