Skip to content

Commit

Permalink
test: abstract skip functionality to common
Browse files Browse the repository at this point in the history
The tap skipping output is so prevalent yet obscure in nature that we
ought to move it into it's own function in test/common.js

PR-URL: #6697
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Santiago Gimeno <[email protected]>
Reviewed-By: Fedor Indutny <[email protected]>
  • Loading branch information
Fishrock123 authored and evanlucas committed May 17, 2016
1 parent 7d3f575 commit b1f58ed
Show file tree
Hide file tree
Showing 229 changed files with 300 additions and 304 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ const assert = require('assert');
// v8::String::kMaxLength defined in v8.h
const kStringMaxLength = process.binding('buffer').kStringMaxLength;

const skipMessage =
'1..0 # Skipped: intensive toString tests due to memory confinements';
const skipMessage = 'intensive toString tests due to memory confinements';
if (!common.enoughTestMem) {
console.log(skipMessage);
common.skip(skipMessage);
return;
}

Expand All @@ -20,13 +19,13 @@ try {
} catch (e) {
// If the exception is not due to memory confinement then rethrow it.
if (e.message !== 'Array buffer allocation failed') throw (e);
console.log(skipMessage);
common.skip(skipMessage);
return;
}

// Ensure we have enough memory available for future allocations to succeed.
if (!binding.ensureAllocation(2 * kStringMaxLength)) {
console.log(skipMessage);
common.skip(skipMessage);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ const common = require('../../common');
const binding = require('./build/Release/binding');
const assert = require('assert');

const skipMessage =
'1..0 # Skipped: intensive toString tests due to memory confinements';
const skipMessage = 'intensive toString tests due to memory confinements';
if (!common.enoughTestMem) {
console.log(skipMessage);
common.skip(skipMessage);
return;
}

Expand All @@ -20,13 +19,13 @@ try {
} catch (e) {
// If the exception is not due to memory confinement then rethrow it.
if (e.message !== 'Array buffer allocation failed') throw (e);
console.log(skipMessage);
common.skip(skipMessage);
return;
}

// Ensure we have enough memory available for future allocations to succeed.
if (!binding.ensureAllocation(2 * kStringMaxLength)) {
console.log(skipMessage);
common.skip(skipMessage);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ const common = require('../../common');
const binding = require('./build/Release/binding');
const assert = require('assert');

const skipMessage =
'1..0 # Skipped: intensive toString tests due to memory confinements';
const skipMessage = 'intensive toString tests due to memory confinements';
if (!common.enoughTestMem) {
console.log(skipMessage);
common.skip(skipMessage);
return;
}

Expand All @@ -20,13 +19,13 @@ try {
} catch (e) {
// If the exception is not due to memory confinement then rethrow it.
if (e.message !== 'Array buffer allocation failed') throw (e);
console.log(skipMessage);
common.skip(skipMessage);
return;
}

// Ensure we have enough memory available for future allocations to succeed.
if (!binding.ensureAllocation(2 * kStringMaxLength)) {
console.log(skipMessage);
common.skip(skipMessage);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ const common = require('../../common');
const binding = require('./build/Release/binding');
const assert = require('assert');

const skipMessage =
'1..0 # Skipped: intensive toString tests due to memory confinements';
const skipMessage = 'intensive toString tests due to memory confinements';
if (!common.enoughTestMem) {
console.log(skipMessage);
common.skip(skipMessage);
return;
}

Expand All @@ -20,13 +19,13 @@ try {
} catch (e) {
// If the exception is not due to memory confinement then rethrow it.
if (e.message !== 'Array buffer allocation failed') throw (e);
console.log(skipMessage);
common.skip(skipMessage);
return;
}

// Ensure we have enough memory available for future allocations to succeed.
if (!binding.ensureAllocation(2 * kStringMaxLength)) {
console.log(skipMessage);
common.skip(skipMessage);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ const common = require('../../common');
const binding = require('./build/Release/binding');
const assert = require('assert');

const skipMessage =
'1..0 # Skipped: intensive toString tests due to memory confinements';
const skipMessage = 'intensive toString tests due to memory confinements';
if (!common.enoughTestMem) {
console.log(skipMessage);
common.skip(skipMessage);
return;
}

Expand All @@ -20,13 +19,13 @@ try {
} catch (e) {
// If the exception is not due to memory confinement then rethrow it.
if (e.message !== 'Array buffer allocation failed') throw (e);
console.log(skipMessage);
common.skip(skipMessage);
return;
}

// Ensure we have enough memory available for future allocations to succeed.
if (!binding.ensureAllocation(2 * kStringMaxLength)) {
console.log(skipMessage);
common.skip(skipMessage);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ const common = require('../../common');
const binding = require('./build/Release/binding');
const assert = require('assert');

const skipMessage =
'1..0 # Skipped: intensive toString tests due to memory confinements';
const skipMessage = 'intensive toString tests due to memory confinements';
if (!common.enoughTestMem) {
console.log(skipMessage);
common.skip(skipMessage);
return;
}

Expand All @@ -20,13 +19,13 @@ try {
} catch (e) {
// If the exception is not due to memory confinement then rethrow it.
if (e.message !== 'Array buffer allocation failed') throw (e);
console.log(skipMessage);
common.skip(skipMessage);
return;
}

// Ensure we have enough memory available for future allocations to succeed.
if (!binding.ensureAllocation(2 * kStringMaxLength)) {
console.log(skipMessage);
common.skip(skipMessage);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ const common = require('../../common');
const binding = require('./build/Release/binding');
const assert = require('assert');

const skipMessage =
'1..0 # Skipped: intensive toString tests due to memory confinements';
const skipMessage = 'intensive toString tests due to memory confinements';
if (!common.enoughTestMem) {
console.log(skipMessage);
common.skip(skipMessage);
return;
}

Expand All @@ -20,13 +19,13 @@ try {
} catch (e) {
// If the exception is not due to memory confinement then rethrow it.
if (e.message !== 'Array buffer allocation failed') throw (e);
console.log(skipMessage);
common.skip(skipMessage);
return;
}

// Ensure we have enough memory available for future allocations to succeed.
if (!binding.ensureAllocation(2 * kStringMaxLength)) {
console.log(skipMessage);
common.skip(skipMessage);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ const common = require('../../common');
const binding = require('./build/Release/binding');
const assert = require('assert');

const skipMessage =
'1..0 # Skipped: intensive toString tests due to memory confinements';
const skipMessage = 'intensive toString tests due to memory confinements';
if (!common.enoughTestMem) {
console.log(skipMessage);
common.skip(skipMessage);
return;
}

Expand All @@ -20,13 +19,13 @@ try {
} catch (e) {
// If the exception is not due to memory confinement then rethrow it.
if (e.message !== 'Array buffer allocation failed') throw (e);
console.log(skipMessage);
common.skip(skipMessage);
return;
}

// Ensure we have enough memory available for future allocations to succeed.
if (!binding.ensureAllocation(2 * kStringMaxLength)) {
console.log(skipMessage);
common.skip(skipMessage);
return;
}

Expand Down
3 changes: 3 additions & 0 deletions test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,9 @@ exports.fail = function(msg) {
assert.fail(null, null, msg);
};

exports.skip = function(msg) {
console.log(`1..0 # Skipped: ${msg}`);
};

// A stream to push an array into a REPL
function ArrayStream() {
Expand Down
2 changes: 1 addition & 1 deletion test/disabled/tls_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var certPem = fs.readFileSync(common.fixturesDir + '/cert.pem');
try {
var credentials = crypto.createCredentials({key: keyPem, cert: certPem});
} catch (e) {
console.log('1..0 # Skipped: node compiled without OpenSSL.');
common.skip('node compiled without OpenSSL.');
return;
}
var i = 0;
Expand Down
2 changes: 1 addition & 1 deletion test/internet/test-dgram-broadcast-multi-process.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const messages = [
];

if (common.inFreeBSDJail) {
console.log('1..0 # Skipped: in a FreeBSD jail');
common.skip('in a FreeBSD jail');
return;
}

Expand Down
2 changes: 1 addition & 1 deletion test/internet/test-dgram-multicast-multi-process.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const listeners = 3;

// Skip test in FreeBSD jails.
if (common.inFreeBSDJail) {
console.log('1..0 # Skipped: In a FreeBSD jail');
common.skip('In a FreeBSD jail');
return;
}

Expand Down
2 changes: 1 addition & 1 deletion test/internet/test-dns-ipv6.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ let running = false;
const queue = [];

if (!common.hasIPv6) {
console.log('1..0 # Skipped: this test, no IPv6 support');
common.skip('this test, no IPv6 support');
return;
}

Expand Down
2 changes: 1 addition & 1 deletion test/internet/test-http-https-default-ports.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var common = require('../common');
var assert = require('assert');

if (!common.hasCrypto) {
console.log('1..0 # Skipped: missing crypto');
common.skip('missing crypto');
return;
}
var https = require('https');
Expand Down
2 changes: 1 addition & 1 deletion test/internet/test-tls-connnect-cnnic.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

var common = require('../common');
if (!common.hasCrypto) {
console.log('1..0 # Skipped: missing crypto');
common.skip('missing crypto');
return;
}

Expand Down
2 changes: 1 addition & 1 deletion test/internet/test-tls-connnect-melissadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

var common = require('../common');
if (!common.hasCrypto) {
console.log('1..0 # Skipped: missing crypto');
common.skip('missing crypto');
return;
}

Expand Down
2 changes: 1 addition & 1 deletion test/internet/test-tls-reuse-host-from-socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var common = require('../common');
var assert = require('assert');

if (!common.hasCrypto) {
console.log('1..0 # Skipped: missing crypto');
common.skip('missing crypto');
return;
}
var tls = require('tls');
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-buffer-alloc.js
Original file line number Diff line number Diff line change
Expand Up @@ -1364,7 +1364,7 @@ if (common.hasCrypto) {
crypto.createHash('sha1').update(b2).digest('hex')
);
} else {
console.log('1..0 # Skipped: missing crypto');
common.skip('missing crypto');
}

// Test Compare
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1367,7 +1367,7 @@ if (common.hasCrypto) {
crypto.createHash('sha1').update(b2).digest('hex')
);
} else {
console.log('1..0 # Skipped: missing crypto');
common.skip('missing crypto');
}

// Test Compare
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-child-process-fork-dgram.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var assert = require('assert');
var common = require('../common');

if (common.isWindows) {
console.log('1..0 # Skipped: Sending dgram sockets to child processes is ' +
common.skip('Sending dgram sockets to child processes is ' +
'not supported');
return;
}
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-cluster-bind-privileged-port.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ var cluster = require('cluster');
var net = require('net');

if (common.isWindows) {
console.log('1..0 # Skipped: not reliable on Windows.');
common.skip('not reliable on Windows.');
return;
}

if (process.getuid() === 0) {
console.log('1..0 # Skipped: Test is not supposed to be run as root.');
common.skip('Test is not supposed to be run as root.');
return;
}

Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-cluster-dgram-1.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var dgram = require('dgram');


if (common.isWindows) {
console.log('1..0 # Skipped: dgram clustering is currently not supported ' +
common.skip('dgram clustering is currently not supported ' +
'on windows.');
return;
}
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-cluster-dgram-2.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var dgram = require('dgram');


if (common.isWindows) {
console.log('1..0 # Skipped: dgram clustering is currently not supported ' +
common.skip('dgram clustering is currently not supported ' +
'on windows.');
return;
}
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-cluster-dgram-reuse.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const cluster = require('cluster');
const dgram = require('dgram');

if (common.isWindows) {
console.log('1..0 # Skipped: dgram clustering is currently not supported ' +
common.skip('dgram clustering is currently not supported ' +
'on windows.');
return;
}
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-cluster-disconnect-handles.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const net = require('net');
const Protocol = require('_debugger').Protocol;

if (common.isWindows) {
console.log('1..0 # Skipped: SCHED_RR not reliable on Windows');
common.skip('SCHED_RR not reliable on Windows');
return;
}

Expand Down
Loading

0 comments on commit b1f58ed

Please sign in to comment.