Skip to content

Commit 1ab6df6

Browse files
thefourtheyeevanlucas
authored andcommitted
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: #7786 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent 6e6cf36 commit 1ab6df6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+94
-97
lines changed

test/debugger/helper-debugger-repl.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
'use strict';
2-
process.env.NODE_DEBUGGER_TIMEOUT = 2000;
3-
var common = require('../common');
2+
const common = require('../common');
43
var assert = require('assert');
54
var spawn = require('child_process').spawn;
65

6+
process.env.NODE_DEBUGGER_TIMEOUT = 2000;
77
var port = common.PORT;
88

99
var child;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
'use strict';
2+
const common = require('../common');
23
const path = require('path');
34
const assert = require('assert');
45
const spawn = require('child_process').spawn;
5-
const common = require('../common');
66
const debug = require('_debugger');
77

88
var scenarios = [];

test/debugger/test-debugger-client.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
'use strict';
2-
process.env.NODE_DEBUGGER_TIMEOUT = 2000;
3-
var common = require('../common');
2+
const common = require('../common');
43
var assert = require('assert');
54
var debug = require('_debugger');
65

6+
process.env.NODE_DEBUGGER_TIMEOUT = 2000;
77
var debugPort = common.PORT;
88
debug.port = debugPort;
99
var spawn = require('child_process').spawn;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
// we also send packets to ourselves to verify that after receiving an error
88
// we can still receive packets successfully.
99

10+
const common = require('../common');
1011
var ITERATIONS = 1000;
1112

1213
var assert = require('assert'),
13-
common = require('../common'),
1414
dgram = require('dgram');
1515

1616
var buf = Buffer.alloc(1024, 42);

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
// just like test/gc/http-client.js,
33
// but aborting every connection that comes in.
44

5+
require('../common');
6+
57
function serverHandler(req, res) {
68
res.connection.destroy();
79
}
810

911
const http = require('http');
1012
const weak = require('weak');
11-
require('../common');
1213
const assert = require('assert');
1314
const todo = 500;
1415
let done = 0;

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// just like test/gc/http-client.js,
33
// but with an on('error') handler that does nothing.
44

5+
require('../common');
6+
57
function serverHandler(req, res) {
68
req.resume();
79
res.writeHead(200, {'Content-Type': 'text/plain'});
@@ -10,7 +12,6 @@ function serverHandler(req, res) {
1012

1113
const http = require('http');
1214
const weak = require('weak');
13-
require('../common');
1415
const assert = require('assert');
1516
const todo = 500;
1617
let done = 0;

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// just like test/gc/http-client.js,
33
// but with a timeout set
44

5+
require('../common');
6+
57
function serverHandler(req, res) {
68
setTimeout(function() {
79
req.resume();
@@ -12,7 +14,6 @@ function serverHandler(req, res) {
1214

1315
const http = require('http');
1416
const weak = require('weak');
15-
require('../common');
1617
const assert = require('assert');
1718
const todo = 550;
1819
let done = 0;

test/gc/test-http-client.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
'use strict';
22
// just a simple http server and client.
33

4+
require('../common');
5+
46
function serverHandler(req, res) {
57
res.writeHead(200, {'Content-Type': 'text/plain'});
68
res.end('Hello World\n');
79
}
810

911
const http = require('http');
1012
const weak = require('weak');
11-
require('../common');
1213
const assert = require('assert');
1314
const todo = 500;
1415
let done = 0;

test/gc/test-net-timeout.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// just like test/gc/http-client-timeout.js,
33
// but using a net server/client instead
44

5+
require('../common');
6+
57
function serverHandler(sock) {
68
sock.setTimeout(120000);
79
sock.resume();
@@ -19,7 +21,6 @@ function serverHandler(sock) {
1921

2022
const net = require('net');
2123
const weak = require('weak');
22-
require('../common');
2324
const assert = require('assert');
2425
const todo = 500;
2526
let done = 0;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
2+
const common = require('../common');
23
var assert = require('assert');
3-
var common = require('../common');
44
var fork = require('child_process').fork;
55
var net = require('net');
66

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
2-
const cp = require('child_process');
32
const common = require('../common');
3+
const cp = require('child_process');
44
const assert = require('assert');
55

66
// Windows' `echo` command is a built-in shell command and not an external

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
2-
const assert = require('assert');
32
const common = require('../common');
3+
const assert = require('assert');
44
const fork = require('child_process').fork;
55

66
var cp = fork(common.fixturesDir + '/child-process-message-and-exit.js');

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
* and the test will fail.
1414
*/
1515

16+
const common = require('../common');
1617
var dgram = require('dgram');
1718
var fork = require('child_process').fork;
1819
var assert = require('assert');
19-
var common = require('../common');
2020

2121
if (common.isWindows) {
2222
common.skip('Sending dgram sockets to child processes is ' +

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
'use strict';
2+
const common = require('../common');
23
var assert = require('assert');
34
var fs = require('fs');
45
var path = require('path');
5-
var common = require('../common');
66
var msg = {test: 'this'};
77
var nodePath = process.execPath;
88
var copyPath = path.join(common.tmpDir, 'node-copy.exe');

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
2+
const common = require('../common');
23
var assert = require('assert');
3-
var common = require('../common');
44
var fork = require('child_process').fork;
55
var net = require('net');
66
var count = 12;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
'use strict';
2+
const common = require('../common');
23
const assert = require('assert');
34
const child_process = require('child_process');
45
const spawn = child_process.spawn;
56
const fork = child_process.fork;
67
const execFile = child_process.execFile;
7-
const common = require('../common');
88
const cmd = common.isWindows ? 'rundll32' : 'ls';
99
const invalidcmd = 'hopefully_you_dont_have_this_on_your_machine';
1010
const invalidArgsMsg = /Incorrect value of args option/;

test/parallel/test-cli-syntax.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
'use strict';
22

3+
const common = require('../common');
34
const assert = require('assert');
45
const spawnSync = require('child_process').spawnSync;
56
const path = require('path');
67

7-
const common = require('../common');
8-
98
var node = process.execPath;
109

1110
// test both sets of arguments that check syntax

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
'use strict';
2+
const common = require('../common');
23
var NUM_WORKERS = 4;
34
var PACKETS_PER_WORKER = 10;
45

56
var assert = require('assert');
67
var cluster = require('cluster');
7-
var common = require('../common');
88
var dgram = require('dgram');
99

1010

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
'use strict';
2+
const common = require('../common');
23
var NUM_WORKERS = 4;
34
var PACKETS_PER_WORKER = 10;
45

56
var cluster = require('cluster');
6-
var common = require('../common');
77
var dgram = require('dgram');
88

99

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
'use strict';
2+
const common = require('../common');
23
var assert = require('assert');
34
var cluster = require('cluster');
45
var net = require('net');
5-
var common = require('../common');
66

77
var destroyed;
88
var success;

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
'use strict';
2+
const common = require('../common');
23
const path = require('path');
34
const spawn = require('child_process').spawn;
45
const assert = require('assert');
5-
6-
const common = require('../common');
7-
86
const fixture = path.join(
97
common.fixturesDir,
108
'debugger-repeat-last.js'

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
'use strict';
2+
const common = require('../common');
23
const path = require('path');
34
const spawn = require('child_process').spawn;
45
const assert = require('assert');
56

6-
const common = require('../common');
7-
87
const fixture = path.join(
98
common.fixturesDir,
109
'debugger-util-regression-fixture.js'

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
'use strict';
22

3+
const common = require('../common');
34
const assert = require('assert');
45
const fs = require('fs');
5-
const common = require('../common');
66

77
/*
88
* The goal of this test is to make sure that:

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
'use strict';
2+
const common = require('../common');
23
var fs = require('fs');
34
var assert = require('assert');
45
var path = require('path');
5-
6-
var common = require('../common');
7-
86
var file = path.join(common.tmpDir, '/read_stream_fd_test.txt');
97
var input = 'hello world';
108
var output = '';

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
2-
const assert = require('assert');
32
const common = require('../common');
3+
const assert = require('assert');
44
const fs = require('fs');
55
const path = require('path');
66
const dirName = path.resolve(common.fixturesDir, 'test-readfile-unlink');

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
'use strict';
2+
const common = require('../common');
23
// disable strict server certificate validation by the client
34
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
45

5-
var common = require('../common');
66
var assert = require('assert');
77

88
if (!common.hasCrypto) {

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
'use strict';
2+
const common = require('../common');
23
// disable strict server certificate validation by the client
34
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
45

5-
var common = require('../common');
6-
76
if (!common.hasCrypto) {
87
common.skip('missing crypto');
98
return;

test/parallel/test-https-strict.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
'use strict';
2+
const common = require('../common');
23
// disable strict server certificate validation by the client
34
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
45

5-
var common = require('../common');
66
var assert = require('assert');
77

88
if (!common.hasCrypto) {

test/parallel/test-path-makelong.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
2+
const common = require('../common');
23
var assert = require('assert');
34
var path = require('path');
4-
var common = require('../common');
55

66
if (common.isWindows) {
77
var file = path.join(common.fixturesDir, 'a.js');

test/parallel/test-process-env.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
'use strict';
22
/* eslint-disable max-len */
33

4+
require('../common');
45
// first things first, set the timezone; see tzset(3)
56
process.env.TZ = 'Europe/Amsterdam';
67

7-
require('../common');
88
var assert = require('assert');
99
var spawn = require('child_process').spawn;
1010

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
// The --no-warnings flag only supresses writing the warning to stderr, not the
55
// emission of the corresponding event. This test file can be run without it.
66

7+
const common = require('../common');
78
process.noDeprecation = true;
89

9-
const common = require('../common');
1010
const assert = require('assert');
1111

1212
function listener() {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
'use strict';
2+
const common = require('../common');
23
var path = require('path');
34
var assert = require('assert');
45
var spawn = require('child_process').spawn;
5-
var common = require('../common');
66

77
var child = spawn(process.argv[0], [
88
path.join(common.fixturesDir, 'GH-1899-output.js')

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
'use strict';
2+
const common = require('../common');
23
var assert = require('assert');
34
var join = require('path').join;
45
var fs = require('fs');
5-
var common = require('../common');
66

77
common.refreshTmpDir();
88

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
2+
const common = require('../common');
23
var assert = require('assert');
3-
var common = require('../common');
44

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

0 commit comments

Comments
 (0)