Skip to content

Commit

Permalink
test: make import common as the first line
Browse files Browse the repository at this point in the history
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: #7786
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
thefourtheye authored and evanlucas committed Aug 2, 2016
1 parent 6e6cf36 commit 1ab6df6
Show file tree
Hide file tree
Showing 46 changed files with 94 additions and 97 deletions.
4 changes: 2 additions & 2 deletions test/debugger/helper-debugger-repl.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion test/debugger/test-debug-break-on-uncaught.js
Original file line number Diff line number Diff line change
@@ -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 = [];
Expand Down
4 changes: 2 additions & 2 deletions test/debugger/test-debugger-client.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion test/disabled/test-dgram-send-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion test/gc/test-http-client-connaborted.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion test/gc/test-http-client-onerror.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'});
Expand All @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion test/gc/test-http-client-timeout.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion test/gc/test-http-client.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
'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');
}

const http = require('http');
const weak = require('weak');
require('../common');
const assert = require('assert');
const todo = 500;
let done = 0;
Expand Down
3 changes: 2 additions & 1 deletion test/gc/test-net-timeout.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-child-process-disconnect.js
Original file line number Diff line number Diff line change
@@ -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');

Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-child-process-flush-stdio.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-child-process-fork-close.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-child-process-fork-dgram.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ' +
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-child-process-fork-exec-path.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-child-process-fork-net2.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-child-process-spawn-typeerror.js
Original file line number Diff line number Diff line change
@@ -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/;
Expand Down
3 changes: 1 addition & 2 deletions test/parallel/test-cli-syntax.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-cluster-dgram-1.js
Original file line number Diff line number Diff line change
@@ -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');


Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-cluster-dgram-2.js
Original file line number Diff line number Diff line change
@@ -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');


Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-cluster-worker-no-exit.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
4 changes: 1 addition & 3 deletions test/parallel/test-debugger-repeat-last.js
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
3 changes: 1 addition & 2 deletions test/parallel/test-debugger-util-regression.js
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
4 changes: 1 addition & 3 deletions test/parallel/test-fs-read-stream-fd.js
Original file line number Diff line number Diff line change
@@ -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 = '';
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-fs-readfile-unlink.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-https-client-get-url.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
3 changes: 1 addition & 2 deletions test/parallel/test-https-req-split.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-https-strict.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-path-makelong.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-process-env.js
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-process-no-deprecation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-regress-GH-1899.js
Original file line number Diff line number Diff line change
@@ -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')
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-repl-.save.load.js
Original file line number Diff line number Diff line change
@@ -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();

Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-repl-timeout-throw.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';
const common = require('../common');
var assert = require('assert');
var common = require('../common');

var spawn = require('child_process').spawn;

Expand Down
Loading

0 comments on commit 1ab6df6

Please sign in to comment.