Skip to content

Commit 06c29a6

Browse files
committed
test: remove common.fail()
common.fail() was added to paste over issues with assert.fail() function signature. assert.fail() has been updated to accept a single argument so common.fail() is no longer necessary. PR-URL: #12293 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 6f202ef commit 06c29a6

File tree

51 files changed

+101
-106
lines changed

Some content is hidden

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

51 files changed

+101
-106
lines changed

test/README.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -246,12 +246,6 @@ Checks whether `IPv6` is supported on this platform.
246246

247247
Checks if there are multiple localhosts available.
248248

249-
### fail(msg)
250-
* `msg` [&lt;String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)
251-
* return [&lt;Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)
252-
253-
Throws an `AssertionError` with `msg`
254-
255249
### fileExists(pathname)
256250
* pathname [&lt;String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)
257251
* return [&lt;Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)

test/common.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ process.on('exit', function() {
404404
if (!exports.globalCheck) return;
405405
const leaked = leakedGlobals();
406406
if (leaked.length > 0) {
407-
fail(`Unexpected global(s) found: ${leaked.join(', ')}`);
407+
assert.fail(`Unexpected global(s) found: ${leaked.join(', ')}`);
408408
}
409409
});
410410

@@ -507,14 +507,9 @@ exports.canCreateSymLink = function() {
507507
return true;
508508
};
509509

510-
function fail(msg) {
511-
assert.fail(null, null, msg);
512-
}
513-
exports.fail = fail;
514-
515510
exports.mustNotCall = function(msg) {
516511
return function mustNotCall() {
517-
fail(msg || 'function should not have been called');
512+
assert.fail(msg || 'function should not have been called');
518513
};
519514
};
520515

@@ -627,7 +622,7 @@ exports.WPT = {
627622
},
628623
assert_array_equals: assert.deepStrictEqual,
629624
assert_unreached(desc) {
630-
assert.fail(undefined, undefined, `Reached unreachable code: ${desc}`);
625+
assert.fail(`Reached unreachable code: ${desc}`);
631626
}
632627
};
633628

test/inspector/inspector-helper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ TestSession.prototype.sendInspectorCommands = function(commands) {
217217
for (const id in this.messages_) {
218218
s += id + ', ';
219219
}
220-
common.fail('Messages without response: ' +
220+
assert.fail('Messages without response: ' +
221221
s.substring(0, s.length - 2));
222222
}, TIMEOUT);
223223
});

test/internet/test-dgram-send-cb-quelches-error.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function callbackOnly(err) {
2828
}
2929

3030
function onEvent(err) {
31-
common.fail('Error should not be emitted if there is callback');
31+
assert.fail('Error should not be emitted if there is callback');
3232
}
3333

3434
function onError(err) {

test/internet/test-dns.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ TEST(function test_lookup_all_mixed(done) {
453453
else if (isIPv6(ip.address))
454454
assert.strictEqual(ip.family, 6);
455455
else
456-
common.fail('unexpected IP address');
456+
assert.fail('unexpected IP address');
457457
});
458458

459459
done();

test/internet/test-tls-add-ca-cert.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ tls.connect(opts, fail).on('error', common.mustCall((err) => {
3838
}));
3939

4040
function fail() {
41-
common.fail('should fail to connect');
41+
assert.fail('should fail to connect');
4242
}
4343

4444
// New secure contexts have the well-known root CAs.

test/parallel/test-beforeexit-event-exit.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@
2020
// USE OR OTHER DEALINGS IN THE SOFTWARE.
2121

2222
'use strict';
23-
const common = require('../common');
23+
require('../common');
24+
const assert = require('assert');
2425

2526
process.on('beforeExit', function() {
26-
common.fail('exit should not allow this to occur');
27+
assert.fail('exit should not allow this to occur');
2728
});
2829

2930
process.exit();

test/parallel/test-child-process-fork-and-spawn.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ switch (process.argv[2] || '') {
3737
case 'spawn':
3838
break;
3939
default:
40-
common.fail();
40+
assert.fail();
4141
}
4242

4343
function checkExit(statusCode) {

test/parallel/test-child-process-stdout-flush-exit.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ if (process.argv[2] === 'child') {
4242

4343
child.stderr.setEncoding('utf8');
4444
child.stderr.on('data', function(data) {
45-
common.fail(`Unexpected parent stderr: ${data}`);
45+
assert.fail(`Unexpected parent stderr: ${data}`);
4646
});
4747

4848
// check if we receive both 'hello' at start and 'goodbye' at end

test/parallel/test-cluster-send-handle-twice.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ if (cluster.isMaster) {
5151
setTimeout(function() { client.end(); }, 50);
5252
}).on('error', function(e) {
5353
console.error(e);
54-
common.fail('server.listen failed');
54+
assert.fail('server.listen failed');
5555
cluster.worker.disconnect();
5656
});
5757
}

0 commit comments

Comments
 (0)