Browse Source

test: make import common as the first line

The `test/common` module has the capability to identify if any variable
is leaked to the global scope and fail the test. So that has to be
imported at the beginning.

PR-URL: https://github.com/nodejs/node/pull/7786
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
v7.x
Sakthipriyan Vairamani 9 years ago
committed by Rich Trott
parent
commit
612307564b
  1. 4
      test/debugger/helper-debugger-repl.js
  2. 2
      test/debugger/test-debug-break-on-uncaught.js
  3. 4
      test/debugger/test-debugger-client.js
  4. 2
      test/disabled/test-dgram-send-error.js
  5. 3
      test/gc/test-http-client-connaborted.js
  6. 3
      test/gc/test-http-client-onerror.js
  7. 3
      test/gc/test-http-client-timeout.js
  8. 3
      test/gc/test-http-client.js
  9. 3
      test/gc/test-net-timeout.js
  10. 2
      test/parallel/test-child-process-disconnect.js
  11. 2
      test/parallel/test-child-process-flush-stdio.js
  12. 2
      test/parallel/test-child-process-fork-close.js
  13. 2
      test/parallel/test-child-process-fork-dgram.js
  14. 2
      test/parallel/test-child-process-fork-exec-path.js
  15. 2
      test/parallel/test-child-process-fork-net2.js
  16. 2
      test/parallel/test-child-process-spawn-typeerror.js
  17. 3
      test/parallel/test-cli-syntax.js
  18. 2
      test/parallel/test-cluster-dgram-1.js
  19. 2
      test/parallel/test-cluster-dgram-2.js
  20. 2
      test/parallel/test-cluster-worker-no-exit.js
  21. 4
      test/parallel/test-debugger-repeat-last.js
  22. 3
      test/parallel/test-debugger-util-regression.js
  23. 2
      test/parallel/test-domain-with-abort-on-uncaught-exception.js
  24. 4
      test/parallel/test-fs-read-stream-fd.js
  25. 2
      test/parallel/test-fs-readfile-unlink.js
  26. 2
      test/parallel/test-https-client-get-url.js
  27. 3
      test/parallel/test-https-req-split.js
  28. 2
      test/parallel/test-https-strict.js
  29. 2
      test/parallel/test-path-makelong.js
  30. 2
      test/parallel/test-process-env.js
  31. 2
      test/parallel/test-process-no-deprecation.js
  32. 2
      test/parallel/test-regress-GH-1899.js
  33. 2
      test/parallel/test-repl-.save.load.js
  34. 2
      test/parallel/test-repl-timeout-throw.js
  35. 2
      test/parallel/test-setproctitle.js
  36. 2
      test/parallel/test-tick-processor.js
  37. 2
      test/parallel/test-timers-blocking-callback.js
  38. 2
      test/parallel/test-timers-nested.js
  39. 2
      test/parallel/test-tls-client-default-ciphers.js
  40. 2
      test/parallel/test-tls-close-error.js
  41. 3
      test/parallel/test-tls-empty-sni-context.js
  42. 2
      test/parallel/test-tls-handshake-error.js
  43. 2
      test/pummel/test-abort-fatal-error.js
  44. 4
      test/pummel/test-regress-GH-814.js
  45. 2
      test/sequential/test-child-process-fork-getconnections.js
  46. 16
      test/sequential/test-init.js

4
test/debugger/helper-debugger-repl.js

@ -1,9 +1,9 @@
'use strict';
process.env.NODE_DEBUGGER_TIMEOUT = 2000;
var common = require('../common');
const common = require('../common');
var assert = require('assert');
var spawn = require('child_process').spawn;
process.env.NODE_DEBUGGER_TIMEOUT = 2000;
var port = common.PORT;
var child;

2
test/debugger/test-debug-break-on-uncaught.js

@ -1,8 +1,8 @@
'use strict';
const common = require('../common');
const path = require('path');
const assert = require('assert');
const spawn = require('child_process').spawn;
const common = require('../common');
const debug = require('_debugger');
var scenarios = [];

4
test/debugger/test-debugger-client.js

@ -1,9 +1,9 @@
'use strict';
process.env.NODE_DEBUGGER_TIMEOUT = 2000;
var common = require('../common');
const common = require('../common');
var assert = require('assert');
var debug = require('_debugger');
process.env.NODE_DEBUGGER_TIMEOUT = 2000;
var debugPort = common.PORT;
debug.port = debugPort;
var spawn = require('child_process').spawn;

2
test/disabled/test-dgram-send-error.js

@ -7,10 +7,10 @@
// we also send packets to ourselves to verify that after receiving an error
// we can still receive packets successfully.
const common = require('../common');
var ITERATIONS = 1000;
var assert = require('assert'),
common = require('../common'),
dgram = require('dgram');
var buf = Buffer.alloc(1024, 42);

3
test/gc/test-http-client-connaborted.js

@ -2,13 +2,14 @@
// just like test/gc/http-client.js,
// but aborting every connection that comes in.
require('../common');
function serverHandler(req, res) {
res.connection.destroy();
}
const http = require('http');
const weak = require('weak');
require('../common');
const assert = require('assert');
const todo = 500;
let done = 0;

3
test/gc/test-http-client-onerror.js

@ -2,6 +2,8 @@
// just like test/gc/http-client.js,
// but with an on('error') handler that does nothing.
require('../common');
function serverHandler(req, res) {
req.resume();
res.writeHead(200, {'Content-Type': 'text/plain'});
@ -10,7 +12,6 @@ function serverHandler(req, res) {
const http = require('http');
const weak = require('weak');
require('../common');
const assert = require('assert');
const todo = 500;
let done = 0;

3
test/gc/test-http-client-timeout.js

@ -2,6 +2,8 @@
// just like test/gc/http-client.js,
// but with a timeout set
require('../common');
function serverHandler(req, res) {
setTimeout(function() {
req.resume();
@ -12,7 +14,6 @@ function serverHandler(req, res) {
const http = require('http');
const weak = require('weak');
require('../common');
const assert = require('assert');
const todo = 550;
let done = 0;

3
test/gc/test-http-client.js

@ -1,6 +1,8 @@
'use strict';
// just a simple http server and client.
require('../common');
function serverHandler(req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
@ -8,7 +10,6 @@ function serverHandler(req, res) {
const http = require('http');
const weak = require('weak');
require('../common');
const assert = require('assert');
const todo = 500;
let done = 0;

3
test/gc/test-net-timeout.js

@ -2,6 +2,8 @@
// just like test/gc/http-client-timeout.js,
// but using a net server/client instead
require('../common');
function serverHandler(sock) {
sock.setTimeout(120000);
sock.resume();
@ -19,7 +21,6 @@ function serverHandler(sock) {
const net = require('net');
const weak = require('weak');
require('../common');
const assert = require('assert');
const todo = 500;
let done = 0;

2
test/parallel/test-child-process-disconnect.js

@ -1,6 +1,6 @@
'use strict';
const common = require('../common');
var assert = require('assert');
var common = require('../common');
var fork = require('child_process').fork;
var net = require('net');

2
test/parallel/test-child-process-flush-stdio.js

@ -1,6 +1,6 @@
'use strict';
const cp = require('child_process');
const common = require('../common');
const cp = require('child_process');
const assert = require('assert');
// Windows' `echo` command is a built-in shell command and not an external

2
test/parallel/test-child-process-fork-close.js

@ -1,6 +1,6 @@
'use strict';
const assert = require('assert');
const common = require('../common');
const assert = require('assert');
const fork = require('child_process').fork;
var cp = fork(common.fixturesDir + '/child-process-message-and-exit.js');

2
test/parallel/test-child-process-fork-dgram.js

@ -13,10 +13,10 @@
* and the test will fail.
*/
const common = require('../common');
var dgram = require('dgram');
var fork = require('child_process').fork;
var assert = require('assert');
var common = require('../common');
if (common.isWindows) {
common.skip('Sending dgram sockets to child processes is ' +

2
test/parallel/test-child-process-fork-exec-path.js

@ -1,8 +1,8 @@
'use strict';
const common = require('../common');
var assert = require('assert');
var fs = require('fs');
var path = require('path');
var common = require('../common');
var msg = {test: 'this'};
var nodePath = process.execPath;
var copyPath = path.join(common.tmpDir, 'node-copy.exe');

2
test/parallel/test-child-process-fork-net2.js

@ -1,6 +1,6 @@
'use strict';
const common = require('../common');
var assert = require('assert');
var common = require('../common');
var fork = require('child_process').fork;
var net = require('net');
var count = 12;

2
test/parallel/test-child-process-spawn-typeerror.js

@ -1,10 +1,10 @@
'use strict';
const common = require('../common');
const assert = require('assert');
const child_process = require('child_process');
const spawn = child_process.spawn;
const fork = child_process.fork;
const execFile = child_process.execFile;
const common = require('../common');
const cmd = common.isWindows ? 'rundll32' : 'ls';
const invalidcmd = 'hopefully_you_dont_have_this_on_your_machine';
const invalidArgsMsg = /Incorrect value of args option/;

3
test/parallel/test-cli-syntax.js

@ -1,11 +1,10 @@
'use strict';
const common = require('../common');
const assert = require('assert');
const spawnSync = require('child_process').spawnSync;
const path = require('path');
const common = require('../common');
var node = process.execPath;
// test both sets of arguments that check syntax

2
test/parallel/test-cluster-dgram-1.js

@ -1,10 +1,10 @@
'use strict';
const common = require('../common');
var NUM_WORKERS = 4;
var PACKETS_PER_WORKER = 10;
var assert = require('assert');
var cluster = require('cluster');
var common = require('../common');
var dgram = require('dgram');

2
test/parallel/test-cluster-dgram-2.js

@ -1,9 +1,9 @@
'use strict';
const common = require('../common');
var NUM_WORKERS = 4;
var PACKETS_PER_WORKER = 10;
var cluster = require('cluster');
var common = require('../common');
var dgram = require('dgram');

2
test/parallel/test-cluster-worker-no-exit.js

@ -1,8 +1,8 @@
'use strict';
const common = require('../common');
var assert = require('assert');
var cluster = require('cluster');
var net = require('net');
var common = require('../common');
var destroyed;
var success;

4
test/parallel/test-debugger-repeat-last.js

@ -1,10 +1,8 @@
'use strict';
const common = require('../common');
const path = require('path');
const spawn = require('child_process').spawn;
const assert = require('assert');
const common = require('../common');
const fixture = path.join(
common.fixturesDir,
'debugger-repeat-last.js'

3
test/parallel/test-debugger-util-regression.js

@ -1,10 +1,9 @@
'use strict';
const common = require('../common');
const path = require('path');
const spawn = require('child_process').spawn;
const assert = require('assert');
const common = require('../common');
const fixture = path.join(
common.fixturesDir,
'debugger-util-regression-fixture.js'

2
test/parallel/test-domain-with-abort-on-uncaught-exception.js

@ -1,8 +1,8 @@
'use strict';
const common = require('../common');
const assert = require('assert');
const fs = require('fs');
const common = require('../common');
/*
* The goal of this test is to make sure that:

4
test/parallel/test-fs-read-stream-fd.js

@ -1,10 +1,8 @@
'use strict';
const common = require('../common');
var fs = require('fs');
var assert = require('assert');
var path = require('path');
var common = require('../common');
var file = path.join(common.tmpDir, '/read_stream_fd_test.txt');
var input = 'hello world';
var output = '';

2
test/parallel/test-fs-readfile-unlink.js

@ -1,6 +1,6 @@
'use strict';
const assert = require('assert');
const common = require('../common');
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const dirName = path.resolve(common.fixturesDir, 'test-readfile-unlink');

2
test/parallel/test-https-client-get-url.js

@ -1,8 +1,8 @@
'use strict';
const common = require('../common');
// disable strict server certificate validation by the client
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
var common = require('../common');
var assert = require('assert');
if (!common.hasCrypto) {

3
test/parallel/test-https-req-split.js

@ -1,9 +1,8 @@
'use strict';
const common = require('../common');
// disable strict server certificate validation by the client
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
var common = require('../common');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;

2
test/parallel/test-https-strict.js

@ -1,8 +1,8 @@
'use strict';
const common = require('../common');
// disable strict server certificate validation by the client
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
var common = require('../common');
var assert = require('assert');
if (!common.hasCrypto) {

2
test/parallel/test-path-makelong.js

@ -1,7 +1,7 @@
'use strict';
const common = require('../common');
var assert = require('assert');
var path = require('path');
var common = require('../common');
if (common.isWindows) {
var file = path.join(common.fixturesDir, 'a.js');

2
test/parallel/test-process-env.js

@ -1,10 +1,10 @@
'use strict';
/* eslint-disable max-len */
require('../common');
// first things first, set the timezone; see tzset(3)
process.env.TZ = 'Europe/Amsterdam';
require('../common');
var assert = require('assert');
var spawn = require('child_process').spawn;

2
test/parallel/test-process-no-deprecation.js

@ -4,9 +4,9 @@
// The --no-warnings flag only supresses writing the warning to stderr, not the
// emission of the corresponding event. This test file can be run without it.
const common = require('../common');
process.noDeprecation = true;
const common = require('../common');
const assert = require('assert');
function listener() {

2
test/parallel/test-regress-GH-1899.js

@ -1,8 +1,8 @@
'use strict';
const common = require('../common');
var path = require('path');
var assert = require('assert');
var spawn = require('child_process').spawn;
var common = require('../common');
var child = spawn(process.argv[0], [
path.join(common.fixturesDir, 'GH-1899-output.js')

2
test/parallel/test-repl-.save.load.js

@ -1,8 +1,8 @@
'use strict';
const common = require('../common');
var assert = require('assert');
var join = require('path').join;
var fs = require('fs');
var common = require('../common');
common.refreshTmpDir();

2
test/parallel/test-repl-timeout-throw.js

@ -1,6 +1,6 @@
'use strict';
const common = require('../common');
var assert = require('assert');
var common = require('../common');
var spawn = require('child_process').spawn;

2
test/parallel/test-setproctitle.js

@ -1,13 +1,13 @@
'use strict';
// Original test written by Jakub Lekstan <kuebzky@gmail.com>
require('../common');
// FIXME add sunos support
if ('linux freebsd darwin'.indexOf(process.platform) === -1) {
console.log(`1..0 # Skipped: Unsupported platform [${process.platform}]`);
return;
}
require('../common');
var assert = require('assert');
var exec = require('child_process').exec;
var path = require('path');

2
test/parallel/test-tick-processor.js

@ -1,8 +1,8 @@
'use strict';
const common = require('../common');
const fs = require('fs');
const assert = require('assert');
const cp = require('child_process');
const common = require('../common');
// TODO(mhdawson) Currently the test-tick-processor functionality in V8
// depends on addresses being smaller than a full 64 bits. Aix supports

2
test/parallel/test-timers-blocking-callback.js

@ -22,8 +22,8 @@
* is not empty (see testAddingTimerToNonEmptyTimersList).
*/
const assert = require('assert');
const common = require('../common');
const assert = require('assert');
const Timer = process.binding('timer_wrap').Timer;
const TIMEOUT = 100;

2
test/parallel/test-timers-nested.js

@ -1,7 +1,7 @@
'use strict';
const assert = require('assert');
const common = require('../common');
const assert = require('assert');
// Make sure we test 0ms timers, since they would had always wanted to run on
// the current tick, and greater than 0ms timers, for scenarios where the

2
test/parallel/test-tls-client-default-ciphers.js

@ -1,6 +1,6 @@
'use strict';
const common = require('../common');
var assert = require('assert');
var common = require('../common');
if (!common.hasCrypto) {
common.skip('missing crypto');

2
test/parallel/test-tls-close-error.js

@ -1,7 +1,7 @@
'use strict';
const common = require('../common');
var assert = require('assert');
var common = require('../common');
if (!common.hasCrypto) {
common.skip('missing crypto');

3
test/parallel/test-tls-empty-sni-context.js

@ -1,12 +1,13 @@
'use strict';
const common = require('../common');
if (!process.features.tls_sni) {
console.log('1..0 # Skipped: node compiled without OpenSSL or ' +
'with old OpenSSL version.');
return;
}
const common = require('../common');
const assert = require('assert');
if (!common.hasCrypto) {

2
test/parallel/test-tls-handshake-error.js

@ -1,7 +1,7 @@
'use strict';
const common = require('../common');
var assert = require('assert');
var common = require('../common');
if (!common.hasCrypto) {
common.skip('missing crypto');

2
test/pummel/test-abort-fatal-error.js

@ -1,6 +1,6 @@
'use strict';
const common = require('../common');
var assert = require('assert');
var common = require('../common');
if (common.isWindows) {
common.skip('no RLIMIT_NOFILE on Windows');

4
test/pummel/test-regress-GH-814.js

@ -1,6 +1,8 @@
'use strict';
// Flags: --expose_gc
const common = require('../common');
function newBuffer(size, value) {
var buffer = Buffer.allocUnsafe(size);
while (size--) {
@ -11,8 +13,6 @@ function newBuffer(size, value) {
return buffer;
}
var common = require('../common');
var fs = require('fs');
var testFileName = require('path').join(common.tmpDir, 'GH-814_testFile.txt');
var testFileFD = fs.openSync(testFileName, 'w');

2
test/sequential/test-child-process-fork-getconnections.js

@ -1,6 +1,6 @@
'use strict';
const assert = require('assert');
const common = require('../common');
const assert = require('assert');
const fork = require('child_process').fork;
const net = require('net');
const count = 12;

16
test/sequential/test-init.js

@ -1,12 +1,11 @@
'use strict';
(function() {
const assert = require('assert');
const child = require('child_process');
const util = require('util');
const common = require('../common');
if (process.env['TEST_INIT']) {
const common = require('../common');
const assert = require('assert');
const child = require('child_process');
const util = require('util');
if (process.env['TEST_INIT']) {
util.print('Loaded successfully!');
} else {
} else {
// change CWD as we do this test so its not dependant on current CWD
// being in the test folder
process.chdir(__dirname);
@ -45,5 +44,4 @@
assert.equal(stdout, 'fs loaded successfully',
'`node fs` failed!');
});
}
})();
}

Loading…
Cancel
Save