Skip to content

Commit

Permalink
test: remove common.expectsInternalAssertion
Browse files Browse the repository at this point in the history
Remove convenience function for internal assertions. It is only used
once.

Signed-off-by: Rich Trott <[email protected]>

PR-URL: #32057
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Anto Aravinth <[email protected]>
  • Loading branch information
Trott authored and MylesBorins committed Mar 9, 2020
1 parent 31e4a0d commit 89987b3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 20 deletions.
14 changes: 0 additions & 14 deletions test/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -547,19 +547,6 @@ function expectsError(validator, exact) {
}, exact);
}

const suffix = 'This is caused by either a bug in Node.js ' +
'or incorrect usage of Node.js internals.\n' +
'Please open an issue with this stack trace at ' +
'https://github.com/nodejs/node/issues\n';

function expectsInternalAssertion(fn, message) {
assert.throws(fn, {
message: `${message}\n${suffix}`,
name: 'Error',
code: 'ERR_INTERNAL_ASSERTION'
});
}

function skipIfInspectorDisabled() {
if (!process.features.inspector) {
skip('V8 inspector is disabled');
Expand Down Expand Up @@ -680,7 +667,6 @@ const common = {
createZeroFilledFile,
disableCrashOnUnhandledRejection,
expectsError,
expectsInternalAssertion,
expectWarning,
getArrayBufferViews,
getBufferSources,
Expand Down
11 changes: 7 additions & 4 deletions test/parallel/test-internal-errors.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Flags: --expose-internals
'use strict';
const common = require('../common');
require('../common');
const {
hijackStdout,
restoreStdout,
Expand Down Expand Up @@ -50,10 +50,13 @@ errors.E('TEST_ERROR_2', (a, b) => `${a} ${b}`, Error);
}

{
common.expectsInternalAssertion(
assert.throws(
() => new errors.codes.TEST_ERROR_1(),
'Code: TEST_ERROR_1; The provided arguments ' +
'length (0) does not match the required ones (1).'
{
message: /^Code: TEST_ERROR_1; The provided arguments length \(0\) does not match the required ones \(1\)\./,
name: 'Error',
code: 'ERR_INTERNAL_ASSERTION'
}
);
}

Expand Down
8 changes: 6 additions & 2 deletions test/sequential/test-fs-watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,18 @@ tmpdir.refresh();
// https://github.com/joyent/node/issues/6690
{
let oldhandle;
common.expectsInternalAssertion(
assert.throws(
() => {
const w = fs.watch(__filename, common.mustNotCall());
oldhandle = w._handle;
w._handle = { close: w._handle.close };
w.close();
},
'handle must be a FSEvent'
{
message: /^handle must be a FSEvent/,
name: 'Error',
code: 'ERR_INTERNAL_ASSERTION',
}
);
oldhandle.close(); // clean up
}

0 comments on commit 89987b3

Please sign in to comment.