test: increase usage of assert.ifError()
PR-URL: https://github.com/nodejs/node/pull/10543 Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
parent
152bd82de9
commit
746a46ebdd
@ -34,7 +34,7 @@ function onMessage(message, info) {
|
||||
}
|
||||
|
||||
function afterSend(err) {
|
||||
if (err) throw err;
|
||||
assert.ifError(err);
|
||||
packetsSent++;
|
||||
}
|
||||
|
||||
|
2
test/gc/node_modules/nan/tools/1to2.js
generated
vendored
2
test/gc/node_modules/nan/tools/1to2.js
generated
vendored
@ -57,7 +57,7 @@ groups.push([1, ['(', [
|
||||
/* replace TryCatch with NanTryCatch once, gobbling possible namespace, key group 2 */
|
||||
groups.push([2, '(?:(?:v8\\:\\:)?|(Nan)?)(TryCatch)']);
|
||||
|
||||
/* NanNew("string") will likely not fail a ToLocalChecked(), key group 1 */
|
||||
/* NanNew("string") will likely not fail a ToLocalChecked(), key group 1 */
|
||||
groups.push([1, ['(NanNew)', '(\\("[^\\"]*"[^\\)]*\\))(?!\\.ToLocalChecked\\(\\))'].join('')]);
|
||||
|
||||
/* Removed v8 APIs, warn that the code needs rewriting using node::Buffer, key group 2 */
|
||||
|
@ -179,7 +179,7 @@ if (process.argv[2] !== 'child') {
|
||||
common.PORT,
|
||||
LOCAL_BROADCAST_HOST,
|
||||
function(err) {
|
||||
if (err) throw err;
|
||||
assert.ifError(err);
|
||||
console.error('[PARENT] sent %s to %s:%s',
|
||||
util.inspect(buf.toString()),
|
||||
LOCAL_BROADCAST_HOST, common.PORT);
|
||||
|
@ -160,7 +160,7 @@ if (process.argv[2] !== 'child') {
|
||||
common.PORT,
|
||||
LOCAL_BROADCAST_HOST,
|
||||
function(err) {
|
||||
if (err) throw err;
|
||||
assert.ifError(err);
|
||||
console.error('[PARENT] sent "%s" to %s:%s',
|
||||
buf.toString(),
|
||||
LOCAL_BROADCAST_HOST, common.PORT);
|
||||
|
@ -87,7 +87,7 @@ TEST(function test_lookup_ipv6_explicit(done) {
|
||||
/* This ends up just being too problematic to test
|
||||
TEST(function test_lookup_ipv6_implicit(done) {
|
||||
var req = dns.lookup('ipv6.google.com', function(err, ip, family) {
|
||||
if (err) throw err;
|
||||
assert.ifError(err);
|
||||
assert.ok(net.isIPv6(ip));
|
||||
assert.strictEqual(family, 6);
|
||||
|
||||
@ -196,7 +196,7 @@ TEST(function test_lookupservice_ip_ipv6(done) {
|
||||
/* Disabled because it appears to be not working on linux. */
|
||||
/* TEST(function test_lookup_localhost_ipv6(done) {
|
||||
var req = dns.lookup('localhost', 6, function(err, ip, family) {
|
||||
if (err) throw err;
|
||||
assert.ifError(err);
|
||||
assert.ok(net.isIPv6(ip));
|
||||
assert.strictEqual(family, 6);
|
||||
|
||||
|
@ -104,8 +104,7 @@ TEST(function test_resolve6_ttl(done) {
|
||||
|
||||
TEST(function test_resolveMx(done) {
|
||||
var req = dns.resolveMx('gmail.com', function(err, result) {
|
||||
if (err) throw err;
|
||||
|
||||
assert.ifError(err);
|
||||
assert.ok(result.length > 0);
|
||||
|
||||
for (var i = 0; i < result.length; i++) {
|
||||
@ -140,8 +139,7 @@ TEST(function test_resolveMx_failure(done) {
|
||||
|
||||
TEST(function test_resolveNs(done) {
|
||||
var req = dns.resolveNs('rackspace.com', function(err, names) {
|
||||
if (err) throw err;
|
||||
|
||||
assert.ifError(err);
|
||||
assert.ok(names.length > 0);
|
||||
|
||||
for (var i = 0; i < names.length; i++) {
|
||||
@ -171,8 +169,7 @@ TEST(function test_resolveNs_failure(done) {
|
||||
|
||||
TEST(function test_resolveSrv(done) {
|
||||
var req = dns.resolveSrv('_jabber._tcp.google.com', function(err, result) {
|
||||
if (err) throw err;
|
||||
|
||||
assert.ifError(err);
|
||||
assert.ok(result.length > 0);
|
||||
|
||||
for (var i = 0; i < result.length; i++) {
|
||||
@ -209,8 +206,7 @@ TEST(function test_resolveSrv_failure(done) {
|
||||
|
||||
TEST(function test_resolvePtr(done) {
|
||||
var req = dns.resolvePtr('8.8.8.8.in-addr.arpa', function(err, result) {
|
||||
if (err) throw err;
|
||||
|
||||
assert.ifError(err);
|
||||
assert.ok(result.length > 0);
|
||||
|
||||
for (var i = 0; i < result.length; i++) {
|
||||
@ -240,8 +236,7 @@ TEST(function test_resolvePtr_failure(done) {
|
||||
|
||||
TEST(function test_resolveNaptr(done) {
|
||||
var req = dns.resolveNaptr('sip2sip.info', function(err, result) {
|
||||
if (err) throw err;
|
||||
|
||||
assert.ifError(err);
|
||||
assert.ok(result.length > 0);
|
||||
|
||||
for (var i = 0; i < result.length; i++) {
|
||||
@ -278,8 +273,7 @@ TEST(function test_resolveNaptr_failure(done) {
|
||||
|
||||
TEST(function test_resolveSoa(done) {
|
||||
var req = dns.resolveSoa('nodejs.org', function(err, result) {
|
||||
if (err) throw err;
|
||||
|
||||
assert.ifError(err);
|
||||
assert.ok(result);
|
||||
assert.strictEqual(typeof result, 'object');
|
||||
|
||||
@ -325,8 +319,7 @@ TEST(function test_resolveSoa_failure(done) {
|
||||
|
||||
TEST(function test_resolveCname(done) {
|
||||
var req = dns.resolveCname('www.microsoft.com', function(err, names) {
|
||||
if (err) throw err;
|
||||
|
||||
assert.ifError(err);
|
||||
assert.ok(names.length > 0);
|
||||
|
||||
for (var i = 0; i < names.length; i++) {
|
||||
@ -357,7 +350,7 @@ TEST(function test_resolveCname_failure(done) {
|
||||
|
||||
TEST(function test_resolveTxt(done) {
|
||||
var req = dns.resolveTxt('google.com', function(err, records) {
|
||||
if (err) throw err;
|
||||
assert.ifError(err);
|
||||
assert.strictEqual(records.length, 1);
|
||||
assert.ok(util.isArray(records[0]));
|
||||
assert.strictEqual(records[0][0].indexOf('v=spf1'), 0);
|
||||
@ -398,7 +391,7 @@ TEST(function test_lookup_failure(done) {
|
||||
|
||||
TEST(function test_lookup_null(done) {
|
||||
var req = dns.lookup(null, function(err, ip, family) {
|
||||
if (err) throw err;
|
||||
assert.ifError(err);
|
||||
assert.strictEqual(ip, null);
|
||||
assert.strictEqual(family, 4);
|
||||
|
||||
@ -411,7 +404,7 @@ TEST(function test_lookup_null(done) {
|
||||
|
||||
TEST(function test_lookup_ip_all(done) {
|
||||
var req = dns.lookup('127.0.0.1', {all: true}, function(err, ips, family) {
|
||||
if (err) throw err;
|
||||
assert.ifError(err);
|
||||
assert.ok(Array.isArray(ips));
|
||||
assert.ok(ips.length > 0);
|
||||
assert.strictEqual(ips[0].address, '127.0.0.1');
|
||||
@ -426,7 +419,7 @@ TEST(function test_lookup_ip_all(done) {
|
||||
|
||||
TEST(function test_lookup_null_all(done) {
|
||||
var req = dns.lookup(null, {all: true}, function(err, ips, family) {
|
||||
if (err) throw err;
|
||||
assert.ifError(err);
|
||||
assert.ok(Array.isArray(ips));
|
||||
assert.strictEqual(ips.length, 0);
|
||||
|
||||
@ -439,7 +432,7 @@ TEST(function test_lookup_null_all(done) {
|
||||
|
||||
TEST(function test_lookup_all_mixed(done) {
|
||||
var req = dns.lookup('www.google.com', {all: true}, function(err, ips) {
|
||||
if (err) throw err;
|
||||
assert.ifError(err);
|
||||
assert.ok(Array.isArray(ips));
|
||||
assert.ok(ips.length > 0);
|
||||
|
||||
|
@ -76,7 +76,7 @@ if (process.argv[2] === 'child') {
|
||||
serverPort,
|
||||
'127.0.0.1',
|
||||
function(err) {
|
||||
if (err) throw err;
|
||||
assert.ifError(err);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ d.run(function() {
|
||||
var fs = require('fs');
|
||||
fs.readdir(__dirname, function() {
|
||||
fs.open('this file does not exist', 'r', function(er) {
|
||||
if (er) throw er;
|
||||
assert.ifError(er);
|
||||
throw new Error('should not get here!');
|
||||
});
|
||||
});
|
||||
|
@ -9,14 +9,14 @@ common.refreshTmpDir();
|
||||
|
||||
assert.doesNotThrow(() => {
|
||||
fs.access(Buffer.from(common.tmpDir), common.mustCall((err) => {
|
||||
if (err) throw err;
|
||||
assert.ifError(err);
|
||||
}));
|
||||
});
|
||||
|
||||
assert.doesNotThrow(() => {
|
||||
const buf = Buffer.from(path.join(common.tmpDir, 'a.txt'));
|
||||
fs.open(buf, 'w+', common.mustCall((err, fd) => {
|
||||
if (err) throw err;
|
||||
assert.ifError(err);
|
||||
assert(fd);
|
||||
fs.close(fd, common.mustCall(() => {
|
||||
fs.unlinkSync(buf);
|
||||
@ -30,12 +30,12 @@ assert.throws(() => {
|
||||
|
||||
const dir = Buffer.from(common.fixturesDir);
|
||||
fs.readdir(dir, 'hex', common.mustCall((err, list) => {
|
||||
if (err) throw err;
|
||||
assert.ifError(err);
|
||||
list = list.map((i) => {
|
||||
return Buffer.from(i, 'hex').toString();
|
||||
});
|
||||
fs.readdir(dir, common.mustCall((err, list2) => {
|
||||
if (err) throw err;
|
||||
assert.ifError(err);
|
||||
assert.deepStrictEqual(list, list2);
|
||||
}));
|
||||
}));
|
||||
|
@ -12,7 +12,7 @@ const dstPath = path.join(common.tmpDir, 'link1.js');
|
||||
fs.writeFileSync(srcPath, 'hello world');
|
||||
|
||||
const callback = function(err) {
|
||||
if (err) throw err;
|
||||
assert.ifError(err);
|
||||
const dstContent = fs.readFileSync(dstPath, 'utf8');
|
||||
assert.strictEqual('hello world', dstContent);
|
||||
};
|
||||
|
@ -19,7 +19,7 @@ const fullpath = Buffer.concat([root, filebuff]);
|
||||
fs.closeSync(fs.openSync(fullpath, 'w+'));
|
||||
|
||||
fs.readdir(common.tmpDir, 'ucs2', (err, list) => {
|
||||
if (err) throw err;
|
||||
assert.ifError(err);
|
||||
assert.equal(1, list.length);
|
||||
const fn = list[0];
|
||||
assert.deepStrictEqual(filebuff, Buffer.from(fn, 'ucs2'));
|
||||
|
@ -29,11 +29,10 @@ tempFdSync(function(fd) {
|
||||
|
||||
function tempFd(callback) {
|
||||
fs.open(fn, 'r', function(err, fd) {
|
||||
if (err) throw err;
|
||||
|
||||
assert.ifError(err);
|
||||
callback(fd, function() {
|
||||
fs.close(fd, function(err) {
|
||||
if (err) throw err;
|
||||
assert.ifError(err);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -14,7 +14,7 @@ const fs = require('fs');
|
||||
|
||||
if (process.argv[2] === 'child') {
|
||||
fs.readFile('/dev/stdin', function(er, data) {
|
||||
if (er) throw er;
|
||||
assert.ifError(er);
|
||||
process.stdout.write(data);
|
||||
});
|
||||
return;
|
||||
@ -30,8 +30,7 @@ const f = JSON.stringify(__filename);
|
||||
const node = JSON.stringify(process.execPath);
|
||||
const cmd = `cat ${filename} | ${node} ${f} child`;
|
||||
exec(cmd, { maxBuffer: 1000000 }, function(err, stdout, stderr) {
|
||||
if (err) console.error(err);
|
||||
assert(!err, 'it exits normally');
|
||||
assert.ifError(err);
|
||||
assert.strictEqual(stdout, dataExpected, 'it reads the file and outputs it');
|
||||
assert.strictEqual(stderr, '', 'it does not write to stderr');
|
||||
console.log('ok');
|
||||
|
@ -26,8 +26,7 @@ const f = JSON.stringify(__filename);
|
||||
const node = JSON.stringify(process.execPath);
|
||||
const cmd = `cat ${f} | ${node} ${f} child`;
|
||||
exec(cmd, function(err, stdout, stderr) {
|
||||
if (err) console.error(err);
|
||||
assert(!err, 'it exits normally');
|
||||
assert.ifError(err);
|
||||
assert.strictEqual(stdout, dataExpected, 'it reads the file and outputs it');
|
||||
assert.strictEqual(stderr, '', 'it does not write to stderr');
|
||||
console.log('ok');
|
||||
|
@ -27,8 +27,7 @@ const f = JSON.stringify(__filename);
|
||||
const node = JSON.stringify(process.execPath);
|
||||
const cmd = `cat ${filename} | ${node} ${f} child`;
|
||||
exec(cmd, { maxBuffer: 1000000 }, function(err, stdout, stderr) {
|
||||
if (err) console.error(err);
|
||||
assert(!err, 'it exits normally');
|
||||
assert.ifError(err);
|
||||
assert.strictEqual(stdout, dataExpected, 'it reads the file and outputs it');
|
||||
assert.strictEqual(stderr, '', 'it does not write to stderr');
|
||||
console.log('ok');
|
||||
|
@ -50,39 +50,39 @@ for (encoding in expected) {
|
||||
const expected_value = expected[encoding];
|
||||
|
||||
fs.realpath(string_dir, {encoding: encoding}, common.mustCall((err, res) => {
|
||||
assert(!err);
|
||||
assert.ifError(err);
|
||||
assert.strictEqual(res, expected_value);
|
||||
}));
|
||||
fs.realpath(string_dir, encoding, common.mustCall((err, res) => {
|
||||
assert(!err);
|
||||
assert.ifError(err);
|
||||
assert.strictEqual(res, expected_value);
|
||||
}));
|
||||
fs.realpath(buffer_dir, {encoding: encoding}, common.mustCall((err, res) => {
|
||||
assert(!err);
|
||||
assert.ifError(err);
|
||||
assert.strictEqual(res, expected_value);
|
||||
}));
|
||||
fs.realpath(buffer_dir, encoding, common.mustCall((err, res) => {
|
||||
assert(!err);
|
||||
assert.ifError(err);
|
||||
assert.strictEqual(res, expected_value);
|
||||
}));
|
||||
}
|
||||
|
||||
fs.realpath(string_dir, {encoding: 'buffer'}, common.mustCall((err, res) => {
|
||||
assert(!err);
|
||||
assert.ifError(err);
|
||||
assert.deepStrictEqual(res, buffer_dir);
|
||||
}));
|
||||
|
||||
fs.realpath(string_dir, 'buffer', common.mustCall((err, res) => {
|
||||
assert(!err);
|
||||
assert.ifError(err);
|
||||
assert.deepStrictEqual(res, buffer_dir);
|
||||
}));
|
||||
|
||||
fs.realpath(buffer_dir, {encoding: 'buffer'}, common.mustCall((err, res) => {
|
||||
assert(!err);
|
||||
assert.ifError(err);
|
||||
assert.deepStrictEqual(res, buffer_dir);
|
||||
}));
|
||||
|
||||
fs.realpath(buffer_dir, 'buffer', common.mustCall((err, res) => {
|
||||
assert(!err);
|
||||
assert.ifError(err);
|
||||
assert.deepStrictEqual(res, buffer_dir);
|
||||
}));
|
||||
|
@ -42,12 +42,12 @@ assert(Buffer.isBuffer(result));
|
||||
assert(result.equals(filenameBuffer));
|
||||
|
||||
fs.realpath(filename, common.mustCall(function(err, result) {
|
||||
assert(!err);
|
||||
assert.ifError(err);
|
||||
assert.strictEqual(result, filename);
|
||||
}));
|
||||
|
||||
fs.realpath(filename, 'buffer', common.mustCall(function(err, result) {
|
||||
assert(!err);
|
||||
assert.ifError(err);
|
||||
assert(Buffer.isBuffer(result));
|
||||
assert(result.equals(filenameBuffer));
|
||||
}));
|
||||
|
@ -386,10 +386,10 @@ function test_up_multiple(cb) {
|
||||
assertEqualPath(fs.realpathSync(abedabeda), abedabeda_real);
|
||||
assertEqualPath(fs.realpathSync(abedabed), abedabed_real);
|
||||
fs.realpath(abedabeda, function(er, real) {
|
||||
if (er) throw er;
|
||||
assert.ifError(er);
|
||||
assertEqualPath(abedabeda_real, real);
|
||||
fs.realpath(abedabed, function(er, real) {
|
||||
if (er) throw er;
|
||||
assert.ifError(er);
|
||||
assertEqualPath(abedabed_real, real);
|
||||
cb();
|
||||
cleanup();
|
||||
@ -476,7 +476,7 @@ const tests = [
|
||||
const numtests = tests.length;
|
||||
var testsRun = 0;
|
||||
function runNextTest(err) {
|
||||
if (err) throw err;
|
||||
assert.ifError(err);
|
||||
const test = tests.shift();
|
||||
if (!test) {
|
||||
return console.log(numtests +
|
||||
|
@ -43,9 +43,9 @@ fs.closeSync(fd);
|
||||
|
||||
// async tests
|
||||
testTruncate(common.mustCall(function(er) {
|
||||
if (er) throw er;
|
||||
assert.ifError(er);
|
||||
testFtruncate(common.mustCall(function(er) {
|
||||
if (er) throw er;
|
||||
assert.ifError(er);
|
||||
}));
|
||||
}));
|
||||
|
||||
|
@ -32,7 +32,7 @@ function next() {
|
||||
function next2() {
|
||||
// This will test if after reusing the fd data is written properly
|
||||
fs.readFile(file, function(err, data) {
|
||||
assert(!err);
|
||||
assert.ifError(err);
|
||||
assert.strictEqual(data.toString(), 'Test2');
|
||||
process.nextTick(common.mustCall(next3));
|
||||
});
|
||||
|
@ -12,11 +12,11 @@ var data = true;
|
||||
var expected = data + '';
|
||||
|
||||
fs.open(fn, 'w', 0o644, common.mustCall(function(err, fd) {
|
||||
if (err) throw err;
|
||||
assert.ifError(err);
|
||||
console.log('open done');
|
||||
fs.write(fd, data, 0, 'utf8', common.mustCall(function(err, written) {
|
||||
console.log('write done');
|
||||
if (err) throw err;
|
||||
assert.ifError(err);
|
||||
assert.equal(Buffer.byteLength(expected), written);
|
||||
fs.closeSync(fd);
|
||||
const found = fs.readFileSync(fn, 'utf8');
|
||||
|
@ -12,14 +12,14 @@ const constants = fs.constants;
|
||||
common.refreshTmpDir();
|
||||
|
||||
fs.open(fn, 'w', 0o644, common.mustCall(function(err, fd) {
|
||||
if (err) throw err;
|
||||
assert.ifError(err);
|
||||
console.log('open done');
|
||||
fs.write(fd, '', 0, 'utf8', function(err, written) {
|
||||
assert.strictEqual(0, written);
|
||||
});
|
||||
fs.write(fd, expected, 0, 'utf8', common.mustCall(function(err, written) {
|
||||
console.log('write done');
|
||||
if (err) throw err;
|
||||
assert.ifError(err);
|
||||
assert.strictEqual(Buffer.byteLength(expected), written);
|
||||
fs.closeSync(fd);
|
||||
const found = fs.readFileSync(fn, 'utf8');
|
||||
@ -33,14 +33,14 @@ fs.open(fn, 'w', 0o644, common.mustCall(function(err, fd) {
|
||||
|
||||
fs.open(fn2, constants.O_CREAT | constants.O_WRONLY | constants.O_TRUNC, 0o644,
|
||||
common.mustCall((err, fd) => {
|
||||
if (err) throw err;
|
||||
assert.ifError(err);
|
||||
console.log('open done');
|
||||
fs.write(fd, '', 0, 'utf8', (err, written) => {
|
||||
assert.strictEqual(0, written);
|
||||
});
|
||||
fs.write(fd, expected, 0, 'utf8', common.mustCall((err, written) => {
|
||||
console.log('write done');
|
||||
if (err) throw err;
|
||||
assert.ifError(err);
|
||||
assert.strictEqual(Buffer.byteLength(expected), written);
|
||||
fs.closeSync(fd);
|
||||
const found = fs.readFileSync(fn2, 'utf8');
|
||||
|
@ -51,7 +51,7 @@ function executeRequest(cb) {
|
||||
__filename,
|
||||
'shasum' ].join(' '),
|
||||
(err, stdout, stderr) => {
|
||||
if (err) throw err;
|
||||
assert.ifError(err);
|
||||
assert.equal('8c206a1a87599f532ce68675536f0b1546900d7a',
|
||||
stdout.slice(0, 40));
|
||||
cb();
|
||||
@ -65,7 +65,7 @@ common.refreshTmpDir();
|
||||
const ddcmd = common.ddCommand(filename, 10240);
|
||||
|
||||
cp.exec(ddcmd, function(err, stdout, stderr) {
|
||||
if (err) throw err;
|
||||
assert.ifError(err);
|
||||
server = http.createServer(function(req, res) {
|
||||
res.writeHead(200);
|
||||
|
||||
|
@ -39,9 +39,7 @@ function testHttp() {
|
||||
|
||||
httpServer.listen(0, function(er) {
|
||||
console.error(`test http server listening on ${this.address().port}`);
|
||||
|
||||
if (er) throw er;
|
||||
|
||||
assert.ifError(er);
|
||||
http.get({
|
||||
method: 'GET',
|
||||
path: '/' + (counter++),
|
||||
|
@ -51,9 +51,7 @@ function testHttps() {
|
||||
|
||||
httpsServer.listen(0, function(er) {
|
||||
console.log(`test https server listening on port ${this.address().port}`);
|
||||
|
||||
if (er) throw er;
|
||||
|
||||
assert.ifError(er);
|
||||
https.get({
|
||||
method: 'GET',
|
||||
path: '/' + (counter++),
|
||||
|
@ -38,7 +38,7 @@ server.on('listening', function() {
|
||||
const cmd = common.ddCommand(filename, 10240);
|
||||
|
||||
cp.exec(cmd, function(err) {
|
||||
if (err) throw err;
|
||||
assert.ifError(err);
|
||||
makeRequest();
|
||||
});
|
||||
});
|
||||
|
@ -36,7 +36,7 @@ childProcess.exec(nodeBinary + ' ' +
|
||||
preloadOption([fixtureA]) + ' ' +
|
||||
fixtureB,
|
||||
function(err, stdout, stderr) {
|
||||
if (err) throw err;
|
||||
assert.ifError(err);
|
||||
assert.strictEqual(stdout, 'A\nB\n');
|
||||
});
|
||||
|
||||
@ -45,7 +45,7 @@ childProcess.exec(nodeBinary + ' ' +
|
||||
preloadOption([fixtureA, fixtureB]) + ' ' +
|
||||
fixtureC,
|
||||
function(err, stdout, stderr) {
|
||||
if (err) throw err;
|
||||
assert.ifError(err);
|
||||
assert.strictEqual(stdout, 'A\nB\nC\n');
|
||||
});
|
||||
|
||||
@ -66,7 +66,7 @@ childProcess.exec(nodeBinary + ' ' +
|
||||
preloadOption([fixtureA]) +
|
||||
'-e "console.log(\'hello\');"',
|
||||
function(err, stdout, stderr) {
|
||||
if (err) throw err;
|
||||
assert.ifError(err);
|
||||
assert.strictEqual(stdout, 'A\nhello\n');
|
||||
});
|
||||
|
||||
@ -113,7 +113,7 @@ childProcess.exec(nodeBinary + ' ' +
|
||||
'-e "console.log(\'hello\');" ' +
|
||||
preloadOption([fixtureA, fixtureB]),
|
||||
function(err, stdout, stderr) {
|
||||
if (err) throw err;
|
||||
assert.ifError(err);
|
||||
assert.strictEqual(stdout, 'A\nB\nhello\n');
|
||||
});
|
||||
|
||||
@ -133,7 +133,7 @@ childProcess.exec(nodeBinary + ' ' +
|
||||
'--require ' + fixture('cluster-preload.js') + ' ' +
|
||||
fixture('cluster-preload-test.js'),
|
||||
function(err, stdout, stderr) {
|
||||
if (err) throw err;
|
||||
assert.ifError(err);
|
||||
assert.ok(/worker terminated with code 43/.test(stdout));
|
||||
});
|
||||
|
||||
@ -144,6 +144,6 @@ childProcess.exec(nodeBinary + ' ' +
|
||||
'--require ' + fixture('cluster-preload.js') + ' ' +
|
||||
'cluster-preload-test.js',
|
||||
function(err, stdout, stderr) {
|
||||
if (err) throw err;
|
||||
assert.ifError(err);
|
||||
assert.ok(/worker terminated with code 43/.test(stdout));
|
||||
});
|
||||
|
@ -13,7 +13,7 @@ if (typeof process.getgroups === 'function') {
|
||||
assert(Array.isArray(groups));
|
||||
assert(groups.length > 0);
|
||||
exec('id -G', function(err, stdout) {
|
||||
if (err) throw err;
|
||||
assert.ifError(err);
|
||||
var real_groups = stdout.match(/\d+/g).map(Number);
|
||||
assert.equal(groups.length, real_groups.length);
|
||||
check(groups, real_groups);
|
||||
|
@ -27,5 +27,5 @@ assert(common.fileExists(dir), 'Directory is not accessible');
|
||||
|
||||
// Test if file exists asynchronously
|
||||
fs.access(dir, function(err) {
|
||||
assert(!err, 'Directory is not accessible');
|
||||
assert.ifError(err);
|
||||
});
|
||||
|
@ -45,7 +45,7 @@ function run(test) {
|
||||
};
|
||||
|
||||
REPL.createInternalRepl(env, opts, function(err, repl) {
|
||||
if (err) throw err;
|
||||
assert.ifError(err);
|
||||
|
||||
// The REPL registers 'module' and 'require' globals
|
||||
common.allowGlobals(repl.context.module, repl.context.require);
|
||||
|
@ -33,8 +33,7 @@ common.refreshTmpDir();
|
||||
const replHistoryPath = path.join(common.tmpDir, '.node_repl_history');
|
||||
|
||||
const checkResults = common.mustCall(function(err, r) {
|
||||
if (err)
|
||||
throw err;
|
||||
assert.ifError(err);
|
||||
|
||||
// The REPL registers 'module' and 'require' globals
|
||||
common.allowGlobals(r.context.module, r.context.require);
|
||||
|
@ -28,8 +28,7 @@ function test(size, useBuffer, cb) {
|
||||
console.log(`${size} chars to ${tmpFile}...`);
|
||||
|
||||
childProcess.exec(cmd, common.mustCall(function(err) {
|
||||
if (err) throw err;
|
||||
|
||||
assert.ifError(err);
|
||||
console.log('done!');
|
||||
|
||||
var stat = fs.statSync(tmpFile);
|
||||
|
@ -31,8 +31,7 @@ function test(decode, uncork, multi, next) {
|
||||
expectCount++;
|
||||
var expect = expectCount;
|
||||
return function(er) {
|
||||
if (er)
|
||||
throw er;
|
||||
assert.ifError(er);
|
||||
counter++;
|
||||
assert.equal(counter, expect);
|
||||
};
|
||||
|
@ -46,7 +46,7 @@ function test(size, type, name, next) {
|
||||
});
|
||||
|
||||
server.on('close', common.mustCall(function(err) {
|
||||
assert(!err);
|
||||
assert.ifError(err);
|
||||
if (next) next();
|
||||
}));
|
||||
|
||||
|
@ -36,7 +36,7 @@ function test(keylen, expectedCipher, cb) {
|
||||
});
|
||||
|
||||
server.on('close', function(err) {
|
||||
assert(!err);
|
||||
assert.ifError(err);
|
||||
if (cb) cb();
|
||||
});
|
||||
|
||||
|
@ -33,7 +33,7 @@ server.listen(0, '127.0.0.1', common.mustCall(function() {
|
||||
cmd += ' -no_rand_screen';
|
||||
|
||||
exec(cmd, common.mustCall(function(err, stdout, stderr) {
|
||||
if (err) throw err;
|
||||
assert.ifError(err);
|
||||
assert(stdout.includes(reply));
|
||||
server.close();
|
||||
}));
|
||||
|
@ -282,7 +282,7 @@ function runTest(port, testIndex) {
|
||||
requestCert: true,
|
||||
rejectUnauthorized: false
|
||||
}, function(err) {
|
||||
assert(!err);
|
||||
assert.ifError(err);
|
||||
c.write('\n_renegotiated\n');
|
||||
handleConnection(c);
|
||||
});
|
||||
|
@ -42,7 +42,7 @@ server.listen(0, '127.0.0.1', function() {
|
||||
cmd += ' -no_rand_screen';
|
||||
|
||||
exec(cmd, function(err, stdout, stderr) {
|
||||
if (err) throw err;
|
||||
assert.ifError(err);
|
||||
response = stdout;
|
||||
server.close();
|
||||
});
|
||||
|
@ -22,7 +22,7 @@ const inputString = 'ΩΩLorem ipsum dolor sit amet, consectetur adipiscing eli'
|
||||
{ comp: 'deflateRaw', decomp: 'inflateRaw', decompSync: 'inflateRawSync' }
|
||||
].forEach(function(methods) {
|
||||
zlib[methods.comp](inputString, function(err, compressed) {
|
||||
assert(!err);
|
||||
assert.ifError(err);
|
||||
const truncated = compressed.slice(0, compressed.length / 2);
|
||||
const toUTF8 = (buffer) => buffer.toString('utf-8');
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user