test: enable no-empty ESLint rule

PR-URL: https://github.com/nodejs/node/pull/41831
Refs: https://eslint.org/docs/rules/no-empty
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
Rich Trott 2022-02-02 22:35:32 -08:00 committed by Node.js GitHub Bot
parent 73a75c2ee6
commit 5d559f4a74
46 changed files with 206 additions and 132 deletions

View File

@ -5,10 +5,11 @@ env:
es6: true
rules:
multiline-comment-style: ["error", "separate-lines"]
no-empty: error
no-var: error
prefer-const: error
symbol-description: off
multiline-comment-style: ["error", "separate-lines"]
no-restricted-syntax:
# Config copied from .eslintrc.js

View File

@ -16,7 +16,9 @@ try {
const { isMainThread } = require('worker_threads');
if (!isMainThread)
common.skip('Cannot run test in environment with clean-exit policy');
} catch {}
} catch {
// Continue regardless of error.
}
binding.leakHandle();
binding.leakHandle(0);

View File

@ -365,8 +365,7 @@ class NodeInstance extends EventEmitter {
['--expose-internals'],
`${scriptContents}\nprocess._rawDebug('started');`, undefined);
const msg = 'Timed out waiting for process to start';
while (await fires(instance.nextStderrString(), msg, TIMEOUT) !==
'started') {}
while (await fires(instance.nextStderrString(), msg, TIMEOUT) !== 'started');
process._debugProcess(instance._process.pid);
return instance;
}

View File

@ -46,7 +46,9 @@ function validateContent(report, fields = []) {
} catch (err) {
try {
err.stack += util.format('\n------\nFailing Report:\n%O', report);
} catch {}
} catch {
// Continue regardless of error.
}
throw err;
}
}

View File

@ -184,7 +184,9 @@ if (process.argv[2] !== 'child') {
const buf = messages[i++];
if (!buf) {
try { sendSocket.close(); } catch {}
try { sendSocket.close(); } catch {
// Continue regardless of error.
}
return;
}

View File

@ -170,7 +170,9 @@ if (process.argv[2] !== 'child') {
const buf = messages[i++];
if (!buf) {
try { sendSocket.close(); } catch {}
try { sendSocket.close(); } catch {
// Continue regardless of error.
}
return;
}

View File

@ -164,7 +164,9 @@ if (process.argv[2] !== 'child') {
const buf = messages[i++];
if (!buf) {
try { sendSocket.close(); } catch {}
try { sendSocket.close(); } catch {
// Continue regardless of error.
}
return;
}

View File

@ -164,7 +164,9 @@ if (process.argv[2] !== 'child') {
const buf = messages[i++];
if (!buf) {
try { sendSocket.close(); } catch {}
try { sendSocket.close(); } catch {
// Continue regardless of error.
}
return;
}

View File

@ -30,7 +30,9 @@ try {
filename: 'test.vm',
displayErrors: false
});
} catch {}
} catch {
// Continue regardless of error.
}
console.error('middle');

View File

@ -30,7 +30,9 @@ try {
filename: 'test.vm',
displayErrors: false
});
} catch {}
} catch {
// Continue regardless of error.
}
console.error('middle');

View File

@ -8,8 +8,9 @@ const test_fatal = require(`./build/${common.buildType}/test_fatal`);
// that crashes the process.
if (process.argv[2] === 'child') {
test_fatal.TestThread();
// Busy loop to allow the work thread to abort.
while (true) {}
while (true) {
// Busy loop to allow the work thread to abort.
}
}
const p = child_process.spawnSync(

View File

@ -16,7 +16,7 @@ if (common.buildType === 'Debug')
if (process.argv[2] === 'child') {
test_fatal.TestThread();
// Busy loop to allow the work thread to abort.
while (true) {}
while (true);
}
tmpdir.refresh();

View File

@ -5,5 +5,7 @@ const { AsyncResource } = require('async_hooks');
try {
new AsyncResource('foo').runInAsyncScope(() => { throw new Error('bar'); });
} catch {}
} catch {
// Continue regardless of error.
}
// Should abort (fail the case) if async id is not matching.

View File

@ -17,5 +17,5 @@ if (cluster.isPrimary) {
assert.strictEqual(signal, 'SIGTERM');
}));
} else {
while (true) {}
while (true);
}

View File

@ -49,6 +49,7 @@ if (process.argv[2] === 'child') {
try {
throw new Error(domainErrHandlerExMessage);
} catch {
// Continue regardless of error.
}
} else {
throw new Error(domainErrHandlerExMessage);

View File

@ -56,7 +56,9 @@ process.on('exit', function() {
function removeTestFile() {
try {
fs.unlinkSync(filepath);
} catch {}
} catch {
// Continue regardless of error.
}
}

View File

@ -60,6 +60,7 @@ if (!common.isWindows && process.getuid() === 0) {
process.setuid('nobody');
hasWriteAccessForReadonlyFile = false;
} catch {
// Continue regardless of error.
}
}

View File

@ -75,33 +75,45 @@ for (const testCase of kCases) {
}
assert.rejects(
// eslint-disable-next-line no-unused-vars
async () => { for await (const _ of watch(1)) {} },
async () => {
// eslint-disable-next-line no-unused-vars, no-empty
for await (const _ of watch(1)) { }
},
{ code: 'ERR_INVALID_ARG_TYPE' });
assert.rejects(
// eslint-disable-next-line no-unused-vars
async () => { for await (const _ of watch(__filename, 1)) {} },
async () => {
// eslint-disable-next-line no-unused-vars, no-empty
for await (const _ of watch(__filename, 1)) { }
},
{ code: 'ERR_INVALID_ARG_TYPE' });
assert.rejects(
// eslint-disable-next-line no-unused-vars
async () => { for await (const _ of watch('', { persistent: 1 })) {} },
async () => {
// eslint-disable-next-line no-unused-vars, no-empty
for await (const _ of watch('', { persistent: 1 })) { }
},
{ code: 'ERR_INVALID_ARG_TYPE' });
assert.rejects(
// eslint-disable-next-line no-unused-vars
async () => { for await (const _ of watch('', { recursive: 1 })) {} },
async () => {
// eslint-disable-next-line no-unused-vars, no-empty
for await (const _ of watch('', { recursive: 1 })) { }
},
{ code: 'ERR_INVALID_ARG_TYPE' });
assert.rejects(
// eslint-disable-next-line no-unused-vars
async () => { for await (const _ of watch('', { encoding: 1 })) {} },
async () => {
// eslint-disable-next-line no-unused-vars, no-empty
for await (const _ of watch('', { encoding: 1 })) { }
},
{ code: 'ERR_INVALID_ARG_VALUE' });
assert.rejects(
// eslint-disable-next-line no-unused-vars
async () => { for await (const _ of watch('', { signal: 1 })) {} },
async () => {
// eslint-disable-next-line no-unused-vars, no-empty
for await (const _ of watch('', { signal: 1 })) { }
},
{ code: 'ERR_INVALID_ARG_TYPE' });
(async () => {
@ -109,8 +121,8 @@ assert.rejects(
const { signal } = ac;
setImmediate(() => ac.abort());
try {
// eslint-disable-next-line no-unused-vars
for await (const _ of watch(__filename, { signal })) {}
// eslint-disable-next-line no-unused-vars, no-empty
for await (const _ of watch(__filename, { signal })) { }
} catch (err) {
assert.strictEqual(err.name, 'AbortError');
}

View File

@ -108,7 +108,9 @@ function test_simple_relative_symlink(realpath, realpathSync, callback) {
[
[entry, `../${path.basename(tmpDir)}/cycles/root.js`],
].forEach(function(t) {
try { fs.unlinkSync(t[0]); } catch {}
try { fs.unlinkSync(t[0]); } catch {
// Continue regardless of error.
}
console.log('fs.symlinkSync(%j, %j, %j)', t[1], t[0], 'file');
fs.symlinkSync(t[1], t[0], 'file');
unlink.push(t[0]);
@ -134,7 +136,9 @@ function test_simple_absolute_symlink(realpath, realpathSync, callback) {
[
[entry, expected],
].forEach(function(t) {
try { fs.unlinkSync(t[0]); } catch {}
try { fs.unlinkSync(t[0]); } catch {
// Continue regardless of error.
}
console.error('fs.symlinkSync(%j, %j, %j)', t[1], t[0], type);
fs.symlinkSync(t[1], t[0], type);
unlink.push(t[0]);
@ -159,13 +163,17 @@ function test_deep_relative_file_symlink(realpath, realpathSync, callback) {
expected);
const linkPath1 = path.join(targetsAbsDir,
'nested-index', 'one', 'symlink1.js');
try { fs.unlinkSync(linkPath1); } catch {}
try { fs.unlinkSync(linkPath1); } catch {
// Continue regardless of error.
}
fs.symlinkSync(linkData1, linkPath1, 'file');
const linkData2 = '../one/symlink1.js';
const entry = path.join(targetsAbsDir,
'nested-index', 'two', 'symlink1-b.js');
try { fs.unlinkSync(entry); } catch {}
try { fs.unlinkSync(entry); } catch {
// Continue regardless of error.
}
fs.symlinkSync(linkData2, entry, 'file');
unlink.push(linkPath1);
unlink.push(entry);
@ -186,13 +194,17 @@ function test_deep_relative_dir_symlink(realpath, realpathSync, callback) {
const path1b = path.join(targetsAbsDir, 'nested-index', 'one');
const linkPath1b = path.join(path1b, 'symlink1-dir');
const linkData1b = path.relative(path1b, expected);
try { fs.unlinkSync(linkPath1b); } catch {}
try { fs.unlinkSync(linkPath1b); } catch {
// Continue regardless of error.
}
fs.symlinkSync(linkData1b, linkPath1b, 'dir');
const linkData2b = '../one/symlink1-dir';
const entry = path.join(targetsAbsDir,
'nested-index', 'two', 'symlink12-dir');
try { fs.unlinkSync(entry); } catch {}
try { fs.unlinkSync(entry); } catch {
// Continue regardless of error.
}
fs.symlinkSync(linkData2b, entry, 'dir');
unlink.push(linkPath1b);
unlink.push(entry);
@ -216,7 +228,9 @@ function test_cyclic_link_protection(realpath, realpathSync, callback) {
[path.join(tmpDir, '/cycles/realpath-3b'), '../cycles/realpath-3c'],
[path.join(tmpDir, '/cycles/realpath-3c'), '../cycles/realpath-3a'],
].forEach(function(t) {
try { fs.unlinkSync(t[0]); } catch {}
try { fs.unlinkSync(t[0]); } catch {
// Continue regardless of error.
}
fs.symlinkSync(t[1], t[0], 'dir');
unlink.push(t[0]);
});
@ -243,7 +257,9 @@ function test_cyclic_link_overprotection(realpath, realpathSync, callback) {
const link = `${folder}/cycles`;
let testPath = cycles;
testPath += '/folder/cycles'.repeat(10);
try { fs.unlinkSync(link); } catch {}
try { fs.unlinkSync(link); } catch {
// Continue regardless of error.
}
fs.symlinkSync(cycles, link, 'dir');
unlink.push(link);
assertEqualPath(realpathSync(testPath), path.resolve(expected));
@ -271,7 +287,9 @@ function test_relative_input_cwd(realpath, realpathSync, callback) {
].forEach(function(t) {
const fn = t[0];
console.error('fn=%j', fn);
try { fs.unlinkSync(fn); } catch {}
try { fs.unlinkSync(fn); } catch {
// Continue regardless of error.
}
const b = path.basename(t[1]);
const type = (b === 'root.js' ? 'file' : 'dir');
console.log('fs.symlinkSync(%j, %j, %j)', t[1], fn, type);
@ -309,8 +327,12 @@ function test_deep_symlink_mix(realpath, realpathSync, callback) {
// $tmpDir/targets/cycles/root.js (hard)
const entry = tmp('node-test-realpath-f1');
try { fs.unlinkSync(tmp('node-test-realpath-d2/foo')); } catch {}
try { fs.rmdirSync(tmp('node-test-realpath-d2')); } catch {}
try { fs.unlinkSync(tmp('node-test-realpath-d2/foo')); } catch {
// Continue regardless of error.
}
try { fs.rmdirSync(tmp('node-test-realpath-d2')); } catch {
// Continue regardless of error.
}
fs.mkdirSync(tmp('node-test-realpath-d2'), 0o700);
try {
[
@ -325,7 +347,9 @@ function test_deep_symlink_mix(realpath, realpathSync, callback) {
[`${targetsAbsDir}/nested-index/two/realpath-c`,
`${tmpDir}/cycles/root.js`],
].forEach(function(t) {
try { fs.unlinkSync(t[0]); } catch {}
try { fs.unlinkSync(t[0]); } catch {
// Continue regardless of error.
}
fs.symlinkSync(t[1], t[0]);
unlink.push(t[0]);
});
@ -479,14 +503,18 @@ function test_abs_with_kids(realpath, realpathSync, cb) {
['/a/b/c/x.txt',
'/a/link',
].forEach(function(file) {
try { fs.unlinkSync(root + file); } catch {}
try { fs.unlinkSync(root + file); } catch {
// Continue regardless of error.
}
});
['/a/b/c',
'/a/b',
'/a',
'',
].forEach(function(folder) {
try { fs.rmdirSync(root + folder); } catch {}
try { fs.rmdirSync(root + folder); } catch {
// Continue regardless of error.
}
});
}

View File

@ -36,7 +36,9 @@ builtinModules.forEach((moduleName) => {
// This could throw for e.g., crypto if the binary is not compiled
// accordingly.
require(moduleName);
} catch {}
} catch {
// Continue regardless of error.
}
}
});

View File

@ -49,7 +49,7 @@ function write(out) {
let endCb = false;
// First, write until it gets some backpressure
while (out.write(buf, common.mustSucceed())) {}
while (out.write(buf, common.mustSucceed()));
// Now end, and make sure that we don't get the 'finish' event
// before the tick where the cb gets called. We give it until

View File

@ -19,7 +19,7 @@ events.captureRejections = true;
}));
// Write until there is space in the buffer
while (res.write('hello')) {}
while (res.write('hello'));
}));
server.listen(0, common.mustCall(() => {
@ -87,6 +87,6 @@ events.captureRejections = true;
}));
// Write until there is space in the buffer
while (req.write('hello')) {}
while (req.write('hello'));
}));
}

View File

@ -62,5 +62,7 @@ server.on('listening', common.mustCall(async () => {
try {
await once(req, 'end');
} catch {}
} catch {
// Continue regardless of error.
}
}));

View File

@ -69,7 +69,9 @@ function test() {
process.kill(child.pid, 'SIGKILL');
try {
parent.kill();
} catch {}
} catch {
// Continue regardless of error.
}
assert.strictEqual(s, 'hello from child\n');
assert.strictEqual(res.statusCode, 200);

View File

@ -69,7 +69,9 @@ function test() {
process.kill(child.pid, 'SIGKILL');
try {
parent.kill();
} catch {}
} catch {
// Continue regardless of error.
}
assert.strictEqual(s, 'hello from child\n');
assert.strictEqual(res.statusCode, 200);

View File

@ -37,7 +37,7 @@ setTimeout(mustCall(function r() {
return setTimeout(mustCall(r), 5);
const t = Date.now();
while (Date.now() - t < SPIN_DUR) { }
while (Date.now() - t < SPIN_DUR);
const elu2 = eventLoopUtilization(elu1);
const elu3 = eventLoopUtilization();

View File

@ -53,10 +53,18 @@ assert.throws(() => {
// Passing -0 shouldn't crash the process
// Refs: https://github.com/nodejs/node/issues/32750
try { process.setuid(-0); } catch {}
try { process.seteuid(-0); } catch {}
try { process.setgid(-0); } catch {}
try { process.setegid(-0); } catch {}
try { process.setuid(-0); } catch {
// Continue regardless of error.
}
try { process.seteuid(-0); } catch {
// Continue regardless of error.
}
try { process.setgid(-0); } catch {
// Continue regardless of error.
}
try { process.setegid(-0); } catch {
// Continue regardless of error.
}
// If we're not running as super user...
if (process.getuid() !== 0) {

View File

@ -19,7 +19,9 @@ function test(size, useBuffer, cb) {
try {
fs.unlinkSync(tmpFile);
} catch {}
} catch {
// Continue regardless of error.
}
console.log(`${size} chars to ${tmpFile}...`);

View File

@ -16,7 +16,7 @@ process.on('uncaughtException', common.mustCall((err) => {
const s = new PassThrough();
s.end('data');
pipeline(s, async function(source) {
for await (const chunk of source) {} // eslint-disable-line no-unused-vars
for await (const chunk of source) { } // eslint-disable-line no-unused-vars, no-empty
}, common.mustSucceed(() => {
throw new Error('error');
}));

View File

@ -700,7 +700,7 @@ const tsp = require('timers/promises');
await Promise.resolve();
yield 'hello';
}, async function*(source) { // eslint-disable-line require-yield
for await (const chunk of source) {} // eslint-disable-line no-unused-vars
for await (const chunk of source) { } // eslint-disable-line no-unused-vars, no-empty
}, common.mustCall((err) => {
assert.strictEqual(err, undefined);
}));
@ -716,7 +716,7 @@ const tsp = require('timers/promises');
await Promise.resolve();
throw new Error('kaboom');
}, async function*(source) { // eslint-disable-line require-yield
for await (const chunk of source) {} // eslint-disable-line no-unused-vars
for await (const chunk of source) { } // eslint-disable-line no-unused-vars, no-empty
}, common.mustCall((err) => {
assert.strictEqual(err.message, 'kaboom');
}));

View File

@ -243,8 +243,8 @@ async function tests() {
let err;
try {
// eslint-disable-next-line no-unused-vars
for await (const k of readable) {}
// eslint-disable-next-line no-unused-vars, no-empty
for await (const k of readable) { }
} catch (e) {
err = e;
}
@ -461,12 +461,10 @@ async function tests() {
this.push(null);
}
});
// eslint-disable-next-line no-unused-vars
for await (const a of r) {
}
// eslint-disable-next-line no-unused-vars
for await (const b of r) {
}
// eslint-disable-next-line no-unused-vars, no-empty
for await (const a of r) { }
// eslint-disable-next-line no-unused-vars, no-empty
for await (const b of r) { }
}
{
@ -616,7 +614,7 @@ async function tests() {
}
});
for await (const chunk of r) {} // eslint-disable-line no-unused-vars
for await (const chunk of r) { } // eslint-disable-line no-unused-vars, no-empty
assert.strictEqual(r.destroyed, false);
}
@ -649,8 +647,7 @@ async function tests() {
assert.strictEqual(r.destroyed, false);
});
for await (const chunk of r) {} // eslint-disable-line no-unused-vars
for await (const chunk of r) { } // eslint-disable-line no-unused-vars, no-empty
assert.strictEqual(r.destroyed, true);
}
}
@ -812,8 +809,8 @@ async function tests() {
let _err;
try {
// eslint-disable-next-line no-unused-vars
for await (const chunk of res) {}
// eslint-disable-next-line no-unused-vars, no-empty
for await (const chunk of res) { }
} catch (err) {
_err = err;
}

View File

@ -316,8 +316,8 @@ const assert = require('assert');
assert.strictEqual(e.name, 'AbortError');
}));
assert.rejects((async () => {
/* eslint-disable-next-line no-unused-vars */
for await (const chunk of read) {}
// eslint-disable-next-line no-unused-vars, no-empty
for await (const chunk of read) { }
})(), /AbortError/);
setTimeout(() => controller.abort(), 0);
}

View File

@ -41,7 +41,7 @@ const Readable = require('stream').Readable;
assert.strictEqual(state.ended, !state.reading);
// Consume all the data
while (readable.read() !== null) {}
while (readable.read() !== null);
if (expectedReadingMore.length === 0) // Reached end of stream
process.nextTick(common.mustCall(onStreamEnd, 1));

View File

@ -251,8 +251,8 @@ process.on('multipleResolves', common.mustNotCall());
const signal = AbortSignal.abort('boom');
try {
const iterable = timerPromises.setInterval(2, undefined, { signal });
// eslint-disable-next-line no-unused-vars
for await (const _ of iterable) {}
// eslint-disable-next-line no-unused-vars, no-empty
for await (const _ of iterable) { }
assert.fail('should have failed');
} catch (err) {
assert.strictEqual(err.cause, 'boom');

View File

@ -7,8 +7,12 @@ const vm = require('vm');
try {
new vm.Script({ toString() { throw new Error('foo'); } }, {});
} catch {}
} catch {
// Continue regardless of error.
}
try {
new vm.Script('[', {});
} catch {}
} catch {
// Continue regardless of error.
}

View File

@ -232,7 +232,3 @@ class Source {
code: 'ERR_INVALID_STATE',
});
}
{
}

View File

@ -26,5 +26,5 @@ function main() {
// Deactivate colors even if the tty does support colors.
process.env.NODE_DISABLE_COLORS = '1';
process.kill(process.pid, 'SIGINT');
while (true) {}
while (true);
}

View File

@ -196,7 +196,9 @@ function drainQueue() {
const enoentFilepath = path.join(tmpdir.path, 'enoent');
try {
fs.unlinkSync(enoentFilepath);
} catch { }
} catch {
// Continue regardless of error.
}
const { status } = spawnSync(
process.execPath,
['--experimental-policy', enoentFilepath, '-e', ''],
@ -282,8 +284,7 @@ for (const permutation of permutations({
} else if (permutation.depIntegrity === 'missing') {
resources[depPath].integrities = null;
shouldSucceed = false;
} else if (permutation.depIntegrity === 'match') {
} else {
} else if (permutation.depIntegrity !== 'match') {
throw new Error('unreachable');
}
if (parentFormat !== 'commonjs') {
@ -301,8 +302,7 @@ for (const permutation of permutations({
} else if (permutation.parentIntegrity === 'missing') {
resources[parentPath].integrities = null;
shouldSucceed = false;
} else if (permutation.parentIntegrity === 'match') {
} else {
} else if (permutation.parentIntegrity !== 'match') {
throw new Error('unreachable');
}
}
@ -324,8 +324,7 @@ for (const permutation of permutations({
} else if (permutation.packageIntegrity === 'missing') {
packageIntegrities = [];
shouldSucceed = false;
} else if (permutation.packageIntegrity === 'match') {
} else {
} else if (permutation.packageIntegrity !== 'match') {
throw new Error('unreachable');
}
resources['./package.json'] = {

View File

@ -197,7 +197,9 @@ function drainQueue() {
const enoentFilepath = path.join(tmpdir.path, 'enoent');
try {
fs.unlinkSync(enoentFilepath);
} catch { }
} catch {
// Continue regardless of error.
}
const { status } = spawnSync(
process.execPath,
['--experimental-policy', enoentFilepath, '-e', ''],
@ -273,8 +275,7 @@ for (const permutation of permutations({
} else if (permutation.depIntegrity === 'missing') {
resources[depPath].integrities = null;
shouldSucceed = false;
} else if (permutation.depIntegrity === 'match') {
} else {
} else if (permutation.depIntegrity !== 'match') {
throw new Error('unreachable');
}
if (parentFormat !== 'commonjs') {
@ -291,8 +292,7 @@ for (const permutation of permutations({
} else if (permutation.parentIntegrity === 'missing') {
resources[parentPath].integrities = null;
shouldSucceed = false;
} else if (permutation.parentIntegrity === 'match') {
} else {
} else if (permutation.parentIntegrity !== 'match') {
throw new Error('unreachable');
}
@ -312,8 +312,7 @@ for (const permutation of permutations({
} else if (permutation.packageIntegrity === 'missing') {
packageIntegrities = [];
shouldSucceed = false;
} else if (permutation.packageIntegrity === 'match') {
} else {
} else if (permutation.packageIntegrity !== 'match') {
throw new Error('unreachable');
}
resources['./package.json'] = {

View File

@ -197,7 +197,9 @@ function drainQueue() {
const enoentFilepath = path.join(tmpdir.path, 'enoent');
try {
fs.unlinkSync(enoentFilepath);
} catch { }
} catch {
// Continue regardless of error.
}
const { status } = spawnSync(
process.execPath,
['--experimental-policy', enoentFilepath, '-e', ''],
@ -273,8 +275,7 @@ for (const permutation of permutations({
} else if (permutation.depIntegrity === 'missing') {
resources[depPath].integrities = null;
shouldSucceed = false;
} else if (permutation.depIntegrity === 'match') {
} else {
} else if (permutation.depIntegrity !== 'match') {
throw new Error('unreachable');
}
if (parentFormat !== 'commonjs') {
@ -291,8 +292,7 @@ for (const permutation of permutations({
} else if (permutation.parentIntegrity === 'missing') {
resources[parentPath].integrities = null;
shouldSucceed = false;
} else if (permutation.parentIntegrity === 'match') {
} else {
} else if (permutation.parentIntegrity !== 'match') {
throw new Error('unreachable');
}
@ -312,8 +312,7 @@ for (const permutation of permutations({
} else if (permutation.packageIntegrity === 'missing') {
packageIntegrities = [];
shouldSucceed = false;
} else if (permutation.packageIntegrity === 'match') {
} else {
} else if (permutation.packageIntegrity !== 'match') {
throw new Error('unreachable');
}
resources['./package.json'] = {

View File

@ -197,7 +197,9 @@ function drainQueue() {
const enoentFilepath = path.join(tmpdir.path, 'enoent');
try {
fs.unlinkSync(enoentFilepath);
} catch { }
} catch {
// Continue regardless of error.
}
const { status } = spawnSync(
process.execPath,
['--experimental-policy', enoentFilepath, '-e', ''],
@ -269,8 +271,7 @@ for (const permutation of permutations({
} else if (permutation.depIntegrity === 'missing') {
resources[depPath].integrities = null;
shouldSucceed = false;
} else if (permutation.depIntegrity === 'match') {
} else {
} else if (permutation.depIntegrity !== 'match') {
throw new Error('unreachable');
}
if (parentFormat !== 'commonjs') {
@ -287,8 +288,7 @@ for (const permutation of permutations({
} else if (permutation.parentIntegrity === 'missing') {
resources[parentPath].integrities = null;
shouldSucceed = false;
} else if (permutation.parentIntegrity === 'match') {
} else {
} else if (permutation.parentIntegrity !== 'match') {
throw new Error('unreachable');
}

View File

@ -214,7 +214,9 @@ function drainQueue() {
const enoentFilepath = path.join(tmpdir.path, 'enoent');
try {
fs.unlinkSync(enoentFilepath);
} catch { }
} catch {
// Continue regardless of error.
}
const { status } = spawnSync(
process.execPath,
['--experimental-policy', enoentFilepath, '-e', ''],
@ -290,8 +292,7 @@ for (const permutation of permutations({
} else if (permutation.depIntegrity === 'missing') {
resources[depPath].integrities = null;
shouldSucceed = false;
} else if (permutation.depIntegrity === 'match') {
} else {
} else if (permutation.depIntegrity !== 'match') {
throw new Error('unreachable');
}
if (parentFormat !== 'commonjs') {
@ -308,8 +309,7 @@ for (const permutation of permutations({
} else if (permutation.parentIntegrity === 'missing') {
resources[parentPath].integrities = null;
shouldSucceed = false;
} else if (permutation.parentIntegrity === 'match') {
} else {
} else if (permutation.parentIntegrity !== 'match') {
throw new Error('unreachable');
}
@ -335,8 +335,7 @@ for (const permutation of permutations({
} else if (permutation.packageIntegrity === 'missing') {
packageIntegrities = [];
shouldSucceed = false;
} else if (permutation.packageIntegrity === 'match') {
} else {
} else if (permutation.packageIntegrity !== 'match') {
throw new Error('unreachable');
}
resources['./package.json'] = {

View File

@ -214,7 +214,9 @@ function drainQueue() {
const enoentFilepath = path.join(tmpdir.path, 'enoent');
try {
fs.unlinkSync(enoentFilepath);
} catch { }
} catch {
// Continue regardless of error.
}
const { status } = spawnSync(
process.execPath,
['--experimental-policy', enoentFilepath, '-e', ''],
@ -290,8 +292,7 @@ for (const permutation of permutations({
} else if (permutation.depIntegrity === 'missing') {
resources[depPath].integrities = null;
shouldSucceed = false;
} else if (permutation.depIntegrity === 'match') {
} else {
} else if (permutation.depIntegrity !== 'match') {
throw new Error('unreachable');
}
if (parentFormat !== 'commonjs') {
@ -308,8 +309,7 @@ for (const permutation of permutations({
} else if (permutation.parentIntegrity === 'missing') {
resources[parentPath].integrities = null;
shouldSucceed = false;
} else if (permutation.parentIntegrity === 'match') {
} else {
} else if (permutation.parentIntegrity !== 'match') {
throw new Error('unreachable');
}
@ -334,8 +334,7 @@ for (const permutation of permutations({
} else if (permutation.packageIntegrity === 'missing') {
packageIntegrities = [];
shouldSucceed = false;
} else if (permutation.packageIntegrity === 'match') {
} else {
} else if (permutation.packageIntegrity !== 'match') {
throw new Error('unreachable');
}
resources['./package.json'] = {

View File

@ -214,7 +214,9 @@ function drainQueue() {
const enoentFilepath = path.join(tmpdir.path, 'enoent');
try {
fs.unlinkSync(enoentFilepath);
} catch { }
} catch {
// Continue regardless of error.
}
const { status } = spawnSync(
process.execPath,
['--experimental-policy', enoentFilepath, '-e', ''],
@ -286,8 +288,7 @@ for (const permutation of permutations({
} else if (permutation.depIntegrity === 'missing') {
resources[depPath].integrities = null;
shouldSucceed = false;
} else if (permutation.depIntegrity === 'match') {
} else {
} else if (permutation.depIntegrity !== 'match') {
throw new Error('unreachable');
}
if (parentFormat !== 'commonjs') {
@ -304,8 +305,7 @@ for (const permutation of permutations({
} else if (permutation.parentIntegrity === 'missing') {
resources[parentPath].integrities = null;
shouldSucceed = false;
} else if (permutation.parentIntegrity === 'match') {
} else {
} else if (permutation.parentIntegrity !== 'match') {
throw new Error('unreachable');
}

View File

@ -39,6 +39,7 @@ const interval = setInterval(function() {
try {
vm.runInNewContext('throw 1;');
} catch {
// Continue regardless of error.
}
global.gc();

View File

@ -65,7 +65,7 @@ if (process.argv[2] === 'server') {
// Block the event loop for 1 second
const start = (new Date()).getTime();
while ((new Date()).getTime() < start + 1000) {}
while ((new Date()).getTime() < start + 1000);
client.write(alittle);