Skip to content

Commit

Permalink
test: load common.js to test for global leaks
Browse files Browse the repository at this point in the history
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: #3095
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
  • Loading branch information
Trott committed Oct 2, 2015
1 parent 9bd26e7 commit 02fe821
Show file tree
Hide file tree
Showing 48 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/parallel/test-arm-math-exp-regress-1376.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-bad-unicode.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
require('../common');
var assert = require('assert'),
exception = null;

Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-beforeexit-event-exit.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
require('../common');
var assert = require('assert');

process.on('beforeExit', function() {
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-child-process-fork-exec-argv.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
require('../common');
var assert = require('assert');
var child_process = require('child_process');
var spawn = child_process.spawn;
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-cluster-disconnect-before-exit.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
require('../common');
var cluster = require('cluster');

if (cluster.isMaster) {
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-cluster-disconnect-unshared-tcp.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
require('../common');
process.env.NODE_CLUSTER_SCHED_POLICY = 'none';

var cluster = require('cluster');
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-cluster-disconnect-with-no-workers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
require('../common');
var assert = require('assert');
var cluster = require('cluster');

Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-cluster-worker-events.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
require('../common');
var assert = require('assert');
var cluster = require('cluster');

Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-cluster-worker-forced-exit.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
require('../common');
var assert = require('assert');
var cluster = require('cluster');
var net = require('net');
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-cluster-worker-isconnected.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
require('../common');
var cluster = require('cluster');
var assert = require('assert');
var util = require('util');
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-cluster-worker-isdead.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
require('../common');
var cluster = require('cluster');
var assert = require('assert');
var net = require('net');
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-domain-enter-exit.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';
// Make sure the domain stack is a stack

require('../common');
var assert = require('assert');
var domain = require('domain');

Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-domain-nested.js
Original file line number Diff line number Diff line change
@@ -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');

Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-domain-safe-exit.js
Original file line number Diff line number Diff line change
@@ -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');

Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-event-emitter-errors.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
require('../common');
var EventEmitter = require('events');
var assert = require('assert');

Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-freelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

// Flags: --expose-internals

require('../common');
const assert = require('assert');
const freelist = require('freelist');
const internalFreelist = require('internal/freelist');
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-http-client-read-in-error.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
require('../common');
var net = require('net');
var http = require('http');
var util = require('util');
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-next-tick-doesnt-hang.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* does not hang the event loop. If this test times out it has failed.
*/

require('../common');
process.nextTick(function() {
// Nothing
});
1 change: 1 addition & 0 deletions test/parallel/test-path-parse-format.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
require('../common');
var assert = require('assert');
var path = require('path');

Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-process-argv-0.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
require('../common');
var path = require('path');
var assert = require('assert');
var spawn = require('child_process').spawn;
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-process-binding.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
require('../common');
var assert = require('assert');

assert.throws(
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-process-exec-argv.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
require('../common');
var assert = require('assert');
var spawn = require('child_process').spawn;

Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-process-exit-recursive.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
require('../common');
var assert = require('assert');

// recursively calling .exit() should not overflow the call stack
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-readline-interface.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
require('../common');
var assert = require('assert');
var readline = require('readline');
var EventEmitter = require('events').EventEmitter;
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-readline-keys.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
require('../common');
var EventEmitter = require('events').EventEmitter;
var PassThrough = require('stream').PassThrough;
var assert = require('assert');
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-readline-set-raw-mode.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
require('../common');
var assert = require('assert');
var readline = require('readline');
var Stream = require('stream');
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-readline-undefined-columns.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';

require('../common');
const assert = require('assert');
const PassThrough = require('stream').PassThrough;
const readline = require('readline');
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-regress-GH-4256.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-regress-GH-5927.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
require('../common');
var assert = require('assert');
var readline = require('readline');

Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-regress-GH-io-1068.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
'use strict';
require('../common');
process.stdin.emit('end');
1 change: 1 addition & 0 deletions test/parallel/test-regress-GH-io-1811.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';

require('../common');
const assert = require('assert');

// Change kMaxLength for zlib to trigger the error without having to allocate
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-regress-GH-node-9326.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
require('../common');
var assert = require('assert');
var child_process = require('child_process');

Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-repl-tab.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
require('../common');
var assert = require('assert');
var util = require('util');
var repl = require('repl');
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-require-json.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
require('../common');
var assert = require('assert');

try {
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-require-process.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
require('../common');
var assert = require('assert');

var nativeProcess = require('process');
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-stdin-pause-resume-sync.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
require('../common');
console.error('before opening stdin');
process.stdin.resume();
console.error('stdin opened');
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-stdin-pause-resume.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
require('../common');
console.error('before opening stdin');
process.stdin.resume();
console.error('stdin opened');
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-stdin-resume-pause.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use strict';
require('../common');
process.stdin.resume();
process.stdin.pause();
1 change: 1 addition & 0 deletions test/parallel/test-string-decoder-end.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-sync-io-option.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';

require('../common');
const assert = require('assert');
const execFile = require('child_process').execFile;

Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-timer-close.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
require('../common');
var assert = require('assert');

var t = new (process.binding('timer_wrap').Timer);
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-timers-non-integer-delay.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* it 100%.
*/

require('../common');
var assert = require('assert');

var TIMEOUT_DELAY = 1.1;
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-timers-this.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
require('../common');
var assert = require('assert');

var immediateThis, intervalThis, timeoutThis,
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-timers-unref-leak.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
require('../common');
var assert = require('assert');

var called = 0;
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-timers-unrefd-interval-still-fires.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/*
* This test is a regression test for joyent/node#8900.
*/
require('../common');
var assert = require('assert');

var N = 5;
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-util-log.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
require('../common');
var assert = require('assert');
var util = require('util');

Expand Down
1 change: 1 addition & 0 deletions test/sequential/test-cluster-listening-port.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
require('../common');
var assert = require('assert');
var cluster = require('cluster');
var net = require('net');
Expand Down
1 change: 1 addition & 0 deletions test/sequential/test-vm-timeout-rethrow.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
require('../common');
var assert = require('assert');
var vm = require('vm');
var spawn = require('child_process').spawn;
Expand Down

4 comments on commit 02fe821

@ronkorving
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the test suite not just require common on Node startup through --require? That way no-one can ever forget. Perhaps then it would also make sense to split up common.js into the logic that checks for globals (loadable through --require), and the properties that are currently exported in common.js. Then no single test-file should ever have to require a file that it doesn't directly use.

@thefourtheye
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ronkorving That has already been tried. Check this @bnoordhuis's comment #2836 (comment)

@ronkorving
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, sorry for the noise.

@thefourtheye
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem :-)

Please sign in to comment.