From 659160a94fcadee374807378183b1f7a60a1b909 Mon Sep 17 00:00:00 2001 From: Sakthipriyan Vairamani Date: Tue, 19 Jul 2016 02:03:42 +0530 Subject: [PATCH] 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. --- test/debugger/helper-debugger-repl.js | 4 +- test/debugger/test-debug-break-on-uncaught.js | 2 +- test/debugger/test-debugger-client.js | 4 +- test/disabled/test-dgram-send-error.js | 2 +- test/gc/test-http-client-connaborted.js | 3 +- test/gc/test-http-client-onerror.js | 3 +- test/gc/test-http-client-timeout.js | 3 +- test/gc/test-http-client.js | 3 +- test/gc/test-net-timeout.js | 3 +- .../parallel/test-child-process-disconnect.js | 2 +- .../test-child-process-flush-stdio.js | 2 +- .../parallel/test-child-process-fork-close.js | 2 +- .../parallel/test-child-process-fork-dgram.js | 2 +- .../test-child-process-fork-exec-path.js | 2 +- test/parallel/test-child-process-fork-net2.js | 2 +- .../test-child-process-spawn-typeerror.js | 2 +- test/parallel/test-cli-syntax.js | 3 +- test/parallel/test-cluster-dgram-1.js | 2 +- test/parallel/test-cluster-dgram-2.js | 2 +- test/parallel/test-cluster-worker-no-exit.js | 2 +- test/parallel/test-debugger-repeat-last.js | 4 +- .../parallel/test-debugger-util-regression.js | 3 +- ...domain-with-abort-on-uncaught-exception.js | 2 +- test/parallel/test-fs-read-stream-fd.js | 4 +- test/parallel/test-fs-readfile-unlink.js | 2 +- test/parallel/test-https-client-get-url.js | 2 +- test/parallel/test-https-req-split.js | 3 +- test/parallel/test-https-strict.js | 2 +- test/parallel/test-path-makelong.js | 2 +- test/parallel/test-process-env.js | 2 +- test/parallel/test-process-no-deprecation.js | 2 +- test/parallel/test-regress-GH-1899.js | 2 +- test/parallel/test-repl-.save.load.js | 2 +- test/parallel/test-repl-timeout-throw.js | 2 +- test/parallel/test-setproctitle.js | 2 +- test/parallel/test-tick-processor.js | 2 +- .../parallel/test-timers-blocking-callback.js | 2 +- test/parallel/test-timers-nested.js | 2 +- .../test-tls-client-default-ciphers.js | 2 +- test/parallel/test-tls-close-error.js | 2 +- test/parallel/test-tls-empty-sni-context.js | 3 +- test/parallel/test-tls-handshake-error.js | 2 +- test/pummel/test-abort-fatal-error.js | 2 +- test/pummel/test-regress-GH-814.js | 4 +- .../test-child-process-fork-getconnections.js | 2 +- test/sequential/test-init.js | 82 +++++++++---------- 46 files changed, 94 insertions(+), 97 deletions(-) diff --git a/test/debugger/helper-debugger-repl.js b/test/debugger/helper-debugger-repl.js index 766c6566f7e4c0..d7a5e745de0ebd 100644 --- a/test/debugger/helper-debugger-repl.js +++ b/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; diff --git a/test/debugger/test-debug-break-on-uncaught.js b/test/debugger/test-debug-break-on-uncaught.js index 4a63751aaf2857..4b4602657cca0d 100644 --- a/test/debugger/test-debug-break-on-uncaught.js +++ b/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 = []; diff --git a/test/debugger/test-debugger-client.js b/test/debugger/test-debugger-client.js index da2c2b839282b5..fbe7ad1f0609be 100644 --- a/test/debugger/test-debugger-client.js +++ b/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; diff --git a/test/disabled/test-dgram-send-error.js b/test/disabled/test-dgram-send-error.js index 0b68af3a0ff08a..271e6689046a00 100644 --- a/test/disabled/test-dgram-send-error.js +++ b/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); diff --git a/test/gc/test-http-client-connaborted.js b/test/gc/test-http-client-connaborted.js index ec8af1472da592..bc3308bf07d908 100644 --- a/test/gc/test-http-client-connaborted.js +++ b/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; diff --git a/test/gc/test-http-client-onerror.js b/test/gc/test-http-client-onerror.js index 3746926c2bb5b1..28fd5765d06dc3 100644 --- a/test/gc/test-http-client-onerror.js +++ b/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; diff --git a/test/gc/test-http-client-timeout.js b/test/gc/test-http-client-timeout.js index 7b65e7ccb94894..5a1175f3b05b10 100644 --- a/test/gc/test-http-client-timeout.js +++ b/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; diff --git a/test/gc/test-http-client.js b/test/gc/test-http-client.js index 8301caa861a1a8..a0ffab34867138 100644 --- a/test/gc/test-http-client.js +++ b/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; diff --git a/test/gc/test-net-timeout.js b/test/gc/test-net-timeout.js index 2645ccc5038d91..5618cab5b39d73 100644 --- a/test/gc/test-net-timeout.js +++ b/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; diff --git a/test/parallel/test-child-process-disconnect.js b/test/parallel/test-child-process-disconnect.js index ad63cbb78bad8e..4681e0405340d5 100644 --- a/test/parallel/test-child-process-disconnect.js +++ b/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'); diff --git a/test/parallel/test-child-process-flush-stdio.js b/test/parallel/test-child-process-flush-stdio.js index c2cae2069a8ce5..a2f0bb9f71f341 100644 --- a/test/parallel/test-child-process-flush-stdio.js +++ b/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 diff --git a/test/parallel/test-child-process-fork-close.js b/test/parallel/test-child-process-fork-close.js index 8af22e7dcf6951..d6e9675ba82012 100644 --- a/test/parallel/test-child-process-fork-close.js +++ b/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'); diff --git a/test/parallel/test-child-process-fork-dgram.js b/test/parallel/test-child-process-fork-dgram.js index 67a783b6b78515..5a00dca06697cf 100644 --- a/test/parallel/test-child-process-fork-dgram.js +++ b/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 ' + diff --git a/test/parallel/test-child-process-fork-exec-path.js b/test/parallel/test-child-process-fork-exec-path.js index 459e9992d01748..e42b72f2b85886 100644 --- a/test/parallel/test-child-process-fork-exec-path.js +++ b/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'); diff --git a/test/parallel/test-child-process-fork-net2.js b/test/parallel/test-child-process-fork-net2.js index 454769b875e181..9489ed8cc03dfd 100644 --- a/test/parallel/test-child-process-fork-net2.js +++ b/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; diff --git a/test/parallel/test-child-process-spawn-typeerror.js b/test/parallel/test-child-process-spawn-typeerror.js index 20b6e4691055f4..6ae9374731d601 100644 --- a/test/parallel/test-child-process-spawn-typeerror.js +++ b/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/; diff --git a/test/parallel/test-cli-syntax.js b/test/parallel/test-cli-syntax.js index 1118a63934d747..7718c42f31fa25 100644 --- a/test/parallel/test-cli-syntax.js +++ b/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 diff --git a/test/parallel/test-cluster-dgram-1.js b/test/parallel/test-cluster-dgram-1.js index c0d9418528d5c1..319bc60b8c3bb0 100644 --- a/test/parallel/test-cluster-dgram-1.js +++ b/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'); diff --git a/test/parallel/test-cluster-dgram-2.js b/test/parallel/test-cluster-dgram-2.js index f152c2342da6c0..65f46a9cd80394 100644 --- a/test/parallel/test-cluster-dgram-2.js +++ b/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'); diff --git a/test/parallel/test-cluster-worker-no-exit.js b/test/parallel/test-cluster-worker-no-exit.js index b44831694c6bfa..0cec652b68648c 100644 --- a/test/parallel/test-cluster-worker-no-exit.js +++ b/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; diff --git a/test/parallel/test-debugger-repeat-last.js b/test/parallel/test-debugger-repeat-last.js index 666a7bca743b9f..157baada0c3ea7 100644 --- a/test/parallel/test-debugger-repeat-last.js +++ b/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' diff --git a/test/parallel/test-debugger-util-regression.js b/test/parallel/test-debugger-util-regression.js index 92630b6a4b307c..069fb061c9ac0c 100644 --- a/test/parallel/test-debugger-util-regression.js +++ b/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' diff --git a/test/parallel/test-domain-with-abort-on-uncaught-exception.js b/test/parallel/test-domain-with-abort-on-uncaught-exception.js index 05d8dba4828536..423c77136fa5f6 100644 --- a/test/parallel/test-domain-with-abort-on-uncaught-exception.js +++ b/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: diff --git a/test/parallel/test-fs-read-stream-fd.js b/test/parallel/test-fs-read-stream-fd.js index 59ff3065896497..5af5200e30eb68 100644 --- a/test/parallel/test-fs-read-stream-fd.js +++ b/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 = ''; diff --git a/test/parallel/test-fs-readfile-unlink.js b/test/parallel/test-fs-readfile-unlink.js index 50ad4172fc43dd..e0539fa100b1f5 100644 --- a/test/parallel/test-fs-readfile-unlink.js +++ b/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'); diff --git a/test/parallel/test-https-client-get-url.js b/test/parallel/test-https-client-get-url.js index 84ef01786d2d49..1a9fdf5f3f808e 100644 --- a/test/parallel/test-https-client-get-url.js +++ b/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) { diff --git a/test/parallel/test-https-req-split.js b/test/parallel/test-https-req-split.js index 6dc6097dc216ae..b49c17f28879be 100644 --- a/test/parallel/test-https-req-split.js +++ b/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; diff --git a/test/parallel/test-https-strict.js b/test/parallel/test-https-strict.js index 639892f1a10bc4..e62f8ad01549e5 100644 --- a/test/parallel/test-https-strict.js +++ b/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) { diff --git a/test/parallel/test-path-makelong.js b/test/parallel/test-path-makelong.js index 2de630189c5511..50a77e9d87b8dc 100644 --- a/test/parallel/test-path-makelong.js +++ b/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'); diff --git a/test/parallel/test-process-env.js b/test/parallel/test-process-env.js index b5e62324ac15db..33a1d9674eaa44 100644 --- a/test/parallel/test-process-env.js +++ b/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; diff --git a/test/parallel/test-process-no-deprecation.js b/test/parallel/test-process-no-deprecation.js index e3f3aad107b5a4..9185f8beb58bd6 100644 --- a/test/parallel/test-process-no-deprecation.js +++ b/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() { diff --git a/test/parallel/test-regress-GH-1899.js b/test/parallel/test-regress-GH-1899.js index 98396aae13b8f9..37fdd34bde14eb 100644 --- a/test/parallel/test-regress-GH-1899.js +++ b/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') diff --git a/test/parallel/test-repl-.save.load.js b/test/parallel/test-repl-.save.load.js index 6bf3d2643181f2..b9c5bc88afa842 100644 --- a/test/parallel/test-repl-.save.load.js +++ b/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(); diff --git a/test/parallel/test-repl-timeout-throw.js b/test/parallel/test-repl-timeout-throw.js index 6c540c9e3197de..35bb8967d39a90 100644 --- a/test/parallel/test-repl-timeout-throw.js +++ b/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; diff --git a/test/parallel/test-setproctitle.js b/test/parallel/test-setproctitle.js index 40107f5774962f..943cd60769c29a 100644 --- a/test/parallel/test-setproctitle.js +++ b/test/parallel/test-setproctitle.js @@ -1,13 +1,13 @@ 'use strict'; // Original test written by Jakub Lekstan +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'); diff --git a/test/parallel/test-tick-processor.js b/test/parallel/test-tick-processor.js index 550061499a394b..71f573deceb3be 100644 --- a/test/parallel/test-tick-processor.js +++ b/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 diff --git a/test/parallel/test-timers-blocking-callback.js b/test/parallel/test-timers-blocking-callback.js index 114c435a6af726..ceac19054ca872 100644 --- a/test/parallel/test-timers-blocking-callback.js +++ b/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; diff --git a/test/parallel/test-timers-nested.js b/test/parallel/test-timers-nested.js index 17b397d33cd860..d5d272ed2eae11 100644 --- a/test/parallel/test-timers-nested.js +++ b/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 diff --git a/test/parallel/test-tls-client-default-ciphers.js b/test/parallel/test-tls-client-default-ciphers.js index ebfc072dd33054..33766dfd5b13b2 100644 --- a/test/parallel/test-tls-client-default-ciphers.js +++ b/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'); diff --git a/test/parallel/test-tls-close-error.js b/test/parallel/test-tls-close-error.js index d1964858c5ae45..2da7a192c30ebc 100644 --- a/test/parallel/test-tls-close-error.js +++ b/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'); diff --git a/test/parallel/test-tls-empty-sni-context.js b/test/parallel/test-tls-empty-sni-context.js index 4ab1778ef62dbd..52e9f14b64d91a 100644 --- a/test/parallel/test-tls-empty-sni-context.js +++ b/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) { diff --git a/test/parallel/test-tls-handshake-error.js b/test/parallel/test-tls-handshake-error.js index efe458ebfbf1a8..e76a0961fb7ad6 100644 --- a/test/parallel/test-tls-handshake-error.js +++ b/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'); diff --git a/test/pummel/test-abort-fatal-error.js b/test/pummel/test-abort-fatal-error.js index f84440b9270d72..0bb2cb2c39998e 100644 --- a/test/pummel/test-abort-fatal-error.js +++ b/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'); diff --git a/test/pummel/test-regress-GH-814.js b/test/pummel/test-regress-GH-814.js index 0506519fc3de0e..7bbd13dd196457 100644 --- a/test/pummel/test-regress-GH-814.js +++ b/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'); diff --git a/test/sequential/test-child-process-fork-getconnections.js b/test/sequential/test-child-process-fork-getconnections.js index 8928ef6c744ba4..02e60f42e6c2ba 100644 --- a/test/sequential/test-child-process-fork-getconnections.js +++ b/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; diff --git a/test/sequential/test-init.js b/test/sequential/test-init.js index 6bb727ea1f6184..c8127e32a1c527 100644 --- a/test/sequential/test-init.js +++ b/test/sequential/test-init.js @@ -1,49 +1,47 @@ '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']) { - util.print('Loaded successfully!'); - } else { - // change CWD as we do this test so its not dependant on current CWD - // being in the test folder - process.chdir(__dirname); +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 { + // change CWD as we do this test so its not dependant on current CWD + // being in the test folder + process.chdir(__dirname); - // slow but simple - var envCopy = JSON.parse(JSON.stringify(process.env)); - envCopy.TEST_INIT = 1; + // slow but simple + var envCopy = JSON.parse(JSON.stringify(process.env)); + envCopy.TEST_INIT = 1; - child.exec('"' + process.execPath + '" test-init', {env: envCopy}, - function(err, stdout, stderr) { - assert.equal(stdout, 'Loaded successfully!', - '`node test-init` failed!'); - }); - child.exec('"' + process.execPath + '" test-init.js', {env: envCopy}, - function(err, stdout, stderr) { - assert.equal(stdout, 'Loaded successfully!', - '`node test-init.js` failed!'); - }); + child.exec('"' + process.execPath + '" test-init', {env: envCopy}, + function(err, stdout, stderr) { + assert.equal(stdout, 'Loaded successfully!', + '`node test-init` failed!'); + }); + child.exec('"' + process.execPath + '" test-init.js', {env: envCopy}, + function(err, stdout, stderr) { + assert.equal(stdout, 'Loaded successfully!', + '`node test-init.js` failed!'); + }); - // test-init-index is in fixtures dir as requested by ry, so go there - process.chdir(common.fixturesDir); + // test-init-index is in fixtures dir as requested by ry, so go there + process.chdir(common.fixturesDir); - child.exec('"' + process.execPath + '" test-init-index', {env: envCopy}, - function(err, stdout, stderr) { - assert.equal(stdout, 'Loaded successfully!', - '`node test-init-index failed!'); - }); + child.exec('"' + process.execPath + '" test-init-index', {env: envCopy}, + function(err, stdout, stderr) { + assert.equal(stdout, 'Loaded successfully!', + '`node test-init-index failed!'); + }); - // ensures that `node fs` does not mistakenly load the native 'fs' module - // instead of the desired file and that the fs module loads as - // expected in node - process.chdir(common.fixturesDir + '/test-init-native/'); + // ensures that `node fs` does not mistakenly load the native 'fs' module + // instead of the desired file and that the fs module loads as + // expected in node + process.chdir(common.fixturesDir + '/test-init-native/'); - child.exec('"' + process.execPath + '" fs', {env: envCopy}, - function(err, stdout, stderr) { - assert.equal(stdout, 'fs loaded successfully', - '`node fs` failed!'); - }); - } -})(); + child.exec('"' + process.execPath + '" fs', {env: envCopy}, + function(err, stdout, stderr) { + assert.equal(stdout, 'fs loaded successfully', + '`node fs` failed!'); + }); +}