Skip to content

Commit 32a8f36

Browse files
vsemozhetbytaddaleax
authored andcommitted
test: simplify test skipping
* Make common.skip() exit. Also add common.printSkipMessage() for partial skips. * Don't make needless things before skip PR-URL: #14021 Fixes: #14016 Reviewed-By: Refael Ackermann <[email protected]>
1 parent 0cc12fc commit 32a8f36

File tree

333 files changed

+896
-1633
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

333 files changed

+896
-1633
lines changed

test/abort/test-abort-backtrace.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
'use strict';
22
const common = require('../common');
3+
if (common.isWindows)
4+
common.skip('Backtraces unimplemented on Windows.');
5+
36
const assert = require('assert');
47
const cp = require('child_process');
58

6-
if (common.isWindows) {
7-
common.skip('Backtraces unimplemented on Windows.');
8-
return;
9-
}
10-
119
if (process.argv[2] === 'child') {
1210
process.abort();
1311
} else {

test/addons/load-long-path/test.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
'use strict';
22
const common = require('../../common');
3+
if (common.isWOW64)
4+
common.skip('doesn\'t work on WOW64');
5+
36
const fs = require('fs');
47
const path = require('path');
58
const assert = require('assert');
69

7-
if (common.isWOW64) {
8-
common.skip('doesn\'t work on WOW64');
9-
return;
10-
}
11-
1210
common.refreshTmpDir();
1311

1412
// make a path that is more than 260 chars long.

test/addons/openssl-binding/test.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
'use strict';
22

33
const common = require('../../common');
4-
if (!common.hasCrypto) {
4+
if (!common.hasCrypto)
55
common.skip('missing crypto');
6-
process.exit(0);
7-
}
6+
87
const assert = require('assert');
98
const binding = require(`./build/${common.buildType}/binding`);
109
const bytes = new Uint8Array(1024);
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,29 @@
11
'use strict';
22

33
const common = require('../../common');
4+
const skipMessage = 'intensive toString tests due to memory confinements';
5+
if (!common.enoughTestMem)
6+
common.skip(skipMessage);
7+
48
const binding = require(`./build/${common.buildType}/binding`);
59
const assert = require('assert');
610

711
// v8 fails silently if string length > v8::String::kMaxLength
812
// v8::String::kMaxLength defined in v8.h
913
const kStringMaxLength = process.binding('buffer').kStringMaxLength;
1014

11-
const skipMessage = 'intensive toString tests due to memory confinements';
12-
if (!common.enoughTestMem) {
13-
common.skip(skipMessage);
14-
return;
15-
}
16-
1715
let buf;
1816
try {
1917
buf = Buffer.allocUnsafe(kStringMaxLength);
2018
} catch (e) {
2119
// If the exception is not due to memory confinement then rethrow it.
2220
if (e.message !== 'Array buffer allocation failed') throw (e);
2321
common.skip(skipMessage);
24-
return;
2522
}
2623

2724
// Ensure we have enough memory available for future allocations to succeed.
28-
if (!binding.ensureAllocation(2 * kStringMaxLength)) {
25+
if (!binding.ensureAllocation(2 * kStringMaxLength))
2926
common.skip(skipMessage);
30-
return;
31-
}
3227

3328
const maxString = buf.toString('latin1');
3429
assert.strictEqual(maxString.length, kStringMaxLength);

test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-ascii.js

+5-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
'use strict';
22

33
const common = require('../../common');
4-
const binding = require(`./build/${common.buildType}/binding`);
5-
const assert = require('assert');
6-
74
const skipMessage = 'intensive toString tests due to memory confinements';
8-
if (!common.enoughTestMem) {
5+
if (!common.enoughTestMem)
96
common.skip(skipMessage);
10-
return;
11-
}
7+
8+
const binding = require(`./build/${common.buildType}/binding`);
9+
const assert = require('assert');
1210

1311
// v8 fails silently if string length > v8::String::kMaxLength
1412
// v8::String::kMaxLength defined in v8.h
@@ -21,14 +19,11 @@ try {
2119
// If the exception is not due to memory confinement then rethrow it.
2220
if (e.message !== 'Array buffer allocation failed') throw (e);
2321
common.skip(skipMessage);
24-
return;
2522
}
2623

2724
// Ensure we have enough memory available for future allocations to succeed.
28-
if (!binding.ensureAllocation(2 * kStringMaxLength)) {
25+
if (!binding.ensureAllocation(2 * kStringMaxLength))
2926
common.skip(skipMessage);
30-
return;
31-
}
3227

3328
assert.throws(function() {
3429
buf.toString('ascii');

test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-base64.js

+5-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
'use strict';
22

33
const common = require('../../common');
4-
const binding = require(`./build/${common.buildType}/binding`);
5-
const assert = require('assert');
6-
74
const skipMessage = 'intensive toString tests due to memory confinements';
8-
if (!common.enoughTestMem) {
5+
if (!common.enoughTestMem)
96
common.skip(skipMessage);
10-
return;
11-
}
7+
8+
const binding = require(`./build/${common.buildType}/binding`);
9+
const assert = require('assert');
1210

1311
// v8 fails silently if string length > v8::String::kMaxLength
1412
// v8::String::kMaxLength defined in v8.h
@@ -21,14 +19,11 @@ try {
2119
// If the exception is not due to memory confinement then rethrow it.
2220
if (e.message !== 'Array buffer allocation failed') throw (e);
2321
common.skip(skipMessage);
24-
return;
2522
}
2623

2724
// Ensure we have enough memory available for future allocations to succeed.
28-
if (!binding.ensureAllocation(2 * kStringMaxLength)) {
25+
if (!binding.ensureAllocation(2 * kStringMaxLength))
2926
common.skip(skipMessage);
30-
return;
31-
}
3227

3328
assert.throws(function() {
3429
buf.toString('base64');

test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-binary.js

+5-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
'use strict';
22

33
const common = require('../../common');
4-
const binding = require(`./build/${common.buildType}/binding`);
5-
const assert = require('assert');
6-
74
const skipMessage = 'intensive toString tests due to memory confinements';
8-
if (!common.enoughTestMem) {
5+
if (!common.enoughTestMem)
96
common.skip(skipMessage);
10-
return;
11-
}
7+
8+
const binding = require(`./build/${common.buildType}/binding`);
9+
const assert = require('assert');
1210

1311
// v8 fails silently if string length > v8::String::kMaxLength
1412
// v8::String::kMaxLength defined in v8.h
@@ -21,14 +19,11 @@ try {
2119
// If the exception is not due to memory confinement then rethrow it.
2220
if (e.message !== 'Array buffer allocation failed') throw (e);
2321
common.skip(skipMessage);
24-
return;
2522
}
2623

2724
// Ensure we have enough memory available for future allocations to succeed.
28-
if (!binding.ensureAllocation(2 * kStringMaxLength)) {
25+
if (!binding.ensureAllocation(2 * kStringMaxLength))
2926
common.skip(skipMessage);
30-
return;
31-
}
3227

3328
assert.throws(function() {
3429
buf.toString('latin1');

test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-hex.js

+5-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
'use strict';
22

33
const common = require('../../common');
4-
const binding = require(`./build/${common.buildType}/binding`);
5-
const assert = require('assert');
6-
74
const skipMessage = 'intensive toString tests due to memory confinements';
8-
if (!common.enoughTestMem) {
5+
if (!common.enoughTestMem)
96
common.skip(skipMessage);
10-
return;
11-
}
7+
8+
const binding = require(`./build/${common.buildType}/binding`);
9+
const assert = require('assert');
1210

1311
// v8 fails silently if string length > v8::String::kMaxLength
1412
// v8::String::kMaxLength defined in v8.h
@@ -21,14 +19,11 @@ try {
2119
// If the exception is not due to memory confinement then rethrow it.
2220
if (e.message !== 'Array buffer allocation failed') throw (e);
2321
common.skip(skipMessage);
24-
return;
2522
}
2623

2724
// Ensure we have enough memory available for future allocations to succeed.
28-
if (!binding.ensureAllocation(2 * kStringMaxLength)) {
25+
if (!binding.ensureAllocation(2 * kStringMaxLength))
2926
common.skip(skipMessage);
30-
return;
31-
}
3227

3328
assert.throws(function() {
3429
buf.toString('hex');

test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-utf8.js

+5-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
'use strict';
22

33
const common = require('../../common');
4-
const binding = require(`./build/${common.buildType}/binding`);
5-
const assert = require('assert');
6-
74
const skipMessage = 'intensive toString tests due to memory confinements';
8-
if (!common.enoughTestMem) {
5+
if (!common.enoughTestMem)
96
common.skip(skipMessage);
10-
return;
11-
}
7+
8+
const binding = require(`./build/${common.buildType}/binding`);
9+
const assert = require('assert');
1210

1311
// v8 fails silently if string length > v8::String::kMaxLength
1412
// v8::String::kMaxLength defined in v8.h
@@ -21,14 +19,11 @@ try {
2119
// If the exception is not due to memory confinement then rethrow it.
2220
if (e.message !== 'Array buffer allocation failed') throw (e);
2321
common.skip(skipMessage);
24-
return;
2522
}
2623

2724
// Ensure we have enough memory available for future allocations to succeed.
28-
if (!binding.ensureAllocation(2 * kStringMaxLength)) {
25+
if (!binding.ensureAllocation(2 * kStringMaxLength))
2926
common.skip(skipMessage);
30-
return;
31-
}
3227

3328
assert.throws(function() {
3429
buf.toString();
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
'use strict';
22

33
const common = require('../../common');
4-
const binding = require(`./build/${common.buildType}/binding`);
5-
const assert = require('assert');
6-
74
const skipMessage = 'intensive toString tests due to memory confinements';
8-
if (!common.enoughTestMem) {
5+
if (!common.enoughTestMem)
96
common.skip(skipMessage);
10-
return;
11-
}
7+
8+
const binding = require(`./build/${common.buildType}/binding`);
9+
const assert = require('assert');
1210

1311
// v8 fails silently if string length > v8::String::kMaxLength
1412
// v8::String::kMaxLength defined in v8.h
@@ -21,14 +19,11 @@ try {
2119
// If the exception is not due to memory confinement then rethrow it.
2220
if (e.message !== 'Array buffer allocation failed') throw (e);
2321
common.skip(skipMessage);
24-
return;
2522
}
2623

2724
// Ensure we have enough memory available for future allocations to succeed.
28-
if (!binding.ensureAllocation(2 * kStringMaxLength)) {
25+
if (!binding.ensureAllocation(2 * kStringMaxLength))
2926
common.skip(skipMessage);
30-
return;
31-
}
3227

3328
const maxString = buf.toString('utf16le');
3429
assert.strictEqual(maxString.length, (kStringMaxLength + 2) / 2);

test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max.js

+5-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
'use strict';
22

33
const common = require('../../common');
4-
const binding = require(`./build/${common.buildType}/binding`);
5-
const assert = require('assert');
6-
74
const skipMessage = 'intensive toString tests due to memory confinements';
8-
if (!common.enoughTestMem) {
5+
if (!common.enoughTestMem)
96
common.skip(skipMessage);
10-
return;
11-
}
7+
8+
const binding = require(`./build/${common.buildType}/binding`);
9+
const assert = require('assert');
1210

1311
// v8 fails silently if string length > v8::String::kMaxLength
1412
// v8::String::kMaxLength defined in v8.h
@@ -21,14 +19,11 @@ try {
2119
// If the exception is not due to memory confinement then rethrow it.
2220
if (e.message !== 'Array buffer allocation failed') throw (e);
2321
common.skip(skipMessage);
24-
return;
2522
}
2623

2724
// Ensure we have enough memory available for future allocations to succeed.
28-
if (!binding.ensureAllocation(2 * kStringMaxLength)) {
25+
if (!binding.ensureAllocation(2 * kStringMaxLength))
2926
common.skip(skipMessage);
30-
return;
31-
}
3227

3328
assert.throws(function() {
3429
buf.toString('utf16le');

test/addons/symlinked-module/test.js

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ try {
2222
} catch (err) {
2323
if (err.code !== 'EPERM') throw err;
2424
common.skip('module identity test (no privs for symlinks)');
25-
return;
2625
}
2726

2827
const sub = require('./submodule');

test/async-hooks/test-connection.ssl.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
'use strict';
22

3+
const common = require('../common');
4+
if (!common.hasCrypto)
5+
common.skip('missing crypto');
6+
37
const initHooks = require('./init-hooks');
48
const tick = require('./tick');
5-
const common = require('../common');
69
const assert = require('assert');
710
const { checkInvocations } = require('./hook-checks');
811

9-
if (!common.hasCrypto) {
10-
common.skip('missing crypto');
11-
return;
12-
}
13-
1412
const tls = require('tls');
1513
const Connection = process.binding('crypto').Connection;
1614
const hooks = initHooks();

test/async-hooks/test-crypto-pbkdf2.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
'use strict';
22

33
const common = require('../common');
4-
if (!common.hasCrypto) {
4+
if (!common.hasCrypto)
55
common.skip('missing crypto');
6-
return;
7-
}
6+
87
const assert = require('assert');
98
const tick = require('./tick');
109
const initHooks = require('./init-hooks');

test/async-hooks/test-crypto-randomBytes.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
'use strict';
22

33
const common = require('../common');
4-
if (!common.hasCrypto) {
4+
if (!common.hasCrypto)
55
common.skip('missing crypto');
6-
return;
7-
}
6+
87
const assert = require('assert');
98
const tick = require('./tick');
109
const initHooks = require('./init-hooks');

0 commit comments

Comments
 (0)