8000 test: remove common.fail() · nodejs/node@1091b86 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1091b86

Browse files
TrottMylesBorins
authored andcommitted
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. Backport-PR-URL: #15479 PR-URL: #12293 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 44cc39d commit 1091b86
  • Some content is hidden

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

    45 files changed

    +95
    -89
    lines changed

    test/common/index.js

    Lines changed: 2 additions & 7 deletions
    Original file line numberDiff line numberDiff line change
    @@ -385,7 +385,7 @@ process.on('exit', function() {
    385385
    if (!exports.globalCheck) return;
    386386
    const leaked = leakedGlobals();
    387387
    if (leaked.length > 0) {
    388-
    fail(`Unexpected global(s) found: ${leaked.join(', ')}`);
    388+
    assert.fail(`Unexpected global(s) found: ${leaked.join(', ')}`);
    389389
    }
    390390
    });
    391391

    @@ -473,14 +473,9 @@ exports.fileExists = function(pathname) {
    473473
    }
    474474
    };
    475475

    476-
    function fail(msg) {
    477-
    assert.fail(null, null, msg);
    478-
    }
    479-
    exports.fail = fail;
    480-
    481476
    exports.mustNotCall = function(msg) {
    482477
    return function mustNotCall() {
    483-
    fail(msg || 'function should not have been called');
    478+
    assert.fail(msg || 'function should not have been called');
    484479
    };
    485480
    };
    486481

    test/inspector/inspector-helper.js

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -222,7 +222,7 @@ TestSession.prototype.sendInspectorCommands = function(commands) {
    222222
    };
    223223
    this.sendAll_(commands, () => {
    224224
    timeoutId = setTimeout(() => {
    225-
    common.fail(`Messages without response: ${
    225+
    assert.fail(`Messages without response: ${
    226226
    Object.keys(this.messages_).join(', ')}`);
    227227
    }, TIMEOUT);
    228228
    });

    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
    @@ -449,7 +449,7 @@ TEST(function test_lookup_all_mixed(done) {
    449449
    else if (isIPv6(ip.address))
    450450
    assert.strictEqual(ip.family, 6);
    451451
    else
    452-
    assert(false);
    452+
    assert.fail('unexpected IP address');
    453453
    });
    454454

    455455
    done();

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

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

    3939
    function fail() {
    40-
    assert(false, 'should fail to connect');
    40+
    assert.fail('should fail to connect');
    4141
    }
    4242

    4343
    // New secure contexts have the well-known root CAs.
    Lines changed: 3 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -1,8 +1,9 @@
    11
    'use strict';
    2-
    const common = require('../common');
    2+
    require('../common');
    3+
    const assert = require('assert');
    34

    45
    process.on('beforeExit', function() {
    5-
    common.fail('exit should not allow this to occur');
    6+
    assert.fail('exit should not allow this to occur');
    67
    });
    78

    89
    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
    @@ -15,7 +15,7 @@ switch (process.argv[2] || '') {
    1515
    case 'spawn':
    1616
    break;
    1717
    default:
    18-
    common.fail();
    18+
    assert.fail();
    1919
    }
    2020

    2121
    function checkExit(statusCode) {

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

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

    2222
    child.stderr.setEncoding('utf8');
    2323
    child.stderr.on('data', function(data) {
    24-
    console.log('parent stderr: ' + data);
    25-
    assert.ok(false);
    24+
    assert.fail(`Unexpected parent stderr: ${data}`);
    2625
    });
    2726

    2827
    // 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
    @@ -33,7 +33,7 @@ if (cluster.isMaster) {
    3333
    setTimeout(function() { client.end(); }, 50);
    3434
    }).on('error', function(e) {
    3535
    console.error(e);
    36-
    common.fail('server.listen failed');
    36+
    assert.fail('server.listen failed');
    3737
    cluster.worker.disconnect();
    3838
    });
    3939
    }

    test/parallel/test-domain-uncaught-exception.js

    Lines changed: 6 additions & 5 deletions
    Original file line numberDiff line numberDiff line change
    @@ -184,15 +184,16 @@ if (process.argv[2] === 'child') {
    184184
    test.expectedMessages.forEach(function(expectedMessage) {
    185185
    if (test.messagesReceived === undefined ||
    186186
    test.messagesReceived.indexOf(expectedMessage) === -1)
    187-
    assert(false, `test ${test.fn.name} should have sent message: ${
    188-
    expectedMessage} but didn't`);
    187+
    assert.fail('test ' + test.fn.name + ' should have sent message: ' +
    188+
    expectedMessage + ' but didn\'t');
    189189
    });
    190190

    191191
    if (test.messagesReceived) {
    192192
    test.messagesReceived.forEach(function(receivedMessage) {
    193-
    if (!test.expectedMessages.includes(receivedMessage)) {
    194-
    assert(false, `test ${test.fn.name} should not have sent message: ${
    195-
    receivedMessage} but did`);
    193+
    if (test.expectedMessages.indexOf(receivedMessage) === -1) {
    194+
    assert.fail('test ' + test.fn.name +
    195+
    ' should not have sent message: ' + receivedMessage +
    196+
    ' but did');
    196197
    }
    197198
    });
    198199
    }

    0 commit comments

    Comments
     (0)
    0