Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: simplify test skipping #14021

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 3 additions & 5 deletions test/abort/test-abort-backtrace.js
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
8 changes: 3 additions & 5 deletions test/addons/load-long-path/test.js
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
5 changes: 2 additions & 3 deletions test/addons/openssl-binding/test.js
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,29 @@
'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');

// v8 fails silently if string length > v8::String::kMaxLength
// 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);
} catch (e) {
// 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);
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
'use strict';

const common = require('../../common');
const binding = require(`./build/${common.buildType}/binding`);
const assert = require('assert');

const skipMessage = 'intensive toString tests due to memory confinements';
if (!common.enoughTestMem) {
if (!common.enoughTestMem)
common.skip(skipMessage);
return;
}

const binding = require(`./build/${common.buildType}/binding`);
const assert = require('assert');

// v8 fails silently if string length > v8::String::kMaxLength
// v8::String::kMaxLength defined in v8.h
Expand All @@ -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');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
'use strict';

const common = require('../../common');
const binding = require(`./build/${common.buildType}/binding`);
const assert = require('assert');

const skipMessage = 'intensive toString tests due to memory confinements';
if (!common.enoughTestMem) {
if (!common.enoughTestMem)
common.skip(skipMessage);
return;
}

const binding = require(`./build/${common.buildType}/binding`);
const assert = require('assert');

// v8 fails silently if string length > v8::String::kMaxLength
// v8::String::kMaxLength defined in v8.h
Expand All @@ -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');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
'use strict';

const common = require('../../common');
const binding = require(`./build/${common.buildType}/binding`);
const assert = require('assert');

const skipMessage = 'intensive toString tests due to memory confinements';
if (!common.enoughTestMem) {
if (!common.enoughTestMem)
common.skip(skipMessage);
return;
}

const binding = require(`./build/${common.buildType}/binding`);
const assert = require('assert');

// v8 fails silently if string length > v8::String::kMaxLength
// v8::String::kMaxLength defined in v8.h
Expand All @@ -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');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
'use strict';

const common = require('../../common');
const binding = require(`./build/${common.buildType}/binding`);
const assert = require('assert');

const skipMessage = 'intensive toString tests due to memory confinements';
if (!common.enoughTestMem) {
if (!common.enoughTestMem)
common.skip(skipMessage);
return;
}

const binding = require(`./build/${common.buildType}/binding`);
const assert = require('assert');

// v8 fails silently if string length > v8::String::kMaxLength
// v8::String::kMaxLength defined in v8.h
Expand All @@ -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');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
'use strict';

const common = require('../../common');
const binding = require(`./build/${common.buildType}/binding`);
const assert = require('assert');

const skipMessage = 'intensive toString tests due to memory confinements';
if (!common.enoughTestMem) {
if (!common.enoughTestMem)
common.skip(skipMessage);
return;
}

const binding = require(`./build/${common.buildType}/binding`);
const assert = require('assert');

// v8 fails silently if string length > v8::String::kMaxLength
// v8::String::kMaxLength defined in v8.h
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
'use strict';

const common = require('../../common');
const binding = require(`./build/${common.buildType}/binding`);
const assert = require('assert');

const skipMessage = 'intensive toString tests due to memory confinements';
if (!common.enoughTestMem) {
if (!common.enoughTestMem)
common.skip(skipMessage);
return;
}

const binding = require(`./build/${common.buildType}/binding`);
const assert = require('assert');

// v8 fails silently if string length > v8::String::kMaxLength
// v8::String::kMaxLength defined in v8.h
Expand All @@ -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);
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
'use strict';

const common = require('../../common');
const binding = require(`./build/${common.buildType}/binding`);
const assert = require('assert');

const skipMessage = 'intensive toString tests due to memory confinements';
if (!common.enoughTestMem) {
if (!common.enoughTestMem)
common.skip(skipMessage);
return;
}

const binding = require(`./build/${common.buildType}/binding`);
const assert = require('assert');

// v8 fails silently if string length > v8::String::kMaxLength
// v8::String::kMaxLength defined in v8.h
Expand All @@ -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');
Expand Down
1 change: 0 additions & 1 deletion test/addons/symlinked-module/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
10 changes: 4 additions & 6 deletions test/async-hooks/test-connection.ssl.js
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
5 changes: 2 additions & 3 deletions test/async-hooks/test-crypto-pbkdf2.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
5 changes: 2 additions & 3 deletions test/async-hooks/test-crypto-randomBytes.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
Loading