test: remove unused catch bindings
PR-URL: https://github.com/nodejs/node/pull/24079 Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Wyatt Preul <wpreul@gmail.com>
This commit is contained in:
parent
a7ba5faaf5
commit
a74b4a062f
@ -372,7 +372,7 @@ function canCreateSymLink() {
|
|||||||
try {
|
try {
|
||||||
const output = execSync(`${whoamiPath} /priv`, { timout: 1000 });
|
const output = execSync(`${whoamiPath} /priv`, { timout: 1000 });
|
||||||
return output.includes('SeCreateSymbolicLinkPrivilege');
|
return output.includes('SeCreateSymbolicLinkPrivilege');
|
||||||
} catch (e) {
|
} catch {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -456,7 +456,7 @@ function isAlive(pid) {
|
|||||||
try {
|
try {
|
||||||
process.kill(pid, 'SIGCONT');
|
process.kill(pid, 'SIGCONT');
|
||||||
return true;
|
return true;
|
||||||
} catch (e) {
|
} catch {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -665,7 +665,7 @@ function getTTYfd() {
|
|||||||
if (ttyFd === undefined) {
|
if (ttyFd === undefined) {
|
||||||
try {
|
try {
|
||||||
return fs.openSync('/dev/tty');
|
return fs.openSync('/dev/tty');
|
||||||
} catch (e) {
|
} catch {
|
||||||
// There aren't any tty fd's available to use.
|
// There aren't any tty fd's available to use.
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -679,7 +679,7 @@ function runWithInvalidFD(func) {
|
|||||||
// be an valid one.
|
// be an valid one.
|
||||||
try {
|
try {
|
||||||
while (fs.fstatSync(fd--) && fd > 0);
|
while (fs.fstatSync(fd--) && fd > 0);
|
||||||
} catch (e) {
|
} catch {
|
||||||
return func(fd);
|
return func(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ const common = require('../common');
|
|||||||
// The doctool currently uses js-yaml from the tool/node_modules/eslint/ tree.
|
// The doctool currently uses js-yaml from the tool/node_modules/eslint/ tree.
|
||||||
try {
|
try {
|
||||||
require('../../tools/node_modules/eslint/node_modules/js-yaml');
|
require('../../tools/node_modules/eslint/node_modules/js-yaml');
|
||||||
} catch (e) {
|
} catch {
|
||||||
common.skip('missing js-yaml (eslint not present)');
|
common.skip('missing js-yaml (eslint not present)');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ const common = require('../common');
|
|||||||
// The doctool currently uses js-yaml from the tool/node_modules/eslint/ tree.
|
// The doctool currently uses js-yaml from the tool/node_modules/eslint/ tree.
|
||||||
try {
|
try {
|
||||||
require('../../tools/node_modules/eslint/node_modules/js-yaml');
|
require('../../tools/node_modules/eslint/node_modules/js-yaml');
|
||||||
} catch (e) {
|
} catch {
|
||||||
common.skip('missing js-yaml (eslint not present)');
|
common.skip('missing js-yaml (eslint not present)');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
test/fixtures/catch-stdout-error.js
vendored
2
test/fixtures/catch-stdout-error.js
vendored
@ -22,7 +22,7 @@
|
|||||||
function write() {
|
function write() {
|
||||||
try {
|
try {
|
||||||
process.stdout.write('Hello, world\n');
|
process.stdout.write('Hello, world\n');
|
||||||
} catch (ex) {
|
} catch {
|
||||||
throw new Error('this should never happen');
|
throw new Error('this should never happen');
|
||||||
}
|
}
|
||||||
setImmediate(function() {
|
setImmediate(function() {
|
||||||
|
@ -182,7 +182,7 @@ if (process.argv[2] !== 'child') {
|
|||||||
const buf = messages[i++];
|
const buf = messages[i++];
|
||||||
|
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
try { sendSocket.close(); } catch (e) {}
|
try { sendSocket.close(); } catch {}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ if (process.argv[2] !== 'child') {
|
|||||||
const buf = messages[i++];
|
const buf = messages[i++];
|
||||||
|
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
try { sendSocket.close(); } catch (e) {}
|
try { sendSocket.close(); } catch {}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,12 +40,12 @@ tests.forEach((test) => {
|
|||||||
assert.strictEqual(test.pathname, parsed.pathname || '/');
|
assert.strictEqual(test.pathname, parsed.pathname || '/');
|
||||||
assert.strictEqual(test.search, parsed.search || '');
|
assert.strictEqual(test.search, parsed.search || '');
|
||||||
assert.strictEqual(test.hash, parsed.hash || '');
|
assert.strictEqual(test.hash, parsed.hash || '');
|
||||||
} catch (err) {
|
} catch {
|
||||||
// For now, we're just interested in the number of failures.
|
// For now, we're just interested in the number of failures.
|
||||||
failed++;
|
failed++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch {
|
||||||
// If Parse failed and it wasn't supposed to, treat it as a failure.
|
// If Parse failed and it wasn't supposed to, treat it as a failure.
|
||||||
if (!test.failure)
|
if (!test.failure)
|
||||||
failed++;
|
failed++;
|
||||||
|
@ -30,7 +30,7 @@ try {
|
|||||||
filename: 'test.vm',
|
filename: 'test.vm',
|
||||||
displayErrors: false
|
displayErrors: false
|
||||||
});
|
});
|
||||||
} catch (e) {}
|
} catch {}
|
||||||
|
|
||||||
console.error('middle');
|
console.error('middle');
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ try {
|
|||||||
filename: 'test.vm',
|
filename: 'test.vm',
|
||||||
displayErrors: false
|
displayErrors: false
|
||||||
});
|
});
|
||||||
} catch (e) {}
|
} catch {}
|
||||||
|
|
||||||
console.error('middle');
|
console.error('middle');
|
||||||
|
|
||||||
|
@ -168,7 +168,7 @@ assert.throws(
|
|||||||
},
|
},
|
||||||
Array
|
Array
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch {
|
||||||
threw = true;
|
threw = true;
|
||||||
}
|
}
|
||||||
assert.ok(threw, 'wrong constructor validation');
|
assert.ok(threw, 'wrong constructor validation');
|
||||||
|
@ -168,13 +168,13 @@ testCipher2(Buffer.from('0123456789abcdef'));
|
|||||||
// not assert. See https://github.com/nodejs/node-v0.x-archive/issues/4886.
|
// not assert. See https://github.com/nodejs/node-v0.x-archive/issues/4886.
|
||||||
{
|
{
|
||||||
const c = crypto.createCipher('aes-256-cbc', 'secret');
|
const c = crypto.createCipher('aes-256-cbc', 'secret');
|
||||||
try { c.final('xxx'); } catch (e) { /* Ignore. */ }
|
try { c.final('xxx'); } catch { /* Ignore. */ }
|
||||||
try { c.final('xxx'); } catch (e) { /* Ignore. */ }
|
try { c.final('xxx'); } catch { /* Ignore. */ }
|
||||||
try { c.final('xxx'); } catch (e) { /* Ignore. */ }
|
try { c.final('xxx'); } catch { /* Ignore. */ }
|
||||||
const d = crypto.createDecipher('aes-256-cbc', 'secret');
|
const d = crypto.createDecipher('aes-256-cbc', 'secret');
|
||||||
try { d.final('xxx'); } catch (e) { /* Ignore. */ }
|
try { d.final('xxx'); } catch { /* Ignore. */ }
|
||||||
try { d.final('xxx'); } catch (e) { /* Ignore. */ }
|
try { d.final('xxx'); } catch { /* Ignore. */ }
|
||||||
try { d.final('xxx'); } catch (e) { /* Ignore. */ }
|
try { d.final('xxx'); } catch { /* Ignore. */ }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Regression test for https://github.com/nodejs/node-v0.x-archive/issues/5482:
|
// Regression test for https://github.com/nodejs/node-v0.x-archive/issues/5482:
|
||||||
|
@ -56,7 +56,7 @@ process.on('exit', function() {
|
|||||||
function removeTestFile() {
|
function removeTestFile() {
|
||||||
try {
|
try {
|
||||||
fs.unlinkSync(filepath);
|
fs.unlinkSync(filepath);
|
||||||
} catch (e) {}
|
} catch {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ for (const code of [
|
|||||||
if (require('fs').realpathSync('/dev/stdin')) {
|
if (require('fs').realpathSync('/dev/stdin')) {
|
||||||
process.exit(2);
|
process.exit(2);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch {
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}`
|
}`
|
||||||
]) {
|
]) {
|
||||||
|
@ -100,7 +100,7 @@ function test_simple_relative_symlink(realpath, realpathSync, callback) {
|
|||||||
[
|
[
|
||||||
[entry, `../${path.basename(tmpDir)}/cycles/root.js`]
|
[entry, `../${path.basename(tmpDir)}/cycles/root.js`]
|
||||||
].forEach(function(t) {
|
].forEach(function(t) {
|
||||||
try { fs.unlinkSync(t[0]); } catch (e) {}
|
try { fs.unlinkSync(t[0]); } catch {}
|
||||||
console.log('fs.symlinkSync(%j, %j, %j)', t[1], t[0], 'file');
|
console.log('fs.symlinkSync(%j, %j, %j)', t[1], t[0], 'file');
|
||||||
fs.symlinkSync(t[1], t[0], 'file');
|
fs.symlinkSync(t[1], t[0], 'file');
|
||||||
unlink.push(t[0]);
|
unlink.push(t[0]);
|
||||||
@ -126,7 +126,7 @@ function test_simple_absolute_symlink(realpath, realpathSync, callback) {
|
|||||||
[
|
[
|
||||||
[entry, expected]
|
[entry, expected]
|
||||||
].forEach(function(t) {
|
].forEach(function(t) {
|
||||||
try { fs.unlinkSync(t[0]); } catch (e) {}
|
try { fs.unlinkSync(t[0]); } catch {}
|
||||||
console.error('fs.symlinkSync(%j, %j, %j)', t[1], t[0], type);
|
console.error('fs.symlinkSync(%j, %j, %j)', t[1], t[0], type);
|
||||||
fs.symlinkSync(t[1], t[0], type);
|
fs.symlinkSync(t[1], t[0], type);
|
||||||
unlink.push(t[0]);
|
unlink.push(t[0]);
|
||||||
@ -151,13 +151,13 @@ function test_deep_relative_file_symlink(realpath, realpathSync, callback) {
|
|||||||
expected);
|
expected);
|
||||||
const linkPath1 = path.join(targetsAbsDir,
|
const linkPath1 = path.join(targetsAbsDir,
|
||||||
'nested-index', 'one', 'symlink1.js');
|
'nested-index', 'one', 'symlink1.js');
|
||||||
try { fs.unlinkSync(linkPath1); } catch (e) {}
|
try { fs.unlinkSync(linkPath1); } catch {}
|
||||||
fs.symlinkSync(linkData1, linkPath1, 'file');
|
fs.symlinkSync(linkData1, linkPath1, 'file');
|
||||||
|
|
||||||
const linkData2 = '../one/symlink1.js';
|
const linkData2 = '../one/symlink1.js';
|
||||||
const entry = path.join(targetsAbsDir,
|
const entry = path.join(targetsAbsDir,
|
||||||
'nested-index', 'two', 'symlink1-b.js');
|
'nested-index', 'two', 'symlink1-b.js');
|
||||||
try { fs.unlinkSync(entry); } catch (e) {}
|
try { fs.unlinkSync(entry); } catch {}
|
||||||
fs.symlinkSync(linkData2, entry, 'file');
|
fs.symlinkSync(linkData2, entry, 'file');
|
||||||
unlink.push(linkPath1);
|
unlink.push(linkPath1);
|
||||||
unlink.push(entry);
|
unlink.push(entry);
|
||||||
@ -178,13 +178,13 @@ function test_deep_relative_dir_symlink(realpath, realpathSync, callback) {
|
|||||||
const path1b = path.join(targetsAbsDir, 'nested-index', 'one');
|
const path1b = path.join(targetsAbsDir, 'nested-index', 'one');
|
||||||
const linkPath1b = path.join(path1b, 'symlink1-dir');
|
const linkPath1b = path.join(path1b, 'symlink1-dir');
|
||||||
const linkData1b = path.relative(path1b, expected);
|
const linkData1b = path.relative(path1b, expected);
|
||||||
try { fs.unlinkSync(linkPath1b); } catch (e) {}
|
try { fs.unlinkSync(linkPath1b); } catch {}
|
||||||
fs.symlinkSync(linkData1b, linkPath1b, 'dir');
|
fs.symlinkSync(linkData1b, linkPath1b, 'dir');
|
||||||
|
|
||||||
const linkData2b = '../one/symlink1-dir';
|
const linkData2b = '../one/symlink1-dir';
|
||||||
const entry = path.join(targetsAbsDir,
|
const entry = path.join(targetsAbsDir,
|
||||||
'nested-index', 'two', 'symlink12-dir');
|
'nested-index', 'two', 'symlink12-dir');
|
||||||
try { fs.unlinkSync(entry); } catch (e) {}
|
try { fs.unlinkSync(entry); } catch {}
|
||||||
fs.symlinkSync(linkData2b, entry, 'dir');
|
fs.symlinkSync(linkData2b, entry, 'dir');
|
||||||
unlink.push(linkPath1b);
|
unlink.push(linkPath1b);
|
||||||
unlink.push(entry);
|
unlink.push(entry);
|
||||||
@ -208,7 +208,7 @@ function test_cyclic_link_protection(realpath, realpathSync, callback) {
|
|||||||
[path.join(tmpDir, '/cycles/realpath-3b'), '../cycles/realpath-3c'],
|
[path.join(tmpDir, '/cycles/realpath-3b'), '../cycles/realpath-3c'],
|
||||||
[path.join(tmpDir, '/cycles/realpath-3c'), '../cycles/realpath-3a']
|
[path.join(tmpDir, '/cycles/realpath-3c'), '../cycles/realpath-3a']
|
||||||
].forEach(function(t) {
|
].forEach(function(t) {
|
||||||
try { fs.unlinkSync(t[0]); } catch (e) {}
|
try { fs.unlinkSync(t[0]); } catch {}
|
||||||
fs.symlinkSync(t[1], t[0], 'dir');
|
fs.symlinkSync(t[1], t[0], 'dir');
|
||||||
unlink.push(t[0]);
|
unlink.push(t[0]);
|
||||||
});
|
});
|
||||||
@ -235,7 +235,7 @@ function test_cyclic_link_overprotection(realpath, realpathSync, callback) {
|
|||||||
const link = `${folder}/cycles`;
|
const link = `${folder}/cycles`;
|
||||||
let testPath = cycles;
|
let testPath = cycles;
|
||||||
testPath += '/folder/cycles'.repeat(10);
|
testPath += '/folder/cycles'.repeat(10);
|
||||||
try { fs.unlinkSync(link); } catch (ex) {}
|
try { fs.unlinkSync(link); } catch {}
|
||||||
fs.symlinkSync(cycles, link, 'dir');
|
fs.symlinkSync(cycles, link, 'dir');
|
||||||
unlink.push(link);
|
unlink.push(link);
|
||||||
assertEqualPath(realpathSync(testPath), path.resolve(expected));
|
assertEqualPath(realpathSync(testPath), path.resolve(expected));
|
||||||
@ -263,7 +263,7 @@ function test_relative_input_cwd(realpath, realpathSync, callback) {
|
|||||||
].forEach(function(t) {
|
].forEach(function(t) {
|
||||||
const fn = t[0];
|
const fn = t[0];
|
||||||
console.error('fn=%j', fn);
|
console.error('fn=%j', fn);
|
||||||
try { fs.unlinkSync(fn); } catch (e) {}
|
try { fs.unlinkSync(fn); } catch {}
|
||||||
const b = path.basename(t[1]);
|
const b = path.basename(t[1]);
|
||||||
const type = (b === 'root.js' ? 'file' : 'dir');
|
const type = (b === 'root.js' ? 'file' : 'dir');
|
||||||
console.log('fs.symlinkSync(%j, %j, %j)', t[1], fn, type);
|
console.log('fs.symlinkSync(%j, %j, %j)', t[1], fn, type);
|
||||||
@ -302,8 +302,8 @@ function test_deep_symlink_mix(realpath, realpathSync, callback) {
|
|||||||
$tmpDir/targets/cycles/root.js (hard)
|
$tmpDir/targets/cycles/root.js (hard)
|
||||||
*/
|
*/
|
||||||
const entry = tmp('node-test-realpath-f1');
|
const entry = tmp('node-test-realpath-f1');
|
||||||
try { fs.unlinkSync(tmp('node-test-realpath-d2/foo')); } catch (e) {}
|
try { fs.unlinkSync(tmp('node-test-realpath-d2/foo')); } catch {}
|
||||||
try { fs.rmdirSync(tmp('node-test-realpath-d2')); } catch (e) {}
|
try { fs.rmdirSync(tmp('node-test-realpath-d2')); } catch {}
|
||||||
fs.mkdirSync(tmp('node-test-realpath-d2'), 0o700);
|
fs.mkdirSync(tmp('node-test-realpath-d2'), 0o700);
|
||||||
try {
|
try {
|
||||||
[
|
[
|
||||||
@ -318,7 +318,7 @@ function test_deep_symlink_mix(realpath, realpathSync, callback) {
|
|||||||
[`${targetsAbsDir}/nested-index/two/realpath-c`,
|
[`${targetsAbsDir}/nested-index/two/realpath-c`,
|
||||||
`${tmpDir}/cycles/root.js`]
|
`${tmpDir}/cycles/root.js`]
|
||||||
].forEach(function(t) {
|
].forEach(function(t) {
|
||||||
try { fs.unlinkSync(t[0]); } catch (e) {}
|
try { fs.unlinkSync(t[0]); } catch {}
|
||||||
fs.symlinkSync(t[1], t[0]);
|
fs.symlinkSync(t[1], t[0]);
|
||||||
unlink.push(t[0]);
|
unlink.push(t[0]);
|
||||||
});
|
});
|
||||||
@ -429,14 +429,14 @@ function test_abs_with_kids(realpath, realpathSync, cb) {
|
|||||||
['/a/b/c/x.txt',
|
['/a/b/c/x.txt',
|
||||||
'/a/link'
|
'/a/link'
|
||||||
].forEach(function(file) {
|
].forEach(function(file) {
|
||||||
try { fs.unlinkSync(root + file); } catch (ex) {}
|
try { fs.unlinkSync(root + file); } catch {}
|
||||||
});
|
});
|
||||||
['/a/b/c',
|
['/a/b/c',
|
||||||
'/a/b',
|
'/a/b',
|
||||||
'/a',
|
'/a',
|
||||||
''
|
''
|
||||||
].forEach(function(folder) {
|
].forEach(function(folder) {
|
||||||
try { fs.rmdirSync(root + folder); } catch (ex) {}
|
try { fs.rmdirSync(root + folder); } catch {}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function setup() {
|
function setup() {
|
||||||
|
@ -69,7 +69,7 @@ function test() {
|
|||||||
process.kill(child.pid, 'SIGKILL');
|
process.kill(child.pid, 'SIGKILL');
|
||||||
try {
|
try {
|
||||||
parent.kill();
|
parent.kill();
|
||||||
} catch (e) {}
|
} catch {}
|
||||||
|
|
||||||
assert.strictEqual(s, 'hello from child\n');
|
assert.strictEqual(s, 'hello from child\n');
|
||||||
assert.strictEqual(res.statusCode, 200);
|
assert.strictEqual(res.statusCode, 200);
|
||||||
|
@ -69,7 +69,7 @@ function test() {
|
|||||||
process.kill(child.pid, 'SIGKILL');
|
process.kill(child.pid, 'SIGKILL');
|
||||||
try {
|
try {
|
||||||
parent.kill();
|
parent.kill();
|
||||||
} catch (e) {}
|
} catch {}
|
||||||
|
|
||||||
assert.strictEqual(s, 'hello from child\n');
|
assert.strictEqual(s, 'hello from child\n');
|
||||||
assert.strictEqual(res.statusCode, 200);
|
assert.strictEqual(res.statusCode, 200);
|
||||||
|
@ -34,7 +34,7 @@ let invalidFd = 2;
|
|||||||
// Get first known bad file descriptor.
|
// Get first known bad file descriptor.
|
||||||
try {
|
try {
|
||||||
while (fs.fstatSync(++invalidFd));
|
while (fs.fstatSync(++invalidFd));
|
||||||
} catch (e) {
|
} catch {
|
||||||
// do nothing; we now have an invalid fd
|
// do nothing; we now have an invalid fd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ if (common.isWindows) {
|
|||||||
try {
|
try {
|
||||||
// If MUI != 'en' we'll ignore the content of the message
|
// If MUI != 'en' we'll ignore the content of the message
|
||||||
localeOk = execSync(powerShellFindMUI).toString('utf8').trim() === 'en';
|
localeOk = execSync(powerShellFindMUI).toString('utf8').trim() === 'en';
|
||||||
} catch (_) {
|
} catch {
|
||||||
// It's only a best effort try to find the MUI
|
// It's only a best effort try to find the MUI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -681,7 +681,7 @@ asyncTest('Throwing an error inside a rejectionHandled handler goes to' +
|
|||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
try {
|
try {
|
||||||
p.catch(function() {});
|
p.catch(function() {});
|
||||||
} catch (e) {
|
} catch {
|
||||||
done(new Error('fail'));
|
done(new Error('fail'));
|
||||||
}
|
}
|
||||||
}, 1);
|
}, 1);
|
||||||
|
@ -63,7 +63,7 @@ function child() {
|
|||||||
let caught;
|
let caught;
|
||||||
try {
|
try {
|
||||||
vm.runInThisContext('haf!@##&$!@$*!@', { displayErrors: false });
|
vm.runInThisContext('haf!@##&$!@$*!@', { displayErrors: false });
|
||||||
} catch (er) {
|
} catch {
|
||||||
caught = true;
|
caught = true;
|
||||||
}
|
}
|
||||||
assert(caught);
|
assert(caught);
|
||||||
|
@ -34,7 +34,7 @@ common.expectWarning('DeprecationWarning', deprecatedModules.map((m) => {
|
|||||||
for (const m of deprecatedModules) {
|
for (const m of deprecatedModules) {
|
||||||
try {
|
try {
|
||||||
require(m);
|
require(m);
|
||||||
} catch (err) {}
|
} catch {}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Instead of checking require, check that resolve isn't pointing toward a
|
// Instead of checking require, check that resolve isn't pointing toward a
|
||||||
|
@ -27,7 +27,7 @@ child.stderr.on('data', function(c) {
|
|||||||
child.on('close', common.mustCall(function(code) {
|
child.on('close', common.mustCall(function(code) {
|
||||||
try {
|
try {
|
||||||
output = JSON.parse(output);
|
output = JSON.parse(output);
|
||||||
} catch (er) {
|
} catch {
|
||||||
console.error(output);
|
console.error(output);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ function test(size, useBuffer, cb) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
fs.unlinkSync(tmpFile);
|
fs.unlinkSync(tmpFile);
|
||||||
} catch (e) {}
|
} catch {}
|
||||||
|
|
||||||
console.log(`${size} chars to ${tmpFile}...`);
|
console.log(`${size} chars to ${tmpFile}...`);
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ const vm = require('vm');
|
|||||||
function a() {
|
function a() {
|
||||||
try {
|
try {
|
||||||
return a();
|
return a();
|
||||||
} catch (e) {
|
} catch {
|
||||||
// Throw an exception as near to the recursion-based RangeError as possible.
|
// Throw an exception as near to the recursion-based RangeError as possible.
|
||||||
return vm.runInThisContext('() => 42')();
|
return vm.runInThisContext('() => 42')();
|
||||||
}
|
}
|
||||||
@ -17,7 +17,7 @@ assert.strictEqual(a(), 42);
|
|||||||
function b() {
|
function b() {
|
||||||
try {
|
try {
|
||||||
return b();
|
return b();
|
||||||
} catch (e) {
|
} catch {
|
||||||
// This writes a lot of noise to stderr, but it still works.
|
// This writes a lot of noise to stderr, but it still works.
|
||||||
return vm.runInNewContext('() => 42')();
|
return vm.runInNewContext('() => 42')();
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ async function checkModuleState() {
|
|||||||
const m = new SourceTextModule('import "foo";');
|
const m = new SourceTextModule('import "foo";');
|
||||||
try {
|
try {
|
||||||
await m.link(common.mustCall(() => ({})));
|
await m.link(common.mustCall(() => ({})));
|
||||||
} catch (err) {
|
} catch {
|
||||||
assert.strictEqual(m.linkingStatus, 'errored');
|
assert.strictEqual(m.linkingStatus, 'errored');
|
||||||
m.instantiate();
|
m.instantiate();
|
||||||
}
|
}
|
||||||
@ -219,7 +219,7 @@ async function checkLinking() {
|
|||||||
const erroredModule = new SourceTextModule('import "foo";');
|
const erroredModule = new SourceTextModule('import "foo";');
|
||||||
try {
|
try {
|
||||||
await erroredModule.link(common.mustCall(() => ({})));
|
await erroredModule.link(common.mustCall(() => ({})));
|
||||||
} catch (err) {
|
} catch {
|
||||||
// ignored
|
// ignored
|
||||||
} finally {
|
} finally {
|
||||||
assert.strictEqual(erroredModule.linkingStatus, 'errored');
|
assert.strictEqual(erroredModule.linkingStatus, 'errored');
|
||||||
|
@ -7,8 +7,8 @@ const vm = require('vm');
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
new vm.Script({ toString() { throw new Error('foo'); } }, {});
|
new vm.Script({ toString() { throw new Error('foo'); } }, {});
|
||||||
} catch (err) {}
|
} catch {}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
new vm.Script('[', {});
|
new vm.Script('[', {});
|
||||||
} catch (err) {}
|
} catch {}
|
||||||
|
@ -31,13 +31,13 @@ const testsubdir = path.join(testDir, 'testsubdir');
|
|||||||
const filepath = path.join(testsubdir, 'watch.txt');
|
const filepath = path.join(testsubdir, 'watch.txt');
|
||||||
|
|
||||||
function cleanup() {
|
function cleanup() {
|
||||||
try { fs.unlinkSync(filepath); } catch (e) { }
|
try { fs.unlinkSync(filepath); } catch { }
|
||||||
try { fs.rmdirSync(testsubdir); } catch (e) { }
|
try { fs.rmdirSync(testsubdir); } catch { }
|
||||||
}
|
}
|
||||||
process.on('exit', cleanup);
|
process.on('exit', cleanup);
|
||||||
cleanup();
|
cleanup();
|
||||||
|
|
||||||
try { fs.mkdirSync(testsubdir, 0o700); } catch (e) {}
|
try { fs.mkdirSync(testsubdir, 0o700); } catch {}
|
||||||
|
|
||||||
// Need a grace period, else the mkdirSync() above fires off an event.
|
// Need a grace period, else the mkdirSync() above fires off an event.
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
|
@ -37,7 +37,7 @@ assert(ok, 'Run this test with --max_old_space_size=32.');
|
|||||||
const interval = setInterval(function() {
|
const interval = setInterval(function() {
|
||||||
try {
|
try {
|
||||||
vm.runInNewContext('throw 1;');
|
vm.runInNewContext('throw 1;');
|
||||||
} catch (e) {
|
} catch {
|
||||||
}
|
}
|
||||||
|
|
||||||
const rss = process.memoryUsage().rss;
|
const rss = process.memoryUsage().rss;
|
||||||
|
@ -25,7 +25,7 @@ do {
|
|||||||
try {
|
try {
|
||||||
script.runInContext(context, { timeout: 5 });
|
script.runInContext(context, { timeout: 5 });
|
||||||
++sandbox.timeout;
|
++sandbox.timeout;
|
||||||
} catch (err) {
|
} catch {
|
||||||
--sandbox.timeout;
|
--sandbox.timeout;
|
||||||
}
|
}
|
||||||
} while (Date.now() < giveUp);
|
} while (Date.now() < giveUp);
|
||||||
|
@ -50,7 +50,7 @@ stream.on('finish', common.mustCall(function() {
|
|||||||
function destroy() {
|
function destroy() {
|
||||||
try {
|
try {
|
||||||
fs.unlinkSync(file);
|
fs.unlinkSync(file);
|
||||||
} catch (err) {
|
} catch {
|
||||||
// it may not exist
|
// it may not exist
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user