test: simplify test skipping

* Make common.skip() exit.

  Also add common.printSkipMessage() for partial skips.

* Don't make needless things before skip

PR-URL: https://github.com/nodejs/node/pull/14021
Fixes: https://github.com/nodejs/node/issues/14016
Reviewed-By: Refael Ackermann <refack@gmail.com>
This commit is contained in:
Vse Mozhet Byt 2017-07-01 02:29:09 +03:00
parent cc1a47dc6b
commit 2d2986ae72
333 changed files with 901 additions and 1638 deletions

View File

@ -1,13 +1,11 @@
'use strict';
const common = require('../common');
if (common.isWindows)
common.skip('Backtraces unimplemented on Windows.');
const assert = require('assert');
const cp = require('child_process');
if (common.isWindows) {
common.skip('Backtraces unimplemented on Windows.');
return;
}
if (process.argv[2] === 'child') {
process.abort();
} else {

View File

@ -1,14 +1,12 @@
'use strict';
const common = require('../../common');
if (common.isWOW64)
common.skip('doesn\'t work on WOW64');
const fs = require('fs');
const path = require('path');
const assert = require('assert');
if (common.isWOW64) {
common.skip('doesn\'t work on WOW64');
return;
}
common.refreshTmpDir();
// make a path that is more than 260 chars long.

View File

@ -1,10 +1,9 @@
'use strict';
const common = require('../../common');
if (!common.hasCrypto) {
if (!common.hasCrypto)
common.skip('missing crypto');
process.exit(0);
}
const assert = require('assert');
const binding = require(`./build/${common.buildType}/binding`);
const bytes = new Uint8Array(1024);

View File

@ -1,6 +1,10 @@
'use strict';
const common = require('../../common');
const skipMessage = 'intensive toString tests due to memory confinements';
if (!common.enoughTestMem)
common.skip(skipMessage);
const binding = require(`./build/${common.buildType}/binding`);
const assert = require('assert');
@ -8,12 +12,6 @@ const assert = require('assert');
// v8::String::kMaxLength defined in v8.h
const kStringMaxLength = process.binding('buffer').kStringMaxLength;
const skipMessage = 'intensive toString tests due to memory confinements';
if (!common.enoughTestMem) {
common.skip(skipMessage);
return;
}
let buf;
try {
buf = Buffer.allocUnsafe(kStringMaxLength);
@ -21,14 +19,11 @@ try {
// If the exception is not due to memory confinement then rethrow it.
if (e.message !== 'Array buffer allocation failed') throw (e);
common.skip(skipMessage);
return;
}
// Ensure we have enough memory available for future allocations to succeed.
if (!binding.ensureAllocation(2 * kStringMaxLength)) {
if (!binding.ensureAllocation(2 * kStringMaxLength))
common.skip(skipMessage);
return;
}
const maxString = buf.toString('latin1');
assert.strictEqual(maxString.length, kStringMaxLength);

View File

@ -1,15 +1,13 @@
'use strict';
const common = require('../../common');
const skipMessage = 'intensive toString tests due to memory confinements';
if (!common.enoughTestMem)
common.skip(skipMessage);
const binding = require(`./build/${common.buildType}/binding`);
const assert = require('assert');
const skipMessage = 'intensive toString tests due to memory confinements';
if (!common.enoughTestMem) {
common.skip(skipMessage);
return;
}
// v8 fails silently if string length > v8::String::kMaxLength
// v8::String::kMaxLength defined in v8.h
const kStringMaxLength = process.binding('buffer').kStringMaxLength;
@ -21,14 +19,11 @@ try {
// If the exception is not due to memory confinement then rethrow it.
if (e.message !== 'Array buffer allocation failed') throw (e);
common.skip(skipMessage);
return;
}
// Ensure we have enough memory available for future allocations to succeed.
if (!binding.ensureAllocation(2 * kStringMaxLength)) {
if (!binding.ensureAllocation(2 * kStringMaxLength))
common.skip(skipMessage);
return;
}
assert.throws(function() {
buf.toString('ascii');

View File

@ -1,15 +1,13 @@
'use strict';
const common = require('../../common');
const skipMessage = 'intensive toString tests due to memory confinements';
if (!common.enoughTestMem)
common.skip(skipMessage);
const binding = require(`./build/${common.buildType}/binding`);
const assert = require('assert');
const skipMessage = 'intensive toString tests due to memory confinements';
if (!common.enoughTestMem) {
common.skip(skipMessage);
return;
}
// v8 fails silently if string length > v8::String::kMaxLength
// v8::String::kMaxLength defined in v8.h
const kStringMaxLength = process.binding('buffer').kStringMaxLength;
@ -21,14 +19,11 @@ try {
// If the exception is not due to memory confinement then rethrow it.
if (e.message !== 'Array buffer allocation failed') throw (e);
common.skip(skipMessage);
return;
}
// Ensure we have enough memory available for future allocations to succeed.
if (!binding.ensureAllocation(2 * kStringMaxLength)) {
if (!binding.ensureAllocation(2 * kStringMaxLength))
common.skip(skipMessage);
return;
}
assert.throws(function() {
buf.toString('base64');

View File

@ -1,15 +1,13 @@
'use strict';
const common = require('../../common');
const skipMessage = 'intensive toString tests due to memory confinements';
if (!common.enoughTestMem)
common.skip(skipMessage);
const binding = require(`./build/${common.buildType}/binding`);
const assert = require('assert');
const skipMessage = 'intensive toString tests due to memory confinements';
if (!common.enoughTestMem) {
common.skip(skipMessage);
return;
}
// v8 fails silently if string length > v8::String::kMaxLength
// v8::String::kMaxLength defined in v8.h
const kStringMaxLength = process.binding('buffer').kStringMaxLength;
@ -21,14 +19,11 @@ try {
// If the exception is not due to memory confinement then rethrow it.
if (e.message !== 'Array buffer allocation failed') throw (e);
common.skip(skipMessage);
return;
}
// Ensure we have enough memory available for future allocations to succeed.
if (!binding.ensureAllocation(2 * kStringMaxLength)) {
if (!binding.ensureAllocation(2 * kStringMaxLength))
common.skip(skipMessage);
return;
}
assert.throws(function() {
buf.toString('latin1');

View File

@ -1,15 +1,13 @@
'use strict';
const common = require('../../common');
const skipMessage = 'intensive toString tests due to memory confinements';
if (!common.enoughTestMem)
common.skip(skipMessage);
const binding = require(`./build/${common.buildType}/binding`);
const assert = require('assert');
const skipMessage = 'intensive toString tests due to memory confinements';
if (!common.enoughTestMem) {
common.skip(skipMessage);
return;
}
// v8 fails silently if string length > v8::String::kMaxLength
// v8::String::kMaxLength defined in v8.h
const kStringMaxLength = process.binding('buffer').kStringMaxLength;
@ -21,14 +19,11 @@ try {
// If the exception is not due to memory confinement then rethrow it.
if (e.message !== 'Array buffer allocation failed') throw (e);
common.skip(skipMessage);
return;
}
// Ensure we have enough memory available for future allocations to succeed.
if (!binding.ensureAllocation(2 * kStringMaxLength)) {
if (!binding.ensureAllocation(2 * kStringMaxLength))
common.skip(skipMessage);
return;
}
assert.throws(function() {
buf.toString('hex');

View File

@ -1,15 +1,13 @@
'use strict';
const common = require('../../common');
const skipMessage = 'intensive toString tests due to memory confinements';
if (!common.enoughTestMem)
common.skip(skipMessage);
const binding = require(`./build/${common.buildType}/binding`);
const assert = require('assert');
const skipMessage = 'intensive toString tests due to memory confinements';
if (!common.enoughTestMem) {
common.skip(skipMessage);
return;
}
// v8 fails silently if string length > v8::String::kMaxLength
// v8::String::kMaxLength defined in v8.h
const kStringMaxLength = process.binding('buffer').kStringMaxLength;
@ -21,14 +19,11 @@ try {
// If the exception is not due to memory confinement then rethrow it.
if (e.message !== 'Array buffer allocation failed') throw (e);
common.skip(skipMessage);
return;
}
// Ensure we have enough memory available for future allocations to succeed.
if (!binding.ensureAllocation(2 * kStringMaxLength)) {
if (!binding.ensureAllocation(2 * kStringMaxLength))
common.skip(skipMessage);
return;
}
assert.throws(function() {
buf.toString();

View File

@ -1,15 +1,13 @@
'use strict';
const common = require('../../common');
const skipMessage = 'intensive toString tests due to memory confinements';
if (!common.enoughTestMem)
common.skip(skipMessage);
const binding = require(`./build/${common.buildType}/binding`);
const assert = require('assert');
const skipMessage = 'intensive toString tests due to memory confinements';
if (!common.enoughTestMem) {
common.skip(skipMessage);
return;
}
// v8 fails silently if string length > v8::String::kMaxLength
// v8::String::kMaxLength defined in v8.h
const kStringMaxLength = process.binding('buffer').kStringMaxLength;
@ -21,14 +19,11 @@ try {
// If the exception is not due to memory confinement then rethrow it.
if (e.message !== 'Array buffer allocation failed') throw (e);
common.skip(skipMessage);
return;
}
// Ensure we have enough memory available for future allocations to succeed.
if (!binding.ensureAllocation(2 * kStringMaxLength)) {
if (!binding.ensureAllocation(2 * kStringMaxLength))
common.skip(skipMessage);
return;
}
const maxString = buf.toString('utf16le');
assert.strictEqual(maxString.length, (kStringMaxLength + 2) / 2);

View File

@ -1,15 +1,13 @@
'use strict';
const common = require('../../common');
const skipMessage = 'intensive toString tests due to memory confinements';
if (!common.enoughTestMem)
common.skip(skipMessage);
const binding = require(`./build/${common.buildType}/binding`);
const assert = require('assert');
const skipMessage = 'intensive toString tests due to memory confinements';
if (!common.enoughTestMem) {
common.skip(skipMessage);
return;
}
// v8 fails silently if string length > v8::String::kMaxLength
// v8::String::kMaxLength defined in v8.h
const kStringMaxLength = process.binding('buffer').kStringMaxLength;
@ -21,14 +19,11 @@ try {
// If the exception is not due to memory confinement then rethrow it.
if (e.message !== 'Array buffer allocation failed') throw (e);
common.skip(skipMessage);
return;
}
// Ensure we have enough memory available for future allocations to succeed.
if (!binding.ensureAllocation(2 * kStringMaxLength)) {
if (!binding.ensureAllocation(2 * kStringMaxLength))
common.skip(skipMessage);
return;
}
assert.throws(function() {
buf.toString('utf16le');

View File

@ -22,7 +22,6 @@ try {
} catch (err) {
if (err.code !== 'EPERM') throw err;
common.skip('module identity test (no privs for symlinks)');
return;
}
const sub = require('./submodule');

View File

@ -1,16 +1,14 @@
'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const initHooks = require('./init-hooks');
const tick = require('./tick');
const common = require('../common');
const assert = require('assert');
const { checkInvocations } = require('./hook-checks');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
const tls = require('tls');
const Connection = process.binding('crypto').Connection;
const hooks = initHooks();

View File

@ -1,10 +1,9 @@
'use strict';
const common = require('../common');
if (!common.hasCrypto) {
if (!common.hasCrypto)
common.skip('missing crypto');
return;
}
const assert = require('assert');
const tick = require('./tick');
const initHooks = require('./init-hooks');

View File

@ -1,10 +1,9 @@
'use strict';
const common = require('../common');
if (!common.hasCrypto) {
if (!common.hasCrypto)
common.skip('missing crypto');
return;
}
const assert = require('assert');
const tick = require('./tick');
const initHooks = require('./init-hooks');

View File

@ -1,13 +1,11 @@
'use strict';
const initHooks = require('./init-hooks');
const common = require('../common');
const verifyGraph = require('./verify-graph');
if (!common.hasCrypto) {
if (!common.hasCrypto)
common.skip('missing crypto');
return;
}
const initHooks = require('./init-hooks');
const verifyGraph = require('./verify-graph');
const tls = require('tls');
const Connection = process.binding('crypto').Connection;

View File

@ -1,14 +1,11 @@
'use strict';
const common = require('../common');
if (!common.hasIPv6)
common.skip('IPv6 support required');
const initHooks = require('./init-hooks');
const verifyGraph = require('./verify-graph');
if (!common.hasIPv6) {
common.skip('IPv6 support required');
return;
}
const net = require('net');
const hooks = initHooks();

View File

@ -1,14 +1,11 @@
'use strict';
const common = require('../common');
if (!common.hasIPv6)
common.skip('IPv6 support required');
const initHooks = require('./init-hooks');
const verifyGraph = require('./verify-graph');
if (!common.hasIPv6) {
common.skip('IPv6 support required');
return;
}
const net = require('net');
const hooks = initHooks();

View File

@ -1,21 +1,17 @@
'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
if (!common.hasIPv6)
common.skip('IPv6 support required');
const initHooks = require('./init-hooks');
const verifyGraph = require('./verify-graph');
const fs = require('fs');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
if (!common.hasIPv6) {
common.skip('IPv6 support required');
return;
}
const tls = require('tls');
const hooks = initHooks();
hooks.enable();

View File

@ -2,16 +2,13 @@
'use strict';
const common = require('../common');
if (!common.hasIPv6)
common.skip('IPv6 support required');
const assert = require('assert');
const tick = require('./tick');
const initHooks = require('./init-hooks');
const { checkInvocations } = require('./hook-checks');
if (!common.hasIPv6) {
common.skip('IPv6 support required');
return;
}
const net = require('net');
let tcp1, tcp2, tcp3;

View File

@ -1,18 +1,16 @@
'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const assert = require('assert');
const tick = require('./tick');
const initHooks = require('./init-hooks');
const fs = require('fs');
const { checkInvocations } = require('./hook-checks');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
const tls = require('tls');
const hooks = initHooks();
hooks.enable();

View File

@ -1,14 +1,16 @@
'use strict';
const common = require('../common');
const tty_fd = common.getTTYfd();
if (tty_fd < 0)
common.skip('no valid TTY fd available');
const assert = require('assert');
const tick = require('./tick');
const initHooks = require('./init-hooks');
const { checkInvocations } = require('./hook-checks');
const tty_fd = common.getTTYfd();
if (tty_fd < 0)
return common.skip('no valid TTY fd available');
const ttyStream = (() => {
try {
return new (require('tty').WriteStream)(tty_fd);
@ -17,7 +19,7 @@ const ttyStream = (() => {
}
})();
if (ttyStream === null)
return common.skip('no valid TTY fd available');
common.skip('no valid TTY fd available');
const hooks = initHooks();
hooks.enable();

View File

@ -1,17 +1,15 @@
'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const assert = require('assert');
const initHooks = require('./init-hooks');
const fs = require('fs');
const { checkInvocations } = require('./hook-checks');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
const tls = require('tls');
const hooks = initHooks();
hooks.enable();

View File

@ -264,6 +264,11 @@ Path to the test sock.
Port tests are running on.
### printSkipMessage(msg)
* `msg` [&lt;String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)
Logs '1..0 # Skipped: ' + `msg`
### refreshTmpDir
* return [&lt;String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)
@ -285,7 +290,7 @@ Path to the 'root' directory. either `/` or `c:\\` (windows)
### skip(msg)
* `msg` [&lt;String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)
Logs '1..0 # Skipped: ' + `msg`
Logs '1..0 # Skipped: ' + `msg` and exits with exit code `0`.
### spawnPwd(options)
* `options` [&lt;Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)

View File

@ -570,10 +570,15 @@ exports.mustNotCall = function(msg) {
};
};
exports.skip = function(msg) {
exports.printSkipMessage = function(msg) {
console.log(`1..0 # Skipped: ${msg}`);
};
exports.skip = function(msg) {
exports.printSkipMessage(msg);
process.exit(0);
};
// A stream to push an array into a REPL
function ArrayStream() {
this.run = function(data) {
@ -717,7 +722,6 @@ exports.expectsError = function expectsError({code, type, message}) {
exports.skipIfInspectorDisabled = function skipIfInspectorDisabled() {
if (process.config.variables.v8_enable_inspector === 0) {
exports.skip('V8 inspector is disabled');
process.exit(0);
}
};

View File

@ -1,17 +1,16 @@
'use strict';
const common = require('../common');
const assert = require('assert');
const fs = require('fs');
const path = require('path');
// The doctool currently uses js-yaml from the tool/eslint/ tree.
try {
require('../../tools/eslint/node_modules/js-yaml');
} catch (e) {
return common.skip('missing js-yaml (eslint not present)');
common.skip('missing js-yaml (eslint not present)');
}
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const processIncludes = require('../../tools/doc/preprocess.js');
const html = require('../../tools/doc/html.js');

View File

@ -1,17 +1,16 @@
'use strict';
const common = require('../common');
const assert = require('assert');
const fs = require('fs');
const path = require('path');
// The doctool currently uses js-yaml from the tool/eslint/ tree.
try {
require('../../tools/eslint/node_modules/js-yaml');
} catch (e) {
return common.skip('missing js-yaml (eslint not present)');
common.skip('missing js-yaml (eslint not present)');
}
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const json = require('../../tools/doc/json.js');
// Outputs valid json with the expected fields when given simple markdown

View File

@ -4,14 +4,13 @@
'use strict';
const common = require('../common');
const fs = require('fs');
const join = require('path').join;
// Check if Node was compiled --without-ssl and if so exit early
// as the require of tls will otherwise throw an Error.
if (!common.hasCrypto) {
if (!common.hasCrypto)
common.skip('missing crypto');
process.exit(0);
}
const fs = require('fs');
const join = require('path').join;
const tls = require('tls');
const util = require('util');

View File

@ -9,10 +9,8 @@ const os = require('os');
const ip = pickIPv4Address();
if (!ip) {
if (!ip)
common.skip('No IP address found');
return;
}
function checkListResponse(instance, err, response) {
assert.ifError(err);
@ -29,7 +27,7 @@ function checkListResponse(instance, err, response) {
function checkError(instance, error) {
// Some OSes will not allow us to connect
if (error.code === 'EHOSTUNREACH') {
common.skip('Unable to connect to self');
common.printSkipMessage('Unable to connect to self');
} else {
throw error;
}

View File

@ -21,6 +21,9 @@
'use strict';
const common = require('../common');
if (common.inFreeBSDJail)
common.skip('in a FreeBSD jail');
const assert = require('assert');
const dgram = require('dgram');
const util = require('util');
@ -35,11 +38,6 @@ const messages = [
Buffer.from('Fourth message to send')
];
if (common.inFreeBSDJail) {
common.skip('in a FreeBSD jail');
return;
}
let bindAddress = null;
// Take the first non-internal interface as the address for binding.

View File

@ -21,6 +21,10 @@
'use strict';
const common = require('../common');
// Skip test in FreeBSD jails.
if (common.inFreeBSDJail)
common.skip('In a FreeBSD jail');
const assert = require('assert');
const dgram = require('dgram');
const fork = require('child_process').fork;
@ -37,12 +41,6 @@ const listeners = 3;
let listening, sendSocket, done, timer, dead;
// Skip test in FreeBSD jails.
if (common.inFreeBSDJail) {
common.skip('In a FreeBSD jail');
return;
}
function launchChildProcess() {
const worker = fork(__filename, ['child']);
workers[worker.pid] = worker;

View File

@ -1,5 +1,8 @@
'use strict';
const common = require('../common');
if (!common.hasIPv6)
common.skip('this test, no IPv6 support');
const assert = require('assert');
const dns = require('dns');
const net = require('net');
@ -8,11 +11,6 @@ const isIPv6 = net.isIPv6;
let running = false;
const queue = [];
if (!common.hasIPv6) {
common.skip('this test, no IPv6 support');
return;
}
function TEST(f) {
function next() {
const f = queue.shift();

View File

@ -22,10 +22,9 @@
'use strict';
const common = require('../common');
if (!common.hasCrypto) {
if (!common.hasCrypto)
common.skip('missing crypto');
return;
}
const https = require('https');
const http = require('http');

View File

@ -1,10 +1,8 @@
'use strict';
const common = require('../common');
if (!common.hasCrypto) {
if (!common.hasCrypto)
common.skip('missing crypto');
return;
}
// Test interaction of compiled-in CAs with user-provided CAs.

View File

@ -3,10 +3,8 @@
// certification between Starfield Class 2 and ValiCert Class 2
const common = require('../common');
if (!common.hasCrypto) {
if (!common.hasCrypto)
common.skip('missing crypto');
return;
}
const tls = require('tls');
const socket = tls.connect(443, 'address.melissadata.net', function() {

View File

@ -22,10 +22,9 @@
'use strict';
const common = require('../common');
if (!common.hasCrypto) {
if (!common.hasCrypto)
common.skip('missing crypto');
return;
}
const tls = require('tls');
const net = require('net');

View File

@ -9,7 +9,6 @@ if (common.isSunOS || common.isWindows || common.isAix) {
// The current working directory cannot be removed on these platforms.
// Change this to common.skip() when this is no longer a known issue test.
assert.fail('cannot rmdir current working directory');
return;
}
const cp = require('child_process');

View File

@ -1,9 +1,7 @@
'use strict';
const common = require('../common');
if (!common.hasCrypto) {
if (!common.hasCrypto)
common.skip('missing crypto');
return;
}
// Refs: https://github.com/nodejs/node/issues/13045
// An HTTP Agent reuses a TLSSocket, and makes a failed call to `asyncReset`.

View File

@ -1,10 +1,9 @@
'use strict';
const common = require('../common');
if (!common.hasCrypto) {
if (!common.hasCrypto)
common.skip('missing crypto');
return;
}
const assert = require('assert');
const async_hooks = require('async_hooks');
const call_log = [0, 0, 0, 0]; // [before, callback, exception, after];

View File

@ -2,15 +2,11 @@
const common = require('../common');
if (!common.hasCrypto) {
if (!common.hasCrypto)
common.skip('missing crypto');
return;
}
if (common.hasFipsCrypto) {
if (common.hasFipsCrypto)
common.skip('some benchmarks are FIPS-incompatible');
return;
}
// Minimal test for crypto benchmarks. This makes sure the benchmarks aren't
// horribly broken but nothing more than that.

View File

@ -917,7 +917,7 @@ if (common.hasCrypto) {
crypto.createHash('sha1').update(b2).digest('hex')
);
} else {
common.skip('missing crypto');
common.printSkipMessage('missing crypto');
}
const ps = Buffer.poolSize;

View File

@ -28,15 +28,13 @@
*/
const common = require('../common');
if (common.isWindows)
common.skip('Sending dgram sockets to child processes is not supported');
const dgram = require('dgram');
const fork = require('child_process').fork;
const assert = require('assert');
if (common.isWindows) {
common.skip('Sending dgram sockets to child processes is not supported');
return;
}
if (process.argv[2] === 'child') {
let childServer;

View File

@ -1,7 +1,7 @@
'use strict';
const common = require('../common');
if (process.config.variables.node_without_node_options)
return common.skip('missing NODE_OPTIONS support');
common.skip('missing NODE_OPTIONS support');
// Test options specified by env variable.

View File

@ -21,20 +21,16 @@
'use strict';
const common = require('../common');
if (common.isWindows)
common.skip('not reliable on Windows.');
if (process.getuid() === 0)
common.skip('Test is not supposed to be run as root.');
const assert = require('assert');
const cluster = require('cluster');
const net = require('net');
if (common.isWindows) {
common.skip('not reliable on Windows.');
return;
}
if (process.getuid() === 0) {
common.skip('Test is not supposed to be run as root.');
return;
}
if (cluster.isMaster) {
cluster.fork().on('exit', common.mustCall((exitCode) => {
assert.strictEqual(exitCode, 0);

View File

@ -21,6 +21,9 @@
'use strict';
const common = require('../common');
if (common.isWindows)
common.skip('dgram clustering is currently not supported on Windows.');
const NUM_WORKERS = 4;
const PACKETS_PER_WORKER = 10;
@ -28,12 +31,6 @@ const assert = require('assert');
const cluster = require('cluster');
const dgram = require('dgram');
if (common.isWindows) {
common.skip('dgram clustering is currently not supported on Windows.');
return;
}
if (cluster.isMaster)
master();
else

View File

@ -21,6 +21,9 @@
'use strict';
const common = require('../common');
if (common.isWindows)
common.skip('dgram clustering is currently not supported on Windows.');
const NUM_WORKERS = 4;
const PACKETS_PER_WORKER = 10;
@ -28,12 +31,6 @@ const cluster = require('cluster');
const dgram = require('dgram');
const assert = require('assert');
if (common.isWindows) {
common.skip('dgram clustering is currently not supported on Windows.');
return;
}
if (cluster.isMaster)
master();
else

View File

@ -1,14 +1,12 @@
'use strict';
const common = require('../common');
if (common.isWindows)
common.skip('dgram clustering is currently not supported on windows.');
const assert = require('assert');
const cluster = require('cluster');
const dgram = require('dgram');
if (common.isWindows) {
common.skip('dgram clustering is currently not supported on windows.');
return;
}
if (cluster.isMaster) {
cluster.fork().on('exit', common.mustCall((code) => {
assert.strictEqual(code, 0);

View File

@ -4,15 +4,13 @@
// Ref: https://github.com/nodejs/node/issues/4205
const common = require('../common');
if (common.isWindows)
common.skip('This test does not apply to Windows.');
const assert = require('assert');
const net = require('net');
const cluster = require('cluster');
if (common.isWindows) {
common.skip('This test does not apply to Windows.');
return;
}
cluster.schedulingPolicy = cluster.SCHED_NONE;
if (cluster.isMaster) {

View File

@ -23,10 +23,8 @@
const common = require('../common');
if (common.isWindows) {
if (common.isWindows)
common.skip('on windows, because clustered dgram is ENOTSUP');
return;
}
const cluster = require('cluster');
const dgram = require('dgram');

View File

@ -22,16 +22,15 @@
'use strict';
const common = require('../common');
const assert = require('assert');
const cluster = require('cluster');
const http = require('http');
if (common.isWindows) {
common.skip(
'It is not possible to send pipe handles over the IPC pipe on Windows');
return;
}
const assert = require('assert');
const cluster = require('cluster');
const http = require('http');
if (cluster.isMaster) {
common.refreshTmpDir();
const worker = cluster.fork();

View File

@ -21,20 +21,16 @@
'use strict';
const common = require('../common');
if (common.isWindows)
common.skip('not reliable on Windows');
if (process.getuid() === 0)
common.skip('as this test should not be run as `root`');
const assert = require('assert');
const cluster = require('cluster');
const net = require('net');
if (common.isWindows) {
common.skip('not reliable on Windows');
return;
}
if (process.getuid() === 0) {
common.skip('as this test should not be run as `root`');
return;
}
if (cluster.isMaster) {
// Master opens and binds the socket and shares it with the worker.
cluster.schedulingPolicy = cluster.SCHED_NONE;

View File

@ -21,12 +21,10 @@
'use strict';
const common = require('../common');
const assert = require('assert');
if (!common.hasCrypto) {
if (!common.hasCrypto)
common.skip('missing crypto');
return;
}
const assert = require('assert');
const crypto = require('crypto');
crypto.DEFAULT_ENCODING = 'buffer';
@ -341,12 +339,12 @@ for (const i in TEST_CASES) {
const test = TEST_CASES[i];
if (!ciphers.includes(test.algo)) {
common.skip(`unsupported ${test.algo} test`);
common.printSkipMessage(`unsupported ${test.algo} test`);
continue;
}
if (common.hasFipsCrypto && test.iv.length < 24) {
common.skip('IV len < 12 bytes unsupported in FIPS mode');
common.printSkipMessage('IV len < 12 bytes unsupported in FIPS mode');
continue;
}

View File

@ -26,10 +26,8 @@
const common = require('../common');
if (!common.hasCrypto) {
if (!common.hasCrypto)
common.skip('missing crypto');
return;
}
const assert = require('assert');
const crypto = require('crypto');

View File

@ -21,12 +21,10 @@
'use strict';
const common = require('../common');
const assert = require('assert');
if (!common.hasCrypto) {
if (!common.hasCrypto)
common.skip('missing crypto');
return;
}
const assert = require('assert');
const crypto = require('crypto');
crypto.DEFAULT_ENCODING = 'buffer';

View File

@ -1,14 +1,12 @@
'use strict';
const common = require('../common');
if (!common.hasCrypto) {
if (!common.hasCrypto)
common.skip('missing crypto');
return;
}
if (common.hasFipsCrypto) {
if (common.hasFipsCrypto)
common.skip('not supported in FIPS mode');
return;
}
const crypto = require('crypto');
const assert = require('assert');

View File

@ -1,11 +1,9 @@
'use strict';
const common = require('../common');
const assert = require('assert');
if (!common.hasCrypto) {
if (!common.hasCrypto)
common.skip('missing crypto');
return;
}
const assert = require('assert');
const crypto = require('crypto');
function testCipher1(key, iv) {

View File

@ -1,11 +1,9 @@
'use strict';
const common = require('../common');
const assert = require('assert');
if (!common.hasCrypto) {
if (!common.hasCrypto)
common.skip('missing crypto');
return;
}
const assert = require('assert');
const crypto = require('crypto');
const tls = require('tls');

View File

@ -21,12 +21,10 @@
'use strict';
const common = require('../common');
const assert = require('assert');
if (!common.hasCrypto) {
if (!common.hasCrypto)
common.skip('missing crypto');
return;
}
const assert = require('assert');
const crypto = require('crypto');
function test() {

View File

@ -1,12 +1,11 @@
'use strict';
const common = require('../common');
const assert = require('assert');
if (!common.hasCrypto) {
if (!common.hasCrypto)
common.skip('missing crypto');
return;
}
const assert = require('assert');
const crypto = require('crypto');
const DH_NOT_SUITABLE_GENERATOR = crypto.constants.DH_NOT_SUITABLE_GENERATOR;
// Test Diffie-Hellman with two parties sharing a secret,

View File

@ -21,13 +21,11 @@
'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const assert = require('assert');
const domain = require('domain');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
const crypto = require('crypto');
function test(fn) {

View File

@ -21,17 +21,16 @@
'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const domain = require('domain');
const assert = require('assert');
const crypto = require('crypto');
const d = domain.create();
const expect = ['pbkdf2', 'randomBytes', 'pseudoRandomBytes'];
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
const crypto = require('crypto');
d.on('error', common.mustCall(function(e) {
assert.strictEqual(e.message, expect.shift());
}, 3));

View File

@ -21,16 +21,13 @@
'use strict';
const common = require('../common');
const assert = require('assert');
if (!common.hasCrypto) {
if (!common.hasCrypto)
common.skip('missing crypto');
return;
}
if (common.hasFipsCrypto) {
if (common.hasFipsCrypto)
common.skip('BF-ECB is not FIPS 140-2 compatible');
return;
}
const assert = require('assert');
const crypto = require('crypto');
crypto.DEFAULT_ENCODING = 'buffer';

View File

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

View File

@ -1,14 +1,12 @@
'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const assert = require('assert');
const spawnSync = require('child_process').spawnSync;
const path = require('path');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
const FIPS_ENABLED = 1;
const FIPS_DISABLED = 0;
const FIPS_ERROR_STRING = 'Error: Cannot set FIPS mode';

View File

@ -25,12 +25,10 @@
const common = require('../common');
const assert = require('assert');
if (!common.hasCrypto) {
if (!common.hasCrypto)
common.skip('missing crypto');
return;
}
const assert = require('assert');
const crypto = require('crypto');
const EXTERN_APEX = 0xFBEE9;

View File

@ -22,10 +22,8 @@
'use strict';
const common = require('../common');
if (!common.hasCrypto) {
if (!common.hasCrypto)
common.skip('missing crypto');
return;
}
const assert = require('assert');
const crypto = require('crypto');

View File

@ -1,13 +1,11 @@
'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const assert = require('assert');
const fs = require('fs');
const path = require('path');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
const crypto = require('crypto');
// Test hashing

View File

@ -1,11 +1,9 @@
'use strict';
const common = require('../common');
const assert = require('assert');
if (!common.hasCrypto) {
if (!common.hasCrypto)
common.skip('missing crypto');
return;
}
const assert = require('assert');
const crypto = require('crypto');
// Test for binding layer robustness

View File

@ -1,10 +1,9 @@
'use strict';
const common = require('../common');
if (!common.hasCrypto) {
if (!common.hasCrypto)
common.skip('missing crypto');
return;
}
const assert = require('assert');
const crypto = require('crypto');
const Stream = require('stream');

View File

@ -21,12 +21,10 @@
'use strict';
const common = require('../common');
const assert = require('assert');
if (!common.hasCrypto) {
if (!common.hasCrypto)
common.skip('missing crypto');
return;
}
const assert = require('assert');
const crypto = require('crypto');
crypto.DEFAULT_ENCODING = 'buffer';

View File

@ -21,12 +21,10 @@
'use strict';
const common = require('../common');
const assert = require('assert');
if (!common.hasCrypto) {
if (!common.hasCrypto)
common.skip('missing crypto');
return;
}
const assert = require('assert');
const crypto = require('crypto');
crypto.DEFAULT_ENCODING = 'buffer';

View File

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

View File

@ -22,10 +22,9 @@
'use strict';
const common = require('../common');
if (!common.hasCrypto) {
if (!common.hasCrypto)
common.skip('missing crypto');
return;
}
const assert = require('assert');
const crypto = require('crypto');

View File

@ -1,15 +1,13 @@
'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const assert = require('assert');
const fs = require('fs');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
const constants = require('crypto').constants;
const crypto = require('crypto');
const constants = crypto.constants;
const fixtDir = common.fixturesDir;
// Test certificates

View File

@ -1,14 +1,12 @@
'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const exec = require('child_process').exec;
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
const crypto = require('crypto');
// Test certificates
@ -245,10 +243,8 @@ const modSize = 1024;
// RSA-PSS Sign test by verifying with 'openssl dgst -verify'
{
if (!common.opensslCli) {
if (!common.opensslCli)
common.skip('node compiled without OpenSSL CLI.');
return;
}
const pubfile = path.join(common.fixturesDir, 'keys/rsa_public_2048.pem');
const privfile = path.join(common.fixturesDir, 'keys/rsa_private_2048.pem');

View File

@ -21,14 +21,12 @@
'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const assert = require('assert');
const stream = require('stream');
const util = require('util');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
const crypto = require('crypto');
// Small stream to buffer converter

View File

@ -22,10 +22,9 @@
'use strict';
const common = require('../common');
if (!common.hasCrypto) {
if (!common.hasCrypto)
common.skip('missing crypto');
return;
}
const crypto = require('crypto');
const tls = require('tls');

View File

@ -22,10 +22,8 @@
'use strict';
const common = require('../common');
if (!common.hasCrypto) {
if (!common.hasCrypto)
common.skip('missing crypto');
return;
}
const assert = require('assert');
const crypto = require('crypto');

View File

@ -1,15 +1,13 @@
'use strict';
const common = require('../common');
// Fails with EINVAL on SmartOS, EBUSY on Windows, EBUSY on AIX.
if (common.isSunOS || common.isWindows || common.isAix)
common.skip('cannot rmdir current working directory');
const assert = require('assert');
const fs = require('fs');
const spawn = require('child_process').spawn;
// Fails with EINVAL on SmartOS, EBUSY on Windows, EBUSY on AIX.
if (common.isSunOS || common.isWindows || common.isAix) {
common.skip('cannot rmdir current working directory');
return;
}
const dirname = `${common.tmpDir}/cwd-does-not-exist-${process.pid}`;
const abspathFile = require('path').join(common.fixturesDir, 'a.js');
common.refreshTmpDir();

View File

@ -1,15 +1,13 @@
'use strict';
const common = require('../common');
// Fails with EINVAL on SmartOS, EBUSY on Windows, EBUSY on AIX.
if (common.isSunOS || common.isWindows || common.isAix)
common.skip('cannot rmdir current working directory');
const assert = require('assert');
const fs = require('fs');
const spawn = require('child_process').spawn;
// Fails with EINVAL on SmartOS, EBUSY on Windows, EBUSY on AIX.
if (common.isSunOS || common.isWindows || common.isAix) {
common.skip('cannot rmdir current working directory');
return;
}
const dirname = `${common.tmpDir}/cwd-does-not-exist-${process.pid}`;
common.refreshTmpDir();
fs.mkdirSync(dirname);

View File

@ -1,15 +1,13 @@
'use strict';
const common = require('../common');
// Fails with EINVAL on SmartOS, EBUSY on Windows, EBUSY on AIX.
if (common.isSunOS || common.isWindows || common.isAix)
common.skip('cannot rmdir current working directory');
const assert = require('assert');
const fs = require('fs');
const spawn = require('child_process').spawn;
// Fails with EINVAL on SmartOS, EBUSY on Windows, EBUSY on AIX.
if (common.isSunOS || common.isWindows || common.isAix) {
common.skip('cannot rmdir current working directory');
return;
}
const dirname = `${common.tmpDir}/cwd-does-not-exist-${process.pid}`;
common.refreshTmpDir();
fs.mkdirSync(dirname);

View File

@ -1,13 +1,11 @@
'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const assert = require('assert');
const spawn = require('child_process').spawn;
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
const child = spawn(process.execPath, ['debug']);
child.stderr.setEncoding('utf8');

View File

@ -21,15 +21,13 @@
'use strict';
const common = require('../common');
// skip test in FreeBSD jails since 0.0.0.0 will resolve to default interface
if (common.inFreeBSDJail)
common.skip('In a FreeBSD jail');
const assert = require('assert');
const dgram = require('dgram');
// skip test in FreeBSD jails since 0.0.0.0 will resolve to default interface
if (common.inFreeBSDJail) {
common.skip('In a FreeBSD jail');
return;
}
dgram.createSocket('udp4').bind(0, common.mustCall(function() {
assert.strictEqual(typeof this.address().port, 'number');
assert.ok(isFinite(this.address().port));
@ -39,7 +37,7 @@ dgram.createSocket('udp4').bind(0, common.mustCall(function() {
}));
if (!common.hasIPv6) {
common.skip('udp6 part of test, because no IPv6 support');
common.printSkipMessage('udp6 part of test, because no IPv6 support');
return;
}

View File

@ -1,14 +1,12 @@
'use strict';
const common = require('../common');
if (common.isWindows)
common.skip('dgram clustering is currently not supported on windows.');
const assert = require('assert');
const cluster = require('cluster');
const dgram = require('dgram');
if (common.isWindows) {
common.skip('dgram clustering is currently not supported on windows.');
return;
}
if (cluster.isMaster) {
cluster.fork();
} else {

View File

@ -2,10 +2,8 @@
const common = require('../common');
if (common.isOSX) {
if (common.isOSX)
common.skip('because of 17894467 Apple bug');
return;
}
const assert = require('assert');
const dgram = require('dgram');

View File

@ -21,13 +21,10 @@
'use strict';
const common = require('../common');
const assert = require('assert');
if (common.isOSX) {
if (common.isOSX)
common.skip('because of 17894467 Apple bug');
return;
}
const assert = require('assert');
const dgram = require('dgram');
const client = dgram.createSocket('udp4');

View File

@ -1,12 +1,9 @@
'use strict';
const common = require('../common');
const assert = require('assert');
if (common.isOSX) {
if (common.isOSX)
common.skip('because of 17894467 Apple bug');
return;
}
const assert = require('assert');
const dgram = require('dgram');
const client = dgram.createSocket('udp4');

View File

@ -1,14 +1,12 @@
'use strict';
const common = require('../common');
if (!common.hasIPv6)
common.skip('no IPv6 support');
const assert = require('assert');
const dgram = require('dgram');
if (!common.hasIPv6) {
common.skip('no IPv6 support');
return;
}
const client = dgram.createSocket('udp6');
const toSend = [Buffer.alloc(256, 'x'),

View File

@ -22,10 +22,8 @@
'use strict';
const common = require('../common');
if (!common.hasCrypto) {
if (!common.hasCrypto)
common.skip('node compiled without OpenSSL.');
return;
}
const assert = require('assert');
const crypto = require('crypto');

View File

@ -23,10 +23,8 @@
const common = require('../common');
if (!common.hasCrypto) {
if (!common.hasCrypto)
common.skip('node compiled without OpenSSL.');
return;
}
const crypto = require('crypto');

View File

@ -1,12 +1,9 @@
'use strict';
const common = require('../common');
const assert = require('assert');
if (!common.hasFipsCrypto) {
if (!common.hasFipsCrypto)
common.skip('node compiled without FIPS OpenSSL.');
return;
}
const assert = require('assert');
const crypto = require('crypto');
const fs = require('fs');

View File

@ -21,15 +21,13 @@
'use strict';
const common = require('../common');
if (!common.isWindows)
common.skip('this test is Windows-specific.');
const fs = require('fs');
const path = require('path');
const assert = require('assert');
if (!common.isWindows) {
common.skip('this test is Windows-specific.');
return;
}
// make a path that will be at least 260 chars long.
const fileNameLen = Math.max(260 - common.tmpDir.length - 1, 1);
const fileName = path.join(common.tmpDir, 'x'.repeat(fileNameLen));

View File

@ -21,14 +21,12 @@
'use strict';
const common = require('../common');
if (!common.isLinux)
common.skip('Test is linux specific.');
const assert = require('assert');
const fs = require('fs');
if (!common.isLinux) {
common.skip('Test is linux specific.');
return;
}
// Test to make sure reading a file under the /proc directory works. See:
// https://groups.google.com/forum/#!topic/nodejs-dev/rxZ_RoH1Gn0
const hostname = fs.readFileSync('/proc/sys/kernel/hostname');

View File

@ -1,15 +1,13 @@
'use strict';
const common = require('../common');
if (!common.isLinux)
common.skip('Test is linux specific.');
const path = require('path');
const fs = require('fs');
const assert = require('assert');
if (!common.isLinux) {
common.skip('Test is linux specific.');
return;
}
common.refreshTmpDir();
const filename = '\uD83D\uDC04';
const root = Buffer.from(`${common.tmpDir}${path.sep}`);

View File

@ -21,17 +21,15 @@
'use strict';
const common = require('../common');
// `fs.readFile('/')` does not fail on FreeBSD, because you can open and read
// the directory there.
if (common.isFreeBSD)
common.skip('platform not supported.');
const assert = require('assert');
const exec = require('child_process').exec;
const path = require('path');
// `fs.readFile('/')` does not fail on FreeBSD, because you can open and read
// the directory there.
if (common.isFreeBSD) {
common.skip('platform not supported.');
return;
}
function test(env, cb) {
const filename = path.join(common.fixturesDir, 'test-fs-readfile-error.js');
const execPath = `"${process.execPath}" "${filename}"`;

View File

@ -1,15 +1,13 @@
'use strict';
const common = require('../common');
const assert = require('assert');
const path = require('path');
// simulate `cat readfile.js | node readfile.js`
if (common.isWindows || common.isAix) {
if (common.isWindows || common.isAix)
common.skip(`No /dev/stdin on ${process.platform}.`);
return;
}
const assert = require('assert');
const path = require('path');
const fs = require('fs');
if (process.argv[2] === 'child') {

View File

@ -21,15 +21,13 @@
'use strict';
const common = require('../common');
const assert = require('assert');
// simulate `cat readfile.js | node readfile.js`
if (common.isWindows || common.isAix) {
if (common.isWindows || common.isAix)
common.skip(`No /dev/stdin on ${process.platform}.`);
return;
}
const assert = require('assert');
const fs = require('fs');
const dataExpected = fs.readFileSync(__filename, 'utf8');

View File

@ -1,15 +1,13 @@
'use strict';
const common = require('../common');
const assert = require('assert');
const path = require('path');
// simulate `cat readfile.js | node readfile.js`
if (common.isWindows || common.isAix) {
if (common.isWindows || common.isAix)
common.skip(`No /dev/stdin on ${process.platform}.`);
return;
}
const assert = require('assert');
const path = require('path');
const fs = require('fs');
if (process.argv[2] === 'child') {

View File

@ -1,14 +1,13 @@
'use strict';
const common = require('../common');
if (!common.isWindows)
common.skip('Test for Windows only');
const assert = require('assert');
const fs = require('fs');
const spawnSync = require('child_process').spawnSync;
if (!common.isWindows) {
common.skip('Test for Windows only');
return;
}
let result;
// create a subst drive
@ -21,10 +20,8 @@ for (i = 0; i < driveLetters.length; ++i) {
if (result.status === 0)
break;
}
if (i === driveLetters.length) {
if (i === driveLetters.length)
common.skip('Cannot create subst drive');
return;
}
// schedule cleanup (and check if all callbacks where called)
process.on('exit', function() {

View File

@ -2,10 +2,8 @@
const common = require('../common');
if (common.isWindows || common.isAix) {
if (common.isWindows || common.isAix)
common.skip(`No /dev/stdin on ${process.platform}.`);
return;
}
const assert = require('assert');

Some files were not shown because too many files have changed in this diff Show More