mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 12:20:27 +01:00
test: ensure never settling promises are detected
PR-URL: https://github.com/nodejs/node/pull/50318 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
parent
2da66c1444
commit
8f742bb13f
|
|
@ -49,6 +49,8 @@ rules:
|
|||
message: Use 'test' as debuglog value in tests.
|
||||
- selector: CallExpression:matches([callee.object.name="common"][callee.property.name=/^must(Not)?Call/],[callee.name="mustCall"],[callee.name="mustCallAtLeast"],[callee.name="mustNotCall"])>:first-child[type=/FunctionExpression$/][body.body.length=0]
|
||||
message: Do not use an empty function, omit the parameter altogether.
|
||||
- selector: ExpressionStatement>CallExpression:matches([callee.name='rejects'], [callee.object.name='assert'][callee.property.name='rejects'])
|
||||
message: Calling `assert.rejects` without `await` or `.then(common.mustCall())` will not detect never-settling promises.
|
||||
- selector: Identifier[name='webcrypto']
|
||||
message: Use `globalThis.crypto`.
|
||||
|
||||
|
|
|
|||
|
|
@ -23,55 +23,55 @@ const expectedPackageHack =
|
|||
|
||||
const expectedBare = errTemplate('deep-fail', 'comeOn', '{ comeOn }');
|
||||
|
||||
rejects(async () => {
|
||||
await rejects(async () => {
|
||||
await import(`${fixtureBase}/single-quote.mjs`);
|
||||
}, {
|
||||
name: 'SyntaxError',
|
||||
message: expectedRelative
|
||||
}, 'should support relative specifiers with single quotes');
|
||||
|
||||
rejects(async () => {
|
||||
await rejects(async () => {
|
||||
await import(`${fixtureBase}/double-quote.mjs`);
|
||||
}, {
|
||||
name: 'SyntaxError',
|
||||
message: expectedRelative
|
||||
}, 'should support relative specifiers with double quotes');
|
||||
|
||||
rejects(async () => {
|
||||
await rejects(async () => {
|
||||
await import(`${fixtureBase}/renamed-import.mjs`);
|
||||
}, {
|
||||
name: 'SyntaxError',
|
||||
message: expectedRenamed
|
||||
}, 'should correctly format named imports with renames');
|
||||
|
||||
rejects(async () => {
|
||||
await rejects(async () => {
|
||||
await import(`${fixtureBase}/multi-line.mjs`);
|
||||
}, {
|
||||
name: 'SyntaxError',
|
||||
message: expectedWithoutExample,
|
||||
}, 'should correctly format named imports across multiple lines');
|
||||
|
||||
rejects(async () => {
|
||||
await rejects(async () => {
|
||||
await import(`${fixtureBase}/json-hack.mjs`);
|
||||
}, {
|
||||
name: 'SyntaxError',
|
||||
message: expectedPackageHack
|
||||
}, 'should respect recursive package.json for module type');
|
||||
|
||||
rejects(async () => {
|
||||
await rejects(async () => {
|
||||
await import(`${fixtureBase}/bare-import-single.mjs`);
|
||||
}, {
|
||||
name: 'SyntaxError',
|
||||
message: expectedBare
|
||||
}, 'should support bare specifiers with single quotes');
|
||||
|
||||
rejects(async () => {
|
||||
await rejects(async () => {
|
||||
await import(`${fixtureBase}/bare-import-double.mjs`);
|
||||
}, {
|
||||
name: 'SyntaxError',
|
||||
message: expectedBare
|
||||
}, 'should support bare specifiers with double quotes');
|
||||
|
||||
rejects(async () => {
|
||||
await rejects(async () => {
|
||||
await import(`${fixtureBase}/escaped-single-quote.mjs`);
|
||||
}, /import pkg from '\.\/oh'no\.cjs'/, 'should support relative specifiers with escaped single quote');
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ assert.rejects(
|
|||
code: 'ENOTFOUND',
|
||||
message: `getaddrinfo ENOTFOUND ${addresses.NOT_FOUND}`,
|
||||
},
|
||||
);
|
||||
).then(common.mustCall());
|
||||
|
||||
assert.rejects(
|
||||
dnsPromises.lookup(addresses.NOT_FOUND, {
|
||||
|
|
@ -29,7 +29,7 @@ assert.rejects(
|
|||
code: 'ENOTFOUND',
|
||||
message: `getaddrinfo ENOTFOUND ${addresses.NOT_FOUND}`,
|
||||
},
|
||||
);
|
||||
).then(common.mustCall());
|
||||
|
||||
dns.lookup(addresses.NOT_FOUND, {
|
||||
hints: 0,
|
||||
|
|
|
|||
|
|
@ -409,10 +409,10 @@ assert.throws(() => new Blob({}), {
|
|||
}
|
||||
|
||||
(async () => {
|
||||
assert.rejects(async () => Blob.prototype.arrayBuffer.call(), {
|
||||
await assert.rejects(async () => Blob.prototype.arrayBuffer.call(), {
|
||||
code: 'ERR_INVALID_THIS',
|
||||
});
|
||||
assert.rejects(async () => Blob.prototype.text.call(), {
|
||||
await assert.rejects(async () => Blob.prototype.text.call(), {
|
||||
code: 'ERR_INVALID_THIS',
|
||||
});
|
||||
})().then(common.mustCall());
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ subtle.importKey(
|
|||
},
|
||||
false,
|
||||
[ 'encrypt', 'decrypt' ])
|
||||
.then((k) => {
|
||||
.then((k) =>
|
||||
assert.rejects(() => {
|
||||
return subtle.decrypt({
|
||||
name: 'AES-GCM',
|
||||
|
|
@ -25,5 +25,5 @@ subtle.importKey(
|
|||
}, {
|
||||
name: 'OperationError',
|
||||
message: /The provided data is too small/,
|
||||
});
|
||||
});
|
||||
})
|
||||
).then(common.mustCall());
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
'use strict';
|
||||
|
||||
require('../common');
|
||||
const common = require('../common');
|
||||
const fixtures = require('../common/fixtures');
|
||||
const assert = require('assert');
|
||||
const { pathToFileURL } = require('url');
|
||||
|
||||
{
|
||||
assert.rejects(import('./'), /ERR_UNSUPPORTED_DIR_IMPORT/);
|
||||
assert.rejects(import('./'), /ERR_UNSUPPORTED_DIR_IMPORT/).then(common.mustCall());
|
||||
assert.rejects(
|
||||
import(pathToFileURL(fixtures.path('packages', 'main'))),
|
||||
/Did you mean/,
|
||||
);
|
||||
).then(common.mustCall());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -205,4 +205,4 @@ tickValue = 1;
|
|||
|
||||
// Should fail due to stub.
|
||||
assert.rejects(dnsPromises.lookup('example.com'),
|
||||
{ code: 'ENOMEM', hostname: 'example.com' });
|
||||
{ code: 'ENOMEM', hostname: 'example.com' }).then(common.mustCall());
|
||||
|
|
|
|||
|
|
@ -16,4 +16,4 @@ dnsPromises.lookupService('127.0.0.1', 22).then(common.mustCall((result) => {
|
|||
assert.rejects(
|
||||
() => dnsPromises.lookupService('192.0.2.1', 22),
|
||||
{ code: /^(?:ENOTFOUND|EAI_AGAIN)$/ }
|
||||
);
|
||||
).then(common.mustCall());
|
||||
|
|
|
|||
|
|
@ -32,4 +32,4 @@ assert.rejects(
|
|||
message: 'getnameinfo ENOENT 127.0.0.1',
|
||||
syscall: 'getnameinfo'
|
||||
}
|
||||
);
|
||||
).then(common.mustCall());
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Flags: --expose-internals
|
||||
'use strict';
|
||||
require('../common');
|
||||
const common = require('../common');
|
||||
const assert = require('assert');
|
||||
const { internalBinding } = require('internal/test/binding');
|
||||
const cares = internalBinding('cares_wrap');
|
||||
|
|
@ -17,4 +17,4 @@ assert.rejects(
|
|||
syscall: 'queryA',
|
||||
hostname: 'example.org'
|
||||
}
|
||||
);
|
||||
).then(common.mustCall());
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ EE.emit('error', theErr);
|
|||
|
||||
// Verify it works with once
|
||||
process.nextTick(() => EE.emit('error', theErr));
|
||||
assert.rejects(EventEmitter.once(EE, 'notTriggered'), theErr);
|
||||
assert.rejects(EventEmitter.once(EE, 'notTriggered'), theErr).then(common.mustCall());
|
||||
|
||||
// Only error events trigger error monitor
|
||||
EE.on('aEvent', common.mustCall());
|
||||
|
|
|
|||
|
|
@ -33,8 +33,8 @@ assert.throws(() => openSync(__filename, 0, invalid), {
|
|||
|
||||
assert.rejects(openPromise(__filename, invalid), {
|
||||
code: 'ERR_OUT_OF_RANGE'
|
||||
});
|
||||
}).then(common.mustCall());
|
||||
|
||||
assert.rejects(openPromise(__filename, 0, invalid), {
|
||||
code: 'ERR_OUT_OF_RANGE'
|
||||
});
|
||||
}).then(common.mustCall());
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ const fs = require('fs');
|
|||
const fh = await fs.promises.open(__filename);
|
||||
fs.closeSync(fh.fd);
|
||||
|
||||
assert.rejects(() => fh.close(), {
|
||||
await assert.rejects(() => fh.close(), {
|
||||
code: 'EBADF',
|
||||
syscall: 'close'
|
||||
});
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ const fs = require('fs').promises;
|
|||
// See https://github.com/nodejs/node/issues/31361 for more details.
|
||||
const otherFilehandle = await fs.open(process.execPath);
|
||||
|
||||
assert.rejects(() => filehandle.stat(), {
|
||||
await assert.rejects(() => filehandle.stat(), {
|
||||
code: 'EBADF',
|
||||
syscall: 'fstat'
|
||||
});
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ assert.throws(() => fs.lchmod(f, {}), { code: 'ERR_INVALID_ARG_TYPE' });
|
|||
code: 'ERR_INVALID_ARG_TYPE',
|
||||
};
|
||||
|
||||
assert.rejects(promises.lchmod(f, input, () => {}), errObj);
|
||||
assert.rejects(promises.lchmod(f, input, () => {}), errObj).then(common.mustCall());
|
||||
assert.throws(() => fs.lchmodSync(f, input), errObj);
|
||||
});
|
||||
|
||||
|
|
@ -61,6 +61,6 @@ assert.throws(() => fs.lchmodSync(f, '123x'), {
|
|||
`4294967295. Received ${input}`
|
||||
};
|
||||
|
||||
assert.rejects(promises.lchmod(f, input, () => {}), errObj);
|
||||
assert.rejects(promises.lchmod(f, input, () => {}), errObj).then(common.mustCall());
|
||||
assert.throws(() => fs.lchmodSync(f, input), errObj);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ for (const extra of [[], ['r'], ['r', 0], ['r', 0, 'bad callback']]) {
|
|||
code: 'ERR_INVALID_ARG_TYPE',
|
||||
name: 'TypeError'
|
||||
}
|
||||
);
|
||||
).then(common.mustCall());
|
||||
});
|
||||
|
||||
// Check invalid modes.
|
||||
|
|
@ -116,5 +116,5 @@ for (const extra of [[], ['r'], ['r', 0], ['r', 0, 'bad callback']]) {
|
|||
{
|
||||
code: 'ERR_INVALID_ARG_TYPE'
|
||||
}
|
||||
);
|
||||
).then(common.mustCall());
|
||||
});
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ function validateReadFileAbortLogicBefore() {
|
|||
const signal = AbortSignal.abort();
|
||||
assert.rejects(readFile(fn, { signal }), {
|
||||
name: 'AbortError'
|
||||
});
|
||||
}).then(common.mustCall());
|
||||
}
|
||||
|
||||
function validateReadFileAbortLogicDuring() {
|
||||
|
|
@ -55,7 +55,7 @@ function validateReadFileAbortLogicDuring() {
|
|||
process.nextTick(() => controller.abort());
|
||||
assert.rejects(readFile(fn, { signal }), {
|
||||
name: 'AbortError'
|
||||
});
|
||||
}).then(common.mustCall());
|
||||
}
|
||||
|
||||
async function validateWrongSignalParam() {
|
||||
|
|
|
|||
|
|
@ -79,42 +79,42 @@ assert.rejects(
|
|||
// eslint-disable-next-line no-unused-vars, no-empty
|
||||
for await (const _ of watch(1)) { }
|
||||
},
|
||||
{ code: 'ERR_INVALID_ARG_TYPE' });
|
||||
{ code: 'ERR_INVALID_ARG_TYPE' }).then(common.mustCall());
|
||||
|
||||
assert.rejects(
|
||||
async () => {
|
||||
// eslint-disable-next-line no-unused-vars, no-empty
|
||||
for await (const _ of watch(__filename, 1)) { }
|
||||
},
|
||||
{ code: 'ERR_INVALID_ARG_TYPE' });
|
||||
{ code: 'ERR_INVALID_ARG_TYPE' }).then(common.mustCall());
|
||||
|
||||
assert.rejects(
|
||||
async () => {
|
||||
// eslint-disable-next-line no-unused-vars, no-empty
|
||||
for await (const _ of watch('', { persistent: 1 })) { }
|
||||
},
|
||||
{ code: 'ERR_INVALID_ARG_TYPE' });
|
||||
{ code: 'ERR_INVALID_ARG_TYPE' }).then(common.mustCall());
|
||||
|
||||
assert.rejects(
|
||||
async () => {
|
||||
// eslint-disable-next-line no-unused-vars, no-empty
|
||||
for await (const _ of watch('', { recursive: 1 })) { }
|
||||
},
|
||||
{ code: 'ERR_INVALID_ARG_TYPE' });
|
||||
{ code: 'ERR_INVALID_ARG_TYPE' }).then(common.mustCall());
|
||||
|
||||
assert.rejects(
|
||||
async () => {
|
||||
// eslint-disable-next-line no-unused-vars, no-empty
|
||||
for await (const _ of watch('', { encoding: 1 })) { }
|
||||
},
|
||||
{ code: 'ERR_INVALID_ARG_VALUE' });
|
||||
{ code: 'ERR_INVALID_ARG_VALUE' }).then(common.mustCall());
|
||||
|
||||
assert.rejects(
|
||||
async () => {
|
||||
// eslint-disable-next-line no-unused-vars, no-empty
|
||||
for await (const _ of watch('', { signal: 1 })) { }
|
||||
},
|
||||
{ code: 'ERR_INVALID_ARG_TYPE' });
|
||||
{ code: 'ERR_INVALID_ARG_TYPE' }).then(common.mustCall());
|
||||
|
||||
(async () => {
|
||||
const ac = new AbortController();
|
||||
|
|
|
|||
|
|
@ -59,21 +59,21 @@ assert.strictEqual(
|
|||
name: 'Error',
|
||||
message: /^ENOENT: no such file or directory, access/
|
||||
}
|
||||
);
|
||||
).then(common.mustCall());
|
||||
|
||||
assert.rejects(
|
||||
access(__filename, 8),
|
||||
{
|
||||
code: 'ERR_OUT_OF_RANGE',
|
||||
}
|
||||
);
|
||||
).then(common.mustCall());
|
||||
|
||||
assert.rejects(
|
||||
access(__filename, { [Symbol.toPrimitive]() { return 5; } }),
|
||||
{
|
||||
code: 'ERR_INVALID_ARG_TYPE',
|
||||
}
|
||||
);
|
||||
).then(common.mustCall());
|
||||
}
|
||||
|
||||
function verifyStatObject(stat) {
|
||||
|
|
@ -407,7 +407,7 @@ async function executeOnHandle(dest, func) {
|
|||
const dir = path.join(tmpDir, nextdir(), nextdir());
|
||||
await mkdir(path.dirname(dir));
|
||||
await writeFile(dir, '');
|
||||
assert.rejects(
|
||||
await assert.rejects(
|
||||
mkdir(dir, { recursive: true }),
|
||||
{
|
||||
code: 'EEXIST',
|
||||
|
|
@ -424,7 +424,7 @@ async function executeOnHandle(dest, func) {
|
|||
const dir = path.join(file, nextdir(), nextdir());
|
||||
await mkdir(path.dirname(file));
|
||||
await writeFile(file, '');
|
||||
assert.rejects(
|
||||
await assert.rejects(
|
||||
mkdir(dir, { recursive: true }),
|
||||
{
|
||||
code: 'ENOTDIR',
|
||||
|
|
@ -463,14 +463,14 @@ async function executeOnHandle(dest, func) {
|
|||
code: 'ERR_INVALID_ARG_TYPE',
|
||||
name: 'TypeError'
|
||||
}
|
||||
);
|
||||
).then(common.mustCall());
|
||||
});
|
||||
}
|
||||
|
||||
// `mkdtemp` with invalid numeric prefix
|
||||
{
|
||||
await mkdtemp(path.resolve(tmpDir, 'FOO'));
|
||||
assert.rejects(
|
||||
await assert.rejects(
|
||||
// mkdtemp() expects to get a string prefix.
|
||||
async () => mkdtemp(1),
|
||||
{
|
||||
|
|
|
|||
|
|
@ -37,5 +37,5 @@ assert.throws(
|
|||
message: 'The argument \'buffer\' is empty and cannot be written. ' +
|
||||
'Received Uint8Array(0) []'
|
||||
}
|
||||
);
|
||||
).then(common.mustCall());
|
||||
})().then(common.mustCall());
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ const kArrayBuffer =
|
|||
writer.close();
|
||||
}, 10);
|
||||
|
||||
assert.rejects(blob(readable), { code: 'ERR_INVALID_STATE' });
|
||||
assert.rejects(blob(readable), { code: 'ERR_INVALID_STATE' }).then(common.mustCall());
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -132,7 +132,7 @@ const kArrayBuffer =
|
|||
writer.close();
|
||||
}, 10);
|
||||
|
||||
assert.rejects(arrayBuffer(readable), { code: 'ERR_INVALID_STATE' });
|
||||
assert.rejects(arrayBuffer(readable), { code: 'ERR_INVALID_STATE' }).then(common.mustCall());
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -150,7 +150,7 @@ const kArrayBuffer =
|
|||
writer.close();
|
||||
}, 10);
|
||||
|
||||
assert.rejects(text(readable), { code: 'ERR_INVALID_STATE' });
|
||||
assert.rejects(text(readable), { code: 'ERR_INVALID_STATE' }).then(common.mustCall());
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -168,7 +168,7 @@ const kArrayBuffer =
|
|||
writer.close();
|
||||
}, 10);
|
||||
|
||||
assert.rejects(json(readable), { code: 'ERR_INVALID_STATE' });
|
||||
assert.rejects(json(readable), { code: 'ERR_INVALID_STATE' }).then(common.mustCall());
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -227,7 +227,7 @@ const kArrayBuffer =
|
|||
|
||||
assert.rejects(text(stream), {
|
||||
code: 'ERR_INVALID_ARG_TYPE',
|
||||
});
|
||||
}).then(common.mustCall());
|
||||
|
||||
stream.write({});
|
||||
stream.end({});
|
||||
|
|
@ -241,7 +241,7 @@ const kArrayBuffer =
|
|||
|
||||
assert.rejects(json(stream), {
|
||||
code: 'ERR_INVALID_ARG_TYPE',
|
||||
});
|
||||
}).then(common.mustCall());
|
||||
|
||||
stream.write({});
|
||||
stream.end({});
|
||||
|
|
|
|||
|
|
@ -318,7 +318,7 @@ const assert = require('assert');
|
|||
assert.rejects((async () => {
|
||||
// eslint-disable-next-line no-unused-vars, no-empty
|
||||
for await (const chunk of read) { }
|
||||
})(), /AbortError/);
|
||||
})(), /AbortError/).then(common.mustCall());
|
||||
setTimeout(() => controller.abort(), 0);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -119,10 +119,10 @@ function sum(p, c) {
|
|||
|
||||
{
|
||||
// Error cases
|
||||
assert.rejects(() => Readable.from([]).reduce(1), /TypeError/);
|
||||
assert.rejects(() => Readable.from([]).reduce('5'), /TypeError/);
|
||||
assert.rejects(() => Readable.from([]).reduce((x, y) => x + y, 0, 1), /ERR_INVALID_ARG_TYPE/);
|
||||
assert.rejects(() => Readable.from([]).reduce((x, y) => x + y, 0, { signal: true }), /ERR_INVALID_ARG_TYPE/);
|
||||
assert.rejects(() => Readable.from([]).reduce(1), /TypeError/).then(common.mustCall());
|
||||
assert.rejects(() => Readable.from([]).reduce('5'), /TypeError/).then(common.mustCall());
|
||||
assert.rejects(() => Readable.from([]).reduce((x, y) => x + y, 0, 1), /ERR_INVALID_ARG_TYPE/).then(common.mustCall());
|
||||
assert.rejects(() => Readable.from([]).reduce((x, y) => x + y, 0, { signal: true }), /ERR_INVALID_ARG_TYPE/).then(common.mustCall());
|
||||
}
|
||||
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
// Flags: --experimental-vm-modules
|
||||
|
||||
require('../common');
|
||||
const common = require('../common');
|
||||
|
||||
const assert = require('assert');
|
||||
const { SourceTextModule } = require('vm');
|
||||
|
|
@ -27,4 +27,4 @@ assert.rejects(async () => {
|
|||
m.createCachedData();
|
||||
}, {
|
||||
code: 'ERR_VM_MODULE_CANNOT_CREATE_CACHED_DATA',
|
||||
});
|
||||
}).then(common.mustCall());
|
||||
|
|
|
|||
|
|
@ -39,4 +39,4 @@ assert.rejects(async () => {
|
|||
}, {
|
||||
code: 'ERR_SCRIPT_EXECUTION_TIMEOUT',
|
||||
message: 'Script execution timed out after 5ms'
|
||||
});
|
||||
}).then(common.mustCall());
|
||||
|
|
|
|||
|
|
@ -366,11 +366,11 @@ async function testImportRaw({ name, publicUsages }) {
|
|||
'spki',
|
||||
rsaPublic.export({ format: 'der', type: 'spki' }),
|
||||
{ name },
|
||||
true, publicUsages), { message: /Invalid key type/ });
|
||||
true, publicUsages), { message: /Invalid key type/ }).then(common.mustCall());
|
||||
assert.rejects(subtle.importKey(
|
||||
'pkcs8',
|
||||
rsaPrivate.export({ format: 'der', type: 'pkcs8' }),
|
||||
{ name },
|
||||
true, privateUsages), { message: /Invalid key type/ });
|
||||
true, privateUsages), { message: /Invalid key type/ }).then(common.mustCall());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -565,11 +565,11 @@ const testVectors = [
|
|||
'spki',
|
||||
ecPublic.export({ format: 'der', type: 'spki' }),
|
||||
{ name, hash: 'SHA-256' },
|
||||
true, [publicUsage]), { message: /Invalid key type/ });
|
||||
true, [publicUsage]), { message: /Invalid key type/ }).then(common.mustCall());
|
||||
assert.rejects(subtle.importKey(
|
||||
'pkcs8',
|
||||
ecPrivate.export({ format: 'der', type: 'pkcs8' }),
|
||||
{ name, hash: 'SHA-256' },
|
||||
true, [privateUsage]), { message: /Invalid key type/ });
|
||||
true, [privateUsage]), { message: /Invalid key type/ }).then(common.mustCall());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// Flags: --expose-internals
|
||||
'use strict';
|
||||
|
||||
require('../common');
|
||||
const common = require('../common');
|
||||
const assert = require('node:assert');
|
||||
const { AbortError } = require('internal/errors');
|
||||
|
||||
|
|
@ -20,5 +20,5 @@ for (const message of [undefined, 'abc']) {
|
|||
assert.strictEqual(e.name, 'AbortError');
|
||||
assert.strictEqual(e.message, reason.message);
|
||||
return true;
|
||||
});
|
||||
}).then(common.mustCall());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -184,7 +184,7 @@ class Source {
|
|||
throw error;
|
||||
}
|
||||
|
||||
assert.rejects(read(stream), error);
|
||||
assert.rejects(read(stream), error).then(common.mustCall());
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -212,10 +212,10 @@ class Source {
|
|||
reader.releaseLock();
|
||||
assert.rejects(reader.read(new Uint8Array(10)), {
|
||||
code: 'ERR_INVALID_STATE',
|
||||
});
|
||||
}).then(common.mustCall());
|
||||
assert.rejects(reader.cancel(), {
|
||||
code: 'ERR_INVALID_STATE',
|
||||
});
|
||||
}).then(common.mustCall());
|
||||
}
|
||||
|
||||
{
|
||||
|
|
|
|||
|
|
@ -355,11 +355,11 @@ assert.throws(() => {
|
|||
|
||||
assert.rejects(reader.read(), {
|
||||
code: 'ERR_INVALID_STATE',
|
||||
});
|
||||
}).then(common.mustCall());
|
||||
|
||||
assert.rejects(closedBefore, {
|
||||
code: 'ERR_INVALID_STATE',
|
||||
});
|
||||
}).then(common.mustCall());
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -391,7 +391,7 @@ assert.throws(() => {
|
|||
|
||||
assert.rejects(stream.cancel(), {
|
||||
code: 'ERR_INVALID_STATE',
|
||||
});
|
||||
}).then(common.mustCall());
|
||||
|
||||
reader.cancel();
|
||||
|
||||
|
|
@ -483,7 +483,7 @@ assert.throws(() => {
|
|||
closedBefore.then(common.mustCall());
|
||||
assert.rejects(closedAfter, {
|
||||
code: 'ERR_INVALID_STATE',
|
||||
});
|
||||
}).then(common.mustCall());
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -505,7 +505,7 @@ assert.throws(() => {
|
|||
closedBefore.then(common.mustCall());
|
||||
assert.rejects(closedAfter, {
|
||||
code: 'ERR_INVALID_STATE',
|
||||
});
|
||||
}).then(common.mustCall());
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -579,9 +579,9 @@ assert.throws(() => {
|
|||
});
|
||||
stream.getReader().releaseLock();
|
||||
const reader = stream.getReader();
|
||||
assert.rejects(reader.closed, error);
|
||||
assert.rejects(reader.read(), error);
|
||||
assert.rejects(reader.read(), error);
|
||||
assert.rejects(reader.closed, error).then(common.mustCall());
|
||||
assert.rejects(reader.read(), error).then(common.mustCall());
|
||||
assert.rejects(reader.read(), error).then(common.mustCall());
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -595,8 +595,8 @@ assert.throws(() => {
|
|||
const cancel1 = reader.cancel();
|
||||
const cancel2 = reader.cancel();
|
||||
assert.notStrictEqual(cancel1, cancel2);
|
||||
assert.rejects(cancel1, error);
|
||||
assert.rejects(cancel2, error);
|
||||
assert.rejects(cancel1, error).then(common.mustCall());
|
||||
assert.rejects(cancel2, error).then(common.mustCall());
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -608,9 +608,9 @@ assert.throws(() => {
|
|||
});
|
||||
stream.getReader().releaseLock();
|
||||
const reader = stream.getReader();
|
||||
assert.rejects(reader.closed, error);
|
||||
assert.rejects(reader.read(), error);
|
||||
assert.rejects(reader.read(), error);
|
||||
assert.rejects(reader.closed, error).then(common.mustCall());
|
||||
assert.rejects(reader.read(), error).then(common.mustCall());
|
||||
assert.rejects(reader.read(), error).then(common.mustCall());
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -717,8 +717,10 @@ assert.throws(() => {
|
|||
|
||||
assert.notStrictEqual(closed1, closed2);
|
||||
|
||||
assert.rejects(closed1, error);
|
||||
assert.rejects(closed2, error);
|
||||
assert.rejects(closed1, error).then(common.mustCall());
|
||||
assert.rejects(closed2, error).then(common.mustCall());
|
||||
|
||||
reader1.read();
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -796,8 +798,8 @@ assert.throws(() => {
|
|||
|
||||
const { 0: s1, 1: s2 } = stream.tee();
|
||||
|
||||
assert.rejects(s1.cancel(), error);
|
||||
assert.rejects(s2.cancel(), error);
|
||||
assert.rejects(s1.cancel(), error).then(common.mustCall());
|
||||
assert.rejects(s2.cancel(), error).then(common.mustCall());
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -812,8 +814,8 @@ assert.throws(() => {
|
|||
const { 0: s1, 1: s2 } = stream.tee();
|
||||
c.error(error);
|
||||
|
||||
assert.rejects(s1.cancel(), error);
|
||||
assert.rejects(s2.cancel(), error);
|
||||
assert.rejects(s1.cancel(), error).then(common.mustCall());
|
||||
assert.rejects(s2.cancel(), error).then(common.mustCall());
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -830,11 +832,11 @@ assert.throws(() => {
|
|||
const reader1 = s1.getReader();
|
||||
const reader2 = s2.getReader();
|
||||
|
||||
assert.rejects(reader1.closed, error);
|
||||
assert.rejects(reader2.closed, error);
|
||||
assert.rejects(reader1.closed, error).then(common.mustCall());
|
||||
assert.rejects(reader2.closed, error).then(common.mustCall());
|
||||
|
||||
assert.rejects(reader1.read(), error);
|
||||
assert.rejects(reader2.read(), error);
|
||||
assert.rejects(reader1.read(), error).then(common.mustCall());
|
||||
assert.rejects(reader2.read(), error).then(common.mustCall());
|
||||
|
||||
setImmediate(() => c.error(error));
|
||||
}
|
||||
|
|
@ -1038,7 +1040,7 @@ assert.throws(() => {
|
|||
|
||||
const reader = stream.getReader();
|
||||
|
||||
assert.rejects(reader.closed, error);
|
||||
assert.rejects(reader.closed, error).then(common.mustCall());
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -1053,7 +1055,7 @@ assert.throws(() => {
|
|||
|
||||
const reader = stream.getReader();
|
||||
|
||||
assert.rejects(reader.closed, error);
|
||||
assert.rejects(reader.closed, error).then(common.mustCall());
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -1357,7 +1359,7 @@ class Source {
|
|||
});
|
||||
assert.rejects(() => ReadableStream.prototype.cancel.call({}), {
|
||||
code: 'ERR_INVALID_THIS',
|
||||
});
|
||||
}).then(common.mustCall());
|
||||
assert.throws(() => ReadableStream.prototype.getReader.call({}), {
|
||||
code: 'ERR_INVALID_THIS',
|
||||
});
|
||||
|
|
@ -1372,15 +1374,15 @@ class Source {
|
|||
});
|
||||
assert.rejects(() => ReadableStreamDefaultReader.prototype.read.call({}), {
|
||||
code: 'ERR_INVALID_THIS',
|
||||
});
|
||||
}).then(common.mustCall());
|
||||
assert.rejects(() => ReadableStreamDefaultReader.prototype.cancel.call({}), {
|
||||
code: 'ERR_INVALID_THIS',
|
||||
});
|
||||
}).then(common.mustCall());
|
||||
assert.rejects(() => {
|
||||
return Reflect.get(ReadableStreamDefaultReader.prototype, 'closed');
|
||||
}, {
|
||||
code: 'ERR_INVALID_THIS',
|
||||
});
|
||||
}).then(common.mustCall());
|
||||
assert.throws(() => {
|
||||
ReadableStreamDefaultReader.prototype.releaseLock.call({});
|
||||
}, {
|
||||
|
|
@ -1388,7 +1390,7 @@ class Source {
|
|||
});
|
||||
assert.rejects(() => ReadableStreamBYOBReader.prototype.read.call({}), {
|
||||
code: 'ERR_INVALID_THIS',
|
||||
});
|
||||
}).then(common.mustCall());
|
||||
assert.throws(() => {
|
||||
ReadableStreamBYOBReader.prototype.releaseLock.call({});
|
||||
}, {
|
||||
|
|
@ -1398,10 +1400,10 @@ class Source {
|
|||
return Reflect.get(ReadableStreamBYOBReader.prototype, 'closed');
|
||||
}, {
|
||||
code: 'ERR_INVALID_THIS',
|
||||
});
|
||||
}).then(common.mustCall());
|
||||
assert.rejects(() => ReadableStreamBYOBReader.prototype.cancel.call({}), {
|
||||
code: 'ERR_INVALID_THIS',
|
||||
});
|
||||
}).then(common.mustCall());
|
||||
|
||||
assert.throws(() => {
|
||||
Reflect.get(ReadableByteStreamController.prototype, 'byobRequest', {});
|
||||
|
|
@ -1484,11 +1486,11 @@ class Source {
|
|||
|
||||
assert.rejects(readableStreamPipeTo(1), {
|
||||
code: 'ERR_INVALID_ARG_TYPE',
|
||||
});
|
||||
}).then(common.mustCall());
|
||||
|
||||
assert.rejects(readableStreamPipeTo(new ReadableStream(), 1), {
|
||||
code: 'ERR_INVALID_ARG_TYPE',
|
||||
});
|
||||
}).then(common.mustCall());
|
||||
|
||||
assert.rejects(
|
||||
readableStreamPipeTo(
|
||||
|
|
@ -1500,7 +1502,7 @@ class Source {
|
|||
{}),
|
||||
{
|
||||
code: 'ERR_INVALID_ARG_TYPE',
|
||||
});
|
||||
}).then(common.mustCall());
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -1510,10 +1512,10 @@ class Source {
|
|||
reader.releaseLock();
|
||||
assert.rejects(reader.read(), {
|
||||
code: 'ERR_INVALID_STATE',
|
||||
});
|
||||
}).then(common.mustCall());
|
||||
assert.rejects(reader.cancel(), {
|
||||
code: 'ERR_INVALID_STATE',
|
||||
});
|
||||
}).then(common.mustCall());
|
||||
}
|
||||
|
||||
{
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ const {
|
|||
|
||||
assert.rejects(reader.closed, {
|
||||
code: 'ABORT_ERR',
|
||||
});
|
||||
}).then(common.mustCall());
|
||||
|
||||
readable.on('end', common.mustNotCall());
|
||||
readable.on('error', common.mustNotCall());
|
||||
|
|
@ -116,7 +116,7 @@ const {
|
|||
|
||||
const reader = readableStream.getReader();
|
||||
|
||||
assert.rejects(reader.closed, error);
|
||||
assert.rejects(reader.closed, error).then(common.mustCall());
|
||||
|
||||
readable.on('end', common.mustNotCall());
|
||||
readable.on('error', common.mustCall((reason) => {
|
||||
|
|
|
|||
|
|
@ -28,11 +28,11 @@ const {
|
|||
|
||||
assert.rejects(reader.closed, {
|
||||
code: 'ABORT_ERR',
|
||||
});
|
||||
}).then(common.mustCall());
|
||||
|
||||
assert.rejects(writer.closed, {
|
||||
code: 'ABORT_ERR',
|
||||
});
|
||||
}).then(common.mustCall());
|
||||
|
||||
duplex.destroy();
|
||||
|
||||
|
|
@ -58,8 +58,8 @@ const {
|
|||
const reader = readable.getReader();
|
||||
const writer = writable.getWriter();
|
||||
|
||||
assert.rejects(reader.closed, error);
|
||||
assert.rejects(writer.closed, error);
|
||||
assert.rejects(reader.closed, error).then(common.mustCall());
|
||||
assert.rejects(writer.closed, error).then(common.mustCall());
|
||||
|
||||
duplex.destroy(error);
|
||||
}
|
||||
|
|
@ -81,7 +81,7 @@ const {
|
|||
const writer = writable.getWriter();
|
||||
|
||||
reader.closed.then(common.mustCall());
|
||||
assert.rejects(writer.closed, error);
|
||||
assert.rejects(writer.closed, error).then(common.mustCall());
|
||||
|
||||
reader.cancel(error).then(common.mustCall());
|
||||
}
|
||||
|
|
@ -121,8 +121,8 @@ const {
|
|||
const reader = readable.getReader();
|
||||
const writer = writable.getWriter();
|
||||
|
||||
assert.rejects(reader.closed, error);
|
||||
assert.rejects(writer.closed, error);
|
||||
assert.rejects(reader.closed, error).then(common.mustCall());
|
||||
assert.rejects(writer.closed, error).then(common.mustCall());
|
||||
|
||||
writer.abort(error).then(common.mustCall());
|
||||
}
|
||||
|
|
@ -145,7 +145,7 @@ const {
|
|||
|
||||
assert.rejects(writer.closed, {
|
||||
code: 'ABORT_ERR',
|
||||
});
|
||||
}).then(common.mustCall());
|
||||
|
||||
reader.cancel();
|
||||
}
|
||||
|
|
@ -166,7 +166,7 @@ const {
|
|||
reader.closed.then(common.mustCall());
|
||||
assert.rejects(writer.closed, {
|
||||
code: 'ABORT_ERR',
|
||||
});
|
||||
}).then(common.mustCall());
|
||||
|
||||
duplex.end();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,10 +56,10 @@ class MySource {
|
|||
|
||||
assert.rejects(readableStream.cancel(), {
|
||||
code: 'ERR_INVALID_STATE',
|
||||
});
|
||||
}).then(common.mustCall());
|
||||
assert.rejects(readableStream.pipeTo(new WritableStream()), {
|
||||
code: 'ERR_INVALID_STATE',
|
||||
});
|
||||
}).then(common.mustCall());
|
||||
assert.throws(() => readableStream.tee(), {
|
||||
code: 'ERR_INVALID_STATE',
|
||||
});
|
||||
|
|
|
|||
|
|
@ -125,11 +125,11 @@ class TestSource {
|
|||
|
||||
assert.rejects(writableStream.close(), {
|
||||
code: 'ERR_INVALID_STATE',
|
||||
});
|
||||
}).then(common.mustCall());
|
||||
|
||||
assert.rejects(writableStream.abort(), {
|
||||
code: 'ERR_INVALID_STATE',
|
||||
});
|
||||
}).then(common.mustCall());
|
||||
|
||||
assert.throws(() => writableStream.getWriter(), {
|
||||
code: 'ERR_INVALID_STATE',
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ class TestWritable extends Writable {
|
|||
const writable = new TestWritable();
|
||||
|
||||
const writableStream = newWritableStreamFromStreamWritable(writable);
|
||||
assert.rejects(writableStream.close(), error);
|
||||
assert.rejects(writableStream.close(), error).then(common.mustCall());
|
||||
writable.destroy(error);
|
||||
}
|
||||
|
||||
|
|
@ -93,7 +93,7 @@ class TestWritable extends Writable {
|
|||
|
||||
assert.rejects(writableStream.close(), {
|
||||
code: 'ABORT_ERR'
|
||||
});
|
||||
}).then(common.mustCall());
|
||||
|
||||
writable.end();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -326,7 +326,7 @@ const theData = 'hello';
|
|||
assert.rejects(reader.read(), {
|
||||
code: 25,
|
||||
name: 'DataCloneError',
|
||||
});
|
||||
}).then(common.mustCall());
|
||||
port1.close();
|
||||
};
|
||||
|
||||
|
|
@ -377,7 +377,7 @@ const theData = 'hello';
|
|||
assert.rejects(writer.closed, {
|
||||
code: 25,
|
||||
name: 'DataCloneError',
|
||||
});
|
||||
}).then(common.mustCall());
|
||||
|
||||
writer.write(notActuallyTransferable).then(common.mustCall());
|
||||
|
||||
|
|
@ -407,7 +407,7 @@ const theData = 'hello';
|
|||
port1.onmessage = common.mustCall(({ data }) => {
|
||||
const writer = data.getWriter();
|
||||
|
||||
assert.rejects(writer.closed, error);
|
||||
assert.rejects(writer.closed, error).then(common.mustCall());
|
||||
|
||||
writer.abort(error).then(common.mustCall());
|
||||
port1.close();
|
||||
|
|
@ -438,7 +438,7 @@ const theData = 'hello';
|
|||
assert.rejects(writer.abort(m), {
|
||||
code: 25,
|
||||
name: 'DataCloneError',
|
||||
});
|
||||
}).then(common.mustCall());
|
||||
port1.close();
|
||||
});
|
||||
|
||||
|
|
@ -531,7 +531,7 @@ const theData = 'hello';
|
|||
assert.rejects(cancel, {
|
||||
code: 25,
|
||||
name: 'DataCloneError',
|
||||
});
|
||||
}).then(common.mustCall());
|
||||
|
||||
port1.close();
|
||||
});
|
||||
|
|
@ -557,7 +557,7 @@ const theData = 'hello';
|
|||
const m = new WebAssembly.Memory({ initial: 1 });
|
||||
const writer = data.getWriter();
|
||||
const write = writer.write(m);
|
||||
assert.rejects(write, { code: 25, name: 'DataCloneError' });
|
||||
assert.rejects(write, { code: 25, name: 'DataCloneError' }).then(common.mustCall());
|
||||
port1.close();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ class Sink {
|
|||
|
||||
const writer = stream.getWriter();
|
||||
|
||||
assert.rejects(writer.closed, error);
|
||||
assert.rejects(writer.closed, error).then(common.mustCall());
|
||||
|
||||
writer.abort(error).then(common.mustCall(() => {
|
||||
assert.strictEqual(stream[kState].state, 'errored');
|
||||
|
|
@ -163,10 +163,10 @@ class Sink {
|
|||
});
|
||||
assert.rejects(() => WritableStream.prototype.abort({}), {
|
||||
code: 'ERR_INVALID_THIS',
|
||||
});
|
||||
}).then(common.mustCall());
|
||||
assert.rejects(() => WritableStream.prototype.close({}), {
|
||||
code: 'ERR_INVALID_THIS',
|
||||
});
|
||||
}).then(common.mustCall());
|
||||
assert.throws(() => WritableStream.prototype.getWriter.call(), {
|
||||
code: 'ERR_INVALID_THIS',
|
||||
});
|
||||
|
|
@ -176,24 +176,24 @@ class Sink {
|
|||
assert.rejects(
|
||||
Reflect.get(WritableStreamDefaultWriter.prototype, 'closed'), {
|
||||
code: 'ERR_INVALID_THIS',
|
||||
});
|
||||
}).then(common.mustCall());
|
||||
assert.rejects(
|
||||
Reflect.get(WritableStreamDefaultWriter.prototype, 'ready'), {
|
||||
code: 'ERR_INVALID_THIS',
|
||||
});
|
||||
}).then(common.mustCall());
|
||||
assert.throws(
|
||||
() => Reflect.get(WritableStreamDefaultWriter.prototype, 'desiredSize'), {
|
||||
code: 'ERR_INVALID_THIS',
|
||||
});
|
||||
assert.rejects(WritableStreamDefaultWriter.prototype.abort({}), {
|
||||
code: 'ERR_INVALID_THIS',
|
||||
});
|
||||
}).then(common.mustCall());
|
||||
assert.rejects(WritableStreamDefaultWriter.prototype.close({}), {
|
||||
code: 'ERR_INVALID_THIS',
|
||||
});
|
||||
}).then(common.mustCall());
|
||||
assert.rejects(WritableStreamDefaultWriter.prototype.write({}), {
|
||||
code: 'ERR_INVALID_THIS',
|
||||
});
|
||||
}).then(common.mustCall());
|
||||
assert.throws(() => WritableStreamDefaultWriter.prototype.releaseLock({}), {
|
||||
code: 'ERR_INVALID_THIS',
|
||||
});
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ const { once } = require('events');
|
|||
assert.deepStrictEqual(await fh2.readFile(), await fs.readFile(__filename));
|
||||
await fh2.close();
|
||||
|
||||
assert.rejects(() => fh.readFile(), { code: 'EBADF' });
|
||||
await assert.rejects(() => fh.readFile(), { code: 'EBADF' });
|
||||
})().then(common.mustCall());
|
||||
|
||||
(async function() {
|
||||
|
|
|
|||
|
|
@ -39,4 +39,4 @@ assert.rejects(async () => {
|
|||
}, {
|
||||
code: 'ERR_SCRIPT_EXECUTION_TIMEOUT',
|
||||
message: 'Script execution timed out after 10ms'
|
||||
});
|
||||
}).then(common.mustCall());
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
'use strict';
|
||||
require('../common');
|
||||
const common = require('../common');
|
||||
|
||||
if (process.argv[2] === 'wasi-child') {
|
||||
const assert = require('assert');
|
||||
|
|
@ -23,7 +23,7 @@ if (process.argv[2] === 'wasi-child') {
|
|||
name: 'Error',
|
||||
code: 'ERR_WASI_NOT_STARTED',
|
||||
message: 'wasi.start() has not been called',
|
||||
});
|
||||
}).then(common.mustCall());
|
||||
} else {
|
||||
const assert = require('assert');
|
||||
const cp = require('child_process');
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user