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