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 c1011c564d11b6..c947208bd46650 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 6dcabc8fd47b96..d2ce9ef01013db 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 43d213a8f95055..67676a7990041f 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 94703a736a110e..a7a58452f925b0 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 8f63bcd1134310..eb9ef45fbe1306 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 a927b5da9fe1b4..e05cbf42cf1798 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 1c99461bfa4fc5..4c2425d82d656b 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 eb986556b69183..0efad0e963e35c 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 54d2ce8a478303..76f5cc69a9f716 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 4477278e31330a..eb3c5892bb5e21 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 045a620a9efab7..70a96539851398 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 5cf0d9c54a3122..4fcd826c7c9493 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 d0ef072339b8f9..68c56d0c3c8b2c 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 6661c577b30c87..f5b03f6ab7579a 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 49203961ac8d9a..3effb999b37e8c 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 9a847a5f1ff31f..4f95a3d9b5622f 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 8d74aecb51b91c..142c0ee3715aed 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 5e63463d4d1f94..28797b4280e716 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 e90fe217de93ec..709ede698acebc 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 fb6df310e14661..3299ec74ea7dd4 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 dad2816d40c185..5350a8c66932cb 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 59c4264ee3c8b7..c2b663ac67eb60 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 c1ee13370b26ca..53426a6b1cdaf0 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 5880d022502711..6d79879615fa28 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 150273f7993963..5cac38a1d7db42 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 f9d5111581fa90..7810dfeda839d5 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 f2baf92184e37f..73945af8bc52b9 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 f512e613162522..1a4a78b3c0781d 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 541820c7a214c8..a23c947c320cfc 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 cc91fe28df3d3e..a92bb3e75259f0 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 b7c99a17a5cdd5..bfbf99243320d4 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 5dc73e044e560b..bb55050d2ce55e 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 badab2133b7e7e..1ab3b4743913bd 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 4c17fc8d025d73..bcb7f6ab7f3ef8 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 fdd921a61195e5..33634930b4e614 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 4fe4d445a2443e..c0f41e92de5adb 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 2685deb0e9b33c..a07bf1327d2774 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 963fd989f085a3..25bd3d7a2eaf51 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 f931c6abb9864c..c3afb88d778b39 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 bb779a0aa66391..d005a3fb69868c 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 79f06dffa98731..9eb70041eb4b97 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 a3e5420a5e4858..97b2c0734f60d5 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 df710b9cb8d5c9..1882f116fecd2d 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 55907d9bc4898d..a1b1265763bf1d 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 50a473b9c8b4b8..98bd278b451613 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 9285e3e3409e99..fbea5e5a31dbe4 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 eb8a974d04bbf8..c9c65389036ec9 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 4f3af900ee0ae2..dd513b5a694de0 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;