mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04:00
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>
This commit is contained in:
1 parent
c21a212bdc
commit
612307564b
46 files changed
+94
-97
No files matched your search
@@ -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;
|
||||
|
||||
@@ -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 = [];
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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');
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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 ' +
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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/;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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');
|
||||
|
||||
|
||||
|
||||
@@ -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');
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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 = '';
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
var assert = require('assert');
|
||||
var common = require('../common');
|
||||
|
||||
var spawn = require('child_process').spawn;
|
||||
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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!');
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user