test: add common.mustNotCall()
This commit adds a mustNotCall() helper for testing. This provides an alternative to using common.fail() as a callback, or creating a callback function for the sole purpose of calling common.fail(). PR-URL: https://github.com/nodejs/node/pull/11152 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
This commit is contained in:
parent
9549329158
commit
7dd82dd1c3
@ -497,6 +497,12 @@ function fail(msg) {
|
|||||||
}
|
}
|
||||||
exports.fail = fail;
|
exports.fail = fail;
|
||||||
|
|
||||||
|
exports.mustNotCall = function(msg) {
|
||||||
|
return function mustNotCall() {
|
||||||
|
fail(msg || 'function should not have been called');
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
exports.skip = function(msg) {
|
exports.skip = function(msg) {
|
||||||
console.log(`1..0 # Skipped: ${msg}`);
|
console.log(`1..0 # Skipped: ${msg}`);
|
||||||
};
|
};
|
||||||
|
@ -15,8 +15,8 @@ const interfacer = spawn(process.execPath, ['debug', `localhost:${PORT}`]);
|
|||||||
interfacer.stdout.setEncoding('utf-8');
|
interfacer.stdout.setEncoding('utf-8');
|
||||||
|
|
||||||
// fail the test if either of the processes exit normally
|
// fail the test if either of the processes exit normally
|
||||||
const debugBreakExit = common.fail.bind(null, 'child should not exit normally');
|
const debugBreakExit = common.mustNotCall('child should not exit normally');
|
||||||
const debugExit = common.fail.bind(null, 'interfacer should not exit normally');
|
const debugExit = common.mustNotCall('interfacer should not exit normally');
|
||||||
child.on('exit', debugBreakExit);
|
child.on('exit', debugBreakExit);
|
||||||
interfacer.on('exit', debugExit);
|
interfacer.on('exit', debugExit);
|
||||||
|
|
||||||
|
@ -116,7 +116,8 @@ function makeBufferingDataCallback(dataCallback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function timeout(message, multiplicator) {
|
function timeout(message, multiplicator) {
|
||||||
return setTimeout(() => common.fail(message), TIMEOUT * (multiplicator || 1));
|
return setTimeout(common.mustNotCall(message),
|
||||||
|
TIMEOUT * (multiplicator || 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
const TestSession = function(socket, harness) {
|
const TestSession = function(socket, harness) {
|
||||||
@ -398,7 +399,7 @@ Harness.prototype.wsHandshake = function(devtoolsUrl, tests, readyCallback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
enqueue(tests);
|
enqueue(tests);
|
||||||
}).on('response', () => common.fail('Upgrade was not received'));
|
}).on('response', common.mustNotCall('Upgrade was not received'));
|
||||||
};
|
};
|
||||||
|
|
||||||
Harness.prototype.runFrontendSession = function(tests) {
|
Harness.prototype.runFrontendSession = function(tests) {
|
||||||
|
@ -45,7 +45,7 @@ function checkWrap(req) {
|
|||||||
|
|
||||||
TEST(function test_reverse_bogus(done) {
|
TEST(function test_reverse_bogus(done) {
|
||||||
assert.throws(() => {
|
assert.throws(() => {
|
||||||
dns.reverse('bogus ip', common.fail);
|
dns.reverse('bogus ip', common.mustNotCall());
|
||||||
}, /^Error: getHostByAddr EINVAL$/);
|
}, /^Error: getHostByAddr EINVAL$/);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
@ -16,7 +16,7 @@ function httpreq(count) {
|
|||||||
port: 80,
|
port: 80,
|
||||||
path: '/',
|
path: '/',
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
}, common.fail);
|
}, common.mustNotCall());
|
||||||
|
|
||||||
req.on('error', common.mustCall((e) => {
|
req.on('error', common.mustCall((e) => {
|
||||||
assert.strictEqual(e.code, 'ENOTFOUND');
|
assert.strictEqual(e.code, 'ENOTFOUND');
|
||||||
|
@ -26,4 +26,4 @@ socket.on('timeout', common.mustCall(function() {
|
|||||||
socket.destroy();
|
socket.destroy();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
socket.on('connect', common.fail);
|
socket.on('connect', common.mustNotCall());
|
||||||
|
@ -8,6 +8,6 @@ const client = net.createConnection(53, '8.8.8.8', function() {
|
|||||||
client.unref();
|
client.unref();
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('close', common.fail);
|
client.on('close', common.mustNotCall());
|
||||||
|
|
||||||
setTimeout(common.fail, TIMEOUT).unref();
|
setTimeout(common.mustNotCall(), TIMEOUT).unref();
|
||||||
|
@ -37,10 +37,10 @@ if (typeof process.argv[2] === 'string') {
|
|||||||
async_wrap.setupHooks({ init, pre, post, destroy });
|
async_wrap.setupHooks({ init, pre, post, destroy });
|
||||||
async_wrap.enable();
|
async_wrap.enable();
|
||||||
|
|
||||||
process.on('uncaughtException', common.fail);
|
process.on('uncaughtException', common.mustNotCall());
|
||||||
|
|
||||||
const d = domain.create();
|
const d = domain.create();
|
||||||
d.on('error', common.fail);
|
d.on('error', common.mustNotCall());
|
||||||
d.run(() => {
|
d.run(() => {
|
||||||
// Using randomBytes because timers are not yet supported.
|
// Using randomBytes because timers are not yet supported.
|
||||||
crypto.randomBytes(0, () => { });
|
crypto.randomBytes(0, () => { });
|
||||||
|
@ -5,7 +5,7 @@ const spawn = require('child_process').spawn;
|
|||||||
const cat = spawn(common.isWindows ? 'cmd' : 'cat');
|
const cat = spawn(common.isWindows ? 'cmd' : 'cat');
|
||||||
|
|
||||||
cat.stdout.on('end', common.mustCall(function() {}));
|
cat.stdout.on('end', common.mustCall(function() {}));
|
||||||
cat.stderr.on('data', common.fail);
|
cat.stderr.on('data', common.mustNotCall());
|
||||||
cat.stderr.on('end', common.mustCall(function() {}));
|
cat.stderr.on('end', common.mustCall(function() {}));
|
||||||
|
|
||||||
cat.on('exit', common.mustCall(function(code, signal) {
|
cat.on('exit', common.mustCall(function(code, signal) {
|
||||||
|
@ -24,7 +24,7 @@ function master() {
|
|||||||
});
|
});
|
||||||
proc.stdout.on('data', common.mustCall((data) => {
|
proc.stdout.on('data', common.mustCall((data) => {
|
||||||
assert.strictEqual(data.toString(), 'ok\r\n');
|
assert.strictEqual(data.toString(), 'ok\r\n');
|
||||||
net.createServer(common.fail).listen(0, function() {
|
net.createServer(common.mustNotCall()).listen(0, function() {
|
||||||
handle = this._handle;
|
handle = this._handle;
|
||||||
proc.send('one');
|
proc.send('one');
|
||||||
proc.send('two', handle);
|
proc.send('two', handle);
|
||||||
|
@ -20,7 +20,7 @@ s.on('exit', function() {
|
|||||||
handle.close();
|
handle.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
net.createServer(common.fail).listen(0, function() {
|
net.createServer(common.mustNotCall()).listen(0, function() {
|
||||||
handle = this._handle;
|
handle = this._handle;
|
||||||
assert.strictEqual(s.send('one', handle), true);
|
assert.strictEqual(s.send('one', handle), true);
|
||||||
assert.strictEqual(s.send('two', handle), true);
|
assert.strictEqual(s.send('two', handle), true);
|
||||||
|
@ -7,7 +7,7 @@ const cp = require('child_process');
|
|||||||
const doesNotExist = cp.spawn('does-not-exist', {shell: true});
|
const doesNotExist = cp.spawn('does-not-exist', {shell: true});
|
||||||
|
|
||||||
assert.notStrictEqual(doesNotExist.spawnfile, 'does-not-exist');
|
assert.notStrictEqual(doesNotExist.spawnfile, 'does-not-exist');
|
||||||
doesNotExist.on('error', common.fail);
|
doesNotExist.on('error', common.mustNotCall());
|
||||||
doesNotExist.on('exit', common.mustCall((code, signal) => {
|
doesNotExist.on('exit', common.mustCall((code, signal) => {
|
||||||
assert.strictEqual(signal, null);
|
assert.strictEqual(signal, null);
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ const empty = common.fixturesDir + '/empty.js';
|
|||||||
|
|
||||||
assert.throws(function() {
|
assert.throws(function() {
|
||||||
const child = spawn(invalidcmd, 'this is not an array');
|
const child = spawn(invalidcmd, 'this is not an array');
|
||||||
child.on('error', common.fail);
|
child.on('error', common.mustNotCall());
|
||||||
}, TypeError);
|
}, TypeError);
|
||||||
|
|
||||||
// verify that valid argument combinations do not throw
|
// verify that valid argument combinations do not throw
|
||||||
|
@ -24,7 +24,7 @@ cat.stdout.on('data', function(chunk) {
|
|||||||
|
|
||||||
cat.stdout.on('end', common.mustCall(function() {}));
|
cat.stdout.on('end', common.mustCall(function() {}));
|
||||||
|
|
||||||
cat.stderr.on('data', common.fail);
|
cat.stderr.on('data', common.mustNotCall());
|
||||||
|
|
||||||
cat.stderr.on('end', common.mustCall(function() {}));
|
cat.stderr.on('end', common.mustCall(function() {}));
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ const child = spawn(process.argv[0], [sub, n]);
|
|||||||
let count = 0;
|
let count = 0;
|
||||||
|
|
||||||
child.stderr.setEncoding('utf8');
|
child.stderr.setEncoding('utf8');
|
||||||
child.stderr.on('data', common.fail);
|
child.stderr.on('data', common.mustNotCall());
|
||||||
|
|
||||||
child.stdout.setEncoding('utf8');
|
child.stdout.setEncoding('utf8');
|
||||||
child.stdout.on('data', (data) => {
|
child.stdout.on('data', (data) => {
|
||||||
|
@ -19,8 +19,8 @@ if (cluster.isMaster) {
|
|||||||
assert.strictEqual(exitCode, 0);
|
assert.strictEqual(exitCode, 0);
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
const s = net.createServer(common.fail);
|
const s = net.createServer(common.mustNotCall());
|
||||||
s.listen(42, common.fail.bind(null, 'listen should have failed'));
|
s.listen(42, common.mustNotCall('listen should have failed'));
|
||||||
s.on('error', common.mustCall((err) => {
|
s.on('error', common.mustCall((err) => {
|
||||||
assert.strictEqual(err.code, 'EACCES');
|
assert.strictEqual(err.code, 'EACCES');
|
||||||
process.disconnect();
|
process.disconnect();
|
||||||
|
@ -60,7 +60,8 @@ if (!id) {
|
|||||||
} else if (id === 'one') {
|
} else if (id === 'one') {
|
||||||
if (cluster.isMaster) return startWorker();
|
if (cluster.isMaster) return startWorker();
|
||||||
|
|
||||||
http.createServer(common.fail).listen(common.PORT, common.mustCall(() => {
|
http.createServer(common.mustNotCall())
|
||||||
|
.listen(common.PORT, common.mustCall(() => {
|
||||||
process.send('READY');
|
process.send('READY');
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -70,11 +71,11 @@ if (!id) {
|
|||||||
} else if (id === 'two') {
|
} else if (id === 'two') {
|
||||||
if (cluster.isMaster) return startWorker();
|
if (cluster.isMaster) return startWorker();
|
||||||
|
|
||||||
const server = http.createServer(common.fail);
|
const server = http.createServer(common.mustNotCall());
|
||||||
process.on('message', common.mustCall((m) => {
|
process.on('message', common.mustCall((m) => {
|
||||||
if (m === 'QUIT') process.exit();
|
if (m === 'QUIT') process.exit();
|
||||||
assert.strictEqual(m, 'START');
|
assert.strictEqual(m, 'START');
|
||||||
server.listen(common.PORT, common.fail);
|
server.listen(common.PORT, common.mustNotCall());
|
||||||
server.on('error', common.mustCall((e) => {
|
server.on('error', common.mustCall((e) => {
|
||||||
assert.strictEqual(e.code, 'EADDRINUSE');
|
assert.strictEqual(e.code, 'EADDRINUSE');
|
||||||
process.send(e.code);
|
process.send(e.code);
|
||||||
|
@ -11,7 +11,7 @@ const net = require('net');
|
|||||||
const id = '' + process.argv[2];
|
const id = '' + process.argv[2];
|
||||||
|
|
||||||
if (id === 'undefined') {
|
if (id === 'undefined') {
|
||||||
const server = net.createServer(common.fail);
|
const server = net.createServer(common.mustNotCall());
|
||||||
server.listen(common.PORT, function() {
|
server.listen(common.PORT, function() {
|
||||||
const worker = fork(__filename, ['worker']);
|
const worker = fork(__filename, ['worker']);
|
||||||
worker.on('message', function(msg) {
|
worker.on('message', function(msg) {
|
||||||
@ -22,14 +22,14 @@ if (id === 'undefined') {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else if (id === 'worker') {
|
} else if (id === 'worker') {
|
||||||
let server = net.createServer(common.fail);
|
let server = net.createServer(common.mustNotCall());
|
||||||
server.listen(common.PORT, common.fail);
|
server.listen(common.PORT, common.mustNotCall());
|
||||||
server.on('error', common.mustCall(function(e) {
|
server.on('error', common.mustCall(function(e) {
|
||||||
assert(e.code, 'EADDRINUSE');
|
assert(e.code, 'EADDRINUSE');
|
||||||
process.send('stop-listening');
|
process.send('stop-listening');
|
||||||
process.once('message', function(msg) {
|
process.once('message', function(msg) {
|
||||||
if (msg !== 'stopped-listening') return;
|
if (msg !== 'stopped-listening') return;
|
||||||
server = net.createServer(common.fail);
|
server = net.createServer(common.mustNotCall());
|
||||||
server.listen(common.PORT, common.mustCall(function() {
|
server.listen(common.PORT, common.mustCall(function() {
|
||||||
server.close();
|
server.close();
|
||||||
}));
|
}));
|
||||||
|
@ -15,5 +15,5 @@ if (cluster.isMaster) {
|
|||||||
worker.kill();
|
worker.kill();
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
net.createServer(common.fail).listen(0);
|
net.createServer(common.mustNotCall()).listen(0);
|
||||||
}
|
}
|
||||||
|
@ -11,5 +11,5 @@ if (cluster.isMaster) {
|
|||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
// listen() without port should not trigger a libuv assert
|
// listen() without port should not trigger a libuv assert
|
||||||
net.createServer(common.fail).listen(process.exit);
|
net.createServer(common.mustNotCall()).listen(process.exit);
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ if (cluster.isMaster) {
|
|||||||
if (msg === 'done') this.kill();
|
if (msg === 'done') this.kill();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
const server = net.createServer(common.fail);
|
const server = net.createServer(common.mustNotCall());
|
||||||
server.listen(common.PORT, function() {
|
server.listen(common.PORT, function() {
|
||||||
server.unref();
|
server.unref();
|
||||||
server.ref();
|
server.ref();
|
||||||
|
@ -3,7 +3,7 @@ const common = require('../common');
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const cluster = require('cluster');
|
const cluster = require('cluster');
|
||||||
|
|
||||||
setTimeout(common.fail.bind(assert, 'setup not emitted'), 1000).unref();
|
setTimeout(common.mustNotCall('setup not emitted'), 1000).unref();
|
||||||
|
|
||||||
cluster.on('setup', common.mustCall(function() {
|
cluster.on('setup', common.mustCall(function() {
|
||||||
const clusterArgs = cluster.settings.args;
|
const clusterArgs = cluster.settings.args;
|
||||||
|
@ -8,7 +8,7 @@ if (cluster.isMaster) {
|
|||||||
// Master opens and binds the socket and shares it with the worker.
|
// Master opens and binds the socket and shares it with the worker.
|
||||||
cluster.schedulingPolicy = cluster.SCHED_NONE;
|
cluster.schedulingPolicy = cluster.SCHED_NONE;
|
||||||
// Hog the TCP port so that when the worker tries to bind, it'll fail.
|
// Hog the TCP port so that when the worker tries to bind, it'll fail.
|
||||||
const server = net.createServer(common.fail);
|
const server = net.createServer(common.mustNotCall());
|
||||||
|
|
||||||
server.listen(common.PORT, common.mustCall(() => {
|
server.listen(common.PORT, common.mustCall(() => {
|
||||||
const worker = cluster.fork();
|
const worker = cluster.fork();
|
||||||
@ -18,8 +18,8 @@ if (cluster.isMaster) {
|
|||||||
}));
|
}));
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
const s = net.createServer(common.fail);
|
const s = net.createServer(common.mustNotCall());
|
||||||
s.listen(common.PORT, common.fail.bind(null, 'listen should have failed'));
|
s.listen(common.PORT, common.mustNotCall('listen should have failed'));
|
||||||
s.on('error', common.mustCall((err) => {
|
s.on('error', common.mustCall((err) => {
|
||||||
assert.strictEqual(err.code, 'EADDRINUSE');
|
assert.strictEqual(err.code, 'EADDRINUSE');
|
||||||
process.disconnect();
|
process.disconnect();
|
||||||
|
@ -21,8 +21,8 @@ if (cluster.isMaster) {
|
|||||||
assert.strictEqual(exitCode, 0);
|
assert.strictEqual(exitCode, 0);
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
const s = net.createServer(common.fail);
|
const s = net.createServer(common.mustNotCall());
|
||||||
s.listen(42, common.fail.bind(null, 'listen should have failed'));
|
s.listen(42, common.mustNotCall('listen should have failed'));
|
||||||
s.on('error', common.mustCall(function(err) {
|
s.on('error', common.mustCall(function(err) {
|
||||||
assert.strictEqual(err.code, 'EACCES');
|
assert.strictEqual(err.code, 'EACCES');
|
||||||
process.disconnect();
|
process.disconnect();
|
||||||
|
@ -9,7 +9,7 @@ const err = new Stream();
|
|||||||
|
|
||||||
// ensure the Console instance doesn't write to the
|
// ensure the Console instance doesn't write to the
|
||||||
// process' "stdout" or "stderr" streams
|
// process' "stdout" or "stderr" streams
|
||||||
process.stdout.write = process.stderr.write = common.fail;
|
process.stdout.write = process.stderr.write = common.mustNotCall();
|
||||||
|
|
||||||
// make sure that the "Console" function exists
|
// make sure that the "Console" function exists
|
||||||
assert.strictEqual('function', typeof Console);
|
assert.strictEqual('function', typeof Console);
|
||||||
|
@ -63,27 +63,30 @@ assert.throws(function() {
|
|||||||
|
|
||||||
// Should not work with Infinity key length
|
// Should not work with Infinity key length
|
||||||
assert.throws(function() {
|
assert.throws(function() {
|
||||||
crypto.pbkdf2('password', 'salt', 1, Infinity, 'sha256', common.fail);
|
crypto.pbkdf2('password', 'salt', 1, Infinity, 'sha256',
|
||||||
|
common.mustNotCall());
|
||||||
}, /^TypeError: Bad key length$/);
|
}, /^TypeError: Bad key length$/);
|
||||||
|
|
||||||
// Should not work with negative Infinity key length
|
// Should not work with negative Infinity key length
|
||||||
assert.throws(function() {
|
assert.throws(function() {
|
||||||
crypto.pbkdf2('password', 'salt', 1, -Infinity, 'sha256', common.fail);
|
crypto.pbkdf2('password', 'salt', 1, -Infinity, 'sha256',
|
||||||
|
common.mustNotCall());
|
||||||
}, /^TypeError: Bad key length$/);
|
}, /^TypeError: Bad key length$/);
|
||||||
|
|
||||||
// Should not work with NaN key length
|
// Should not work with NaN key length
|
||||||
assert.throws(function() {
|
assert.throws(function() {
|
||||||
crypto.pbkdf2('password', 'salt', 1, NaN, 'sha256', common.fail);
|
crypto.pbkdf2('password', 'salt', 1, NaN, 'sha256', common.mustNotCall());
|
||||||
}, /^TypeError: Bad key length$/);
|
}, /^TypeError: Bad key length$/);
|
||||||
|
|
||||||
// Should not work with negative key length
|
// Should not work with negative key length
|
||||||
assert.throws(function() {
|
assert.throws(function() {
|
||||||
crypto.pbkdf2('password', 'salt', 1, -1, 'sha256', common.fail);
|
crypto.pbkdf2('password', 'salt', 1, -1, 'sha256', common.mustNotCall());
|
||||||
}, /^TypeError: Bad key length$/);
|
}, /^TypeError: Bad key length$/);
|
||||||
|
|
||||||
// Should not work with key length that does not fit into 32 signed bits
|
// Should not work with key length that does not fit into 32 signed bits
|
||||||
assert.throws(function() {
|
assert.throws(function() {
|
||||||
crypto.pbkdf2('password', 'salt', 1, 4073741824, 'sha256', common.fail);
|
crypto.pbkdf2('password', 'salt', 1, 4073741824, 'sha256',
|
||||||
|
common.mustNotCall());
|
||||||
}, /^TypeError: Bad key length$/);
|
}, /^TypeError: Bad key length$/);
|
||||||
|
|
||||||
// Should not get FATAL ERROR with empty password and salt
|
// Should not get FATAL ERROR with empty password and salt
|
||||||
|
@ -41,7 +41,7 @@ server.listen(0, common.mustCall(() => {
|
|||||||
}, common.mustCall(() => {
|
}, common.mustCall(() => {
|
||||||
verify();
|
verify();
|
||||||
}))
|
}))
|
||||||
.on('error', common.fail)
|
.on('error', common.mustNotCall())
|
||||||
.on('close', common.mustCall(() => {
|
.on('close', common.mustCall(() => {
|
||||||
server.close();
|
server.close();
|
||||||
})).resume();
|
})).resume();
|
||||||
|
@ -6,7 +6,7 @@ const dgram = require('dgram');
|
|||||||
// IPv4 Test
|
// IPv4 Test
|
||||||
const socket_ipv4 = dgram.createSocket('udp4');
|
const socket_ipv4 = dgram.createSocket('udp4');
|
||||||
|
|
||||||
socket_ipv4.on('listening', common.fail);
|
socket_ipv4.on('listening', common.mustNotCall());
|
||||||
|
|
||||||
socket_ipv4.on('error', common.mustCall(function(e) {
|
socket_ipv4.on('error', common.mustCall(function(e) {
|
||||||
assert.strictEqual(e.port, undefined);
|
assert.strictEqual(e.port, undefined);
|
||||||
@ -21,7 +21,7 @@ socket_ipv4.bind(0, '1.1.1.1');
|
|||||||
// IPv6 Test
|
// IPv6 Test
|
||||||
const socket_ipv6 = dgram.createSocket('udp6');
|
const socket_ipv6 = dgram.createSocket('udp6');
|
||||||
|
|
||||||
socket_ipv6.on('listening', common.fail);
|
socket_ipv6.on('listening', common.mustNotCall());
|
||||||
|
|
||||||
socket_ipv6.on('error', common.mustCall(function(e) {
|
socket_ipv6.on('error', common.mustCall(function(e) {
|
||||||
// EAFNOSUPPORT or EPROTONOSUPPORT means IPv6 is disabled on this system.
|
// EAFNOSUPPORT or EPROTONOSUPPORT means IPv6 is disabled on this system.
|
||||||
|
@ -6,4 +6,4 @@ const s = dgram.createSocket('udp4');
|
|||||||
s.bind();
|
s.bind();
|
||||||
s.unref();
|
s.unref();
|
||||||
|
|
||||||
setTimeout(common.fail, 1000).unref();
|
setTimeout(common.mustNotCall(), 1000).unref();
|
||||||
|
@ -8,7 +8,7 @@ const http = require('http');
|
|||||||
const a = domain.create();
|
const a = domain.create();
|
||||||
a.enter(); // this will be our "root" domain
|
a.enter(); // this will be our "root" domain
|
||||||
|
|
||||||
a.on('error', common.fail);
|
a.on('error', common.mustNotCall());
|
||||||
|
|
||||||
const server = http.createServer((req, res) => {
|
const server = http.createServer((req, res) => {
|
||||||
// child domain of a.
|
// child domain of a.
|
||||||
|
@ -20,7 +20,7 @@ function listener2() {}
|
|||||||
{
|
{
|
||||||
const ee = new EventEmitter();
|
const ee = new EventEmitter();
|
||||||
ee.on('hello', listener1);
|
ee.on('hello', listener1);
|
||||||
ee.on('removeListener', common.fail);
|
ee.on('removeListener', common.mustNotCall());
|
||||||
ee.removeListener('hello', listener2);
|
ee.removeListener('hello', listener2);
|
||||||
assert.deepStrictEqual([listener1], ee.listeners('hello'));
|
assert.deepStrictEqual([listener1], ee.listeners('hello'));
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,9 @@ const spawn = require('child_process').spawn;
|
|||||||
|
|
||||||
// spawn a node child process in "interactive" mode (force the repl)
|
// spawn a node child process in "interactive" mode (force the repl)
|
||||||
const cp = spawn(process.execPath, ['-i']);
|
const cp = spawn(process.execPath, ['-i']);
|
||||||
const timeoutId = setTimeout(function() {
|
// give node + the repl 5 seconds to start
|
||||||
common.fail('timeout!');
|
const timeoutId = setTimeout(common.mustNotCall(),
|
||||||
}, common.platformTimeout(5000)); // give node + the repl 5 seconds to start
|
common.platformTimeout(5000));
|
||||||
|
|
||||||
cp.stdout.setEncoding('utf8');
|
cp.stdout.setEncoding('utf8');
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ fs.access(readOnlyFile, fs.W_OK, common.mustCall((err) => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
assert.throws(() => {
|
assert.throws(() => {
|
||||||
fs.access(100, fs.F_OK, () => { common.fail('callback should not run'); });
|
fs.access(100, fs.F_OK, common.mustNotCall());
|
||||||
}, /^TypeError: path must be a string or Buffer$/);
|
}, /^TypeError: path must be a string or Buffer$/);
|
||||||
|
|
||||||
assert.throws(() => {
|
assert.throws(() => {
|
||||||
|
@ -43,10 +43,10 @@ check(fs.symlink, fs.symlinkSync, 'foo\u0000bar', 'foobar');
|
|||||||
check(fs.symlink, fs.symlinkSync, 'foobar', 'foo\u0000bar');
|
check(fs.symlink, fs.symlinkSync, 'foobar', 'foo\u0000bar');
|
||||||
check(fs.truncate, fs.truncateSync, 'foo\u0000bar');
|
check(fs.truncate, fs.truncateSync, 'foo\u0000bar');
|
||||||
check(fs.unlink, fs.unlinkSync, 'foo\u0000bar');
|
check(fs.unlink, fs.unlinkSync, 'foo\u0000bar');
|
||||||
check(null, fs.unwatchFile, 'foo\u0000bar', common.fail);
|
check(null, fs.unwatchFile, 'foo\u0000bar', common.mustNotCall());
|
||||||
check(fs.utimes, fs.utimesSync, 'foo\u0000bar', 0, 0);
|
check(fs.utimes, fs.utimesSync, 'foo\u0000bar', 0, 0);
|
||||||
check(null, fs.watch, 'foo\u0000bar', common.fail);
|
check(null, fs.watch, 'foo\u0000bar', common.mustNotCall());
|
||||||
check(null, fs.watchFile, 'foo\u0000bar', common.fail);
|
check(null, fs.watchFile, 'foo\u0000bar', common.mustNotCall());
|
||||||
check(fs.writeFile, fs.writeFileSync, 'foo\u0000bar');
|
check(fs.writeFile, fs.writeFileSync, 'foo\u0000bar');
|
||||||
|
|
||||||
const fileUrl = new URL('file:///C:/foo\u0000bar');
|
const fileUrl = new URL('file:///C:/foo\u0000bar');
|
||||||
|
@ -38,5 +38,5 @@ fs.read = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
stream.on('data', (buf) => {
|
stream.on('data', (buf) => {
|
||||||
stream.on('data', () => common.fail("no more 'data' events should follow"));
|
stream.on('data', common.mustNotCall("no more 'data' events should follow"));
|
||||||
});
|
});
|
||||||
|
@ -3,7 +3,7 @@ const common = require('../common');
|
|||||||
const http = require('http');
|
const http = require('http');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
|
||||||
const server = http.createServer(common.fail);
|
const server = http.createServer(common.mustNotCall());
|
||||||
|
|
||||||
server.listen(0, function() {
|
server.listen(0, function() {
|
||||||
const req = http.request({
|
const req = http.request({
|
||||||
|
@ -24,7 +24,7 @@ server.listen(0, common.mustCall(() => {
|
|||||||
|
|
||||||
http.get({agent, port}, (res) => res.resume());
|
http.get({agent, port}, (res) => res.resume());
|
||||||
|
|
||||||
const req = http.get({agent, port}, common.fail);
|
const req = http.get({agent, port}, common.mustNotCall());
|
||||||
req.abort();
|
req.abort();
|
||||||
|
|
||||||
http.get({agent, port}, common.mustCall((res) => {
|
http.get({agent, port}, common.mustCall((res) => {
|
||||||
|
@ -3,10 +3,10 @@ const common = require('../common');
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const http = require('http');
|
const http = require('http');
|
||||||
|
|
||||||
const server1 = http.createServer(common.fail);
|
const server1 = http.createServer(common.mustNotCall());
|
||||||
server1.listen(0, '127.0.0.1', common.mustCall(function() {
|
server1.listen(0, '127.0.0.1', common.mustCall(function() {
|
||||||
const server2 = http.createServer(common.fail);
|
const server2 = http.createServer(common.mustNotCall());
|
||||||
server2.listen(this.address().port, '127.0.0.1', common.fail);
|
server2.listen(this.address().port, '127.0.0.1', common.mustNotCall());
|
||||||
|
|
||||||
server2.on('error', common.mustCall(function(e) {
|
server2.on('error', common.mustCall(function(e) {
|
||||||
assert.strictEqual(e.code, 'EADDRINUSE');
|
assert.strictEqual(e.code, 'EADDRINUSE');
|
||||||
|
@ -8,7 +8,7 @@ const server = http.createServer(function(req, res) {
|
|||||||
server.listen(0, common.mustCall(function() {
|
server.listen(0, common.mustCall(function() {
|
||||||
const req = http.request({
|
const req = http.request({
|
||||||
port: this.address().port
|
port: this.address().port
|
||||||
}, common.fail);
|
}, common.mustNotCall());
|
||||||
|
|
||||||
req.on('abort', common.mustCall(function() {
|
req.on('abort', common.mustCall(function() {
|
||||||
server.close();
|
server.close();
|
||||||
|
@ -3,7 +3,7 @@ const common = require('../common');
|
|||||||
const http = require('http');
|
const http = require('http');
|
||||||
const net = require('net');
|
const net = require('net');
|
||||||
|
|
||||||
const server = http.createServer(common.fail);
|
const server = http.createServer(common.mustNotCall());
|
||||||
|
|
||||||
server.listen(0, common.mustCall(() => {
|
server.listen(0, common.mustCall(() => {
|
||||||
const req = http.get({
|
const req = http.get({
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const http = require('http');
|
const http = require('http');
|
||||||
|
|
||||||
const server = http.createServer(common.fail);
|
const server = http.createServer(common.mustNotCall());
|
||||||
|
|
||||||
class Agent extends http.Agent {
|
class Agent extends http.Agent {
|
||||||
createConnection(options, oncreate) {
|
createConnection(options, oncreate) {
|
||||||
|
@ -18,7 +18,7 @@ const server = http.createServer((req, res) => {
|
|||||||
function test() {
|
function test() {
|
||||||
function fail(input) {
|
function fail(input) {
|
||||||
assert.throws(() => {
|
assert.throws(() => {
|
||||||
http.request({ method: input, path: '/' }, common.fail);
|
http.request({ method: input, path: '/' }, common.mustNotCall());
|
||||||
}, /^TypeError: Method must be a string$/);
|
}, /^TypeError: Method must be a string$/);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,9 +17,7 @@ server.listen(0, () => {
|
|||||||
// The callback should not be called because the server is sending
|
// The callback should not be called because the server is sending
|
||||||
// both a Content-Length header and a Transfer-Encoding: chunked
|
// both a Content-Length header and a Transfer-Encoding: chunked
|
||||||
// header, which is a violation of the HTTP spec.
|
// header, which is a violation of the HTTP spec.
|
||||||
const req = http.get({port: server.address().port}, (res) => {
|
const req = http.get({port: server.address().port}, common.mustNotCall());
|
||||||
common.fail('callback should not be called');
|
|
||||||
});
|
|
||||||
req.on('error', common.mustCall((err) => {
|
req.on('error', common.mustCall((err) => {
|
||||||
assert(/^Parse Error/.test(err.message));
|
assert(/^Parse Error/.test(err.message));
|
||||||
assert.strictEqual(err.code, 'HPE_UNEXPECTED_CONTENT_LENGTH');
|
assert.strictEqual(err.code, 'HPE_UNEXPECTED_CONTENT_LENGTH');
|
||||||
|
@ -16,9 +16,7 @@ const server = net.createServer((socket) => {
|
|||||||
server.listen(0, () => {
|
server.listen(0, () => {
|
||||||
// The callback should not be called because the server is sending a
|
// The callback should not be called because the server is sending a
|
||||||
// header field that ends only in \r with no following \n
|
// header field that ends only in \r with no following \n
|
||||||
const req = http.get({port: server.address().port}, (res) => {
|
const req = http.get({port: server.address().port}, common.mustNotCall());
|
||||||
common.fail('callback should not be called');
|
|
||||||
});
|
|
||||||
req.on('error', common.mustCall((err) => {
|
req.on('error', common.mustCall((err) => {
|
||||||
assert(/^Parse Error/.test(err.message));
|
assert(/^Parse Error/.test(err.message));
|
||||||
assert.strictEqual(err.code, 'HPE_LF_EXPECTED');
|
assert.strictEqual(err.code, 'HPE_LF_EXPECTED');
|
||||||
|
@ -5,6 +5,6 @@ const http = require('http');
|
|||||||
|
|
||||||
for (let i = 0; i <= 32; i += 1) {
|
for (let i = 0; i <= 32; i += 1) {
|
||||||
const path = 'bad' + String.fromCharCode(i) + 'path';
|
const path = 'bad' + String.fromCharCode(i) + 'path';
|
||||||
assert.throws(() => http.get({ path }, common.fail),
|
assert.throws(() => http.get({ path }, common.mustNotCall()),
|
||||||
/contains unescaped characters/);
|
/contains unescaped characters/);
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ server.listen(0, options.host, common.mustCall(onListen));
|
|||||||
// do a GET request, expect it to fail
|
// do a GET request, expect it to fail
|
||||||
function onListen() {
|
function onListen() {
|
||||||
options.port = this.address().port;
|
options.port = this.address().port;
|
||||||
const req = http.request(options, common.fail);
|
const req = http.request(options, common.mustNotCall());
|
||||||
req.on('error', common.mustCall(function(err) {
|
req.on('error', common.mustCall(function(err) {
|
||||||
assert.strictEqual(err.code, 'ECONNRESET');
|
assert.strictEqual(err.code, 'ECONNRESET');
|
||||||
}));
|
}));
|
||||||
|
@ -3,7 +3,7 @@ const common = require('../common');
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const http = require('http');
|
const http = require('http');
|
||||||
|
|
||||||
const server = http.createServer(common.fail);
|
const server = http.createServer(common.mustNotCall());
|
||||||
server.on('connect', common.mustCall(function(req, socket, firstBodyChunk) {
|
server.on('connect', common.mustCall(function(req, socket, firstBodyChunk) {
|
||||||
assert.strictEqual(req.method, 'CONNECT');
|
assert.strictEqual(req.method, 'CONNECT');
|
||||||
assert.strictEqual(req.url, 'example.com:443');
|
assert.strictEqual(req.url, 'example.com:443');
|
||||||
@ -31,7 +31,7 @@ server.listen(0, common.mustCall(function() {
|
|||||||
port: this.address().port,
|
port: this.address().port,
|
||||||
method: 'CONNECT',
|
method: 'CONNECT',
|
||||||
path: 'example.com:443'
|
path: 'example.com:443'
|
||||||
}, common.fail);
|
}, common.mustNotCall());
|
||||||
|
|
||||||
req.on('close', common.mustCall(function() { }));
|
req.on('close', common.mustCall(function() { }));
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ const common = require('../common');
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const http = require('http');
|
const http = require('http');
|
||||||
|
|
||||||
const server = http.createServer(common.fail);
|
const server = http.createServer(common.mustNotCall());
|
||||||
|
|
||||||
server.on('connect', common.mustCall((req, socket, firstBodyChunk) => {
|
server.on('connect', common.mustCall((req, socket, firstBodyChunk) => {
|
||||||
assert.strictEqual(req.method, 'CONNECT');
|
assert.strictEqual(req.method, 'CONNECT');
|
||||||
@ -26,7 +26,7 @@ server.listen(0, common.mustCall(function() {
|
|||||||
port: this.address().port,
|
port: this.address().port,
|
||||||
method: 'CONNECT',
|
method: 'CONNECT',
|
||||||
path: 'google.com:443'
|
path: 'google.com:443'
|
||||||
}, common.fail);
|
}, common.mustNotCall());
|
||||||
|
|
||||||
req.on('close', common.mustCall(() => {}));
|
req.on('close', common.mustCall(() => {}));
|
||||||
|
|
||||||
|
@ -53,12 +53,8 @@ server.listen(0, function() {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
req.on('response', function(res) {
|
req.on('response', function(res) {
|
||||||
res.on('data', function(chunk) {
|
res.on('data', common.mustNotCall('Should not receive response data'));
|
||||||
common.fail('Should not receive response data');
|
res.on('end', common.mustNotCall('Should not receive response end'));
|
||||||
});
|
|
||||||
res.on('end', function() {
|
|
||||||
common.fail('Should not receive response end');
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
write();
|
write();
|
||||||
|
@ -7,7 +7,7 @@ const assert = require('assert');
|
|||||||
// The callback should never be invoked because the server
|
// The callback should never be invoked because the server
|
||||||
// should respond with a 400 Client Error when a double
|
// should respond with a 400 Client Error when a double
|
||||||
// Content-Length header is received.
|
// Content-Length header is received.
|
||||||
const server = http.createServer(common.fail);
|
const server = http.createServer(common.mustNotCall());
|
||||||
server.on('clientError', common.mustCall((err, socket) => {
|
server.on('clientError', common.mustCall((err, socket) => {
|
||||||
assert(/^Parse Error/.test(err.message));
|
assert(/^Parse Error/.test(err.message));
|
||||||
assert.strictEqual(err.code, 'HPE_UNEXPECTED_CONTENT_LENGTH');
|
assert.strictEqual(err.code, 'HPE_UNEXPECTED_CONTENT_LENGTH');
|
||||||
@ -18,11 +18,8 @@ server.listen(0, () => {
|
|||||||
const req = http.get({
|
const req = http.get({
|
||||||
port: server.address().port,
|
port: server.address().port,
|
||||||
// Send two content-length header values.
|
// Send two content-length header values.
|
||||||
headers: {'Content-Length': [1, 2]}},
|
headers: {'Content-Length': [1, 2]}
|
||||||
(res) => {
|
}, common.mustNotCall('an error should have occurred'));
|
||||||
common.fail('an error should have occurred');
|
|
||||||
}
|
|
||||||
);
|
|
||||||
req.on('error', common.mustCall(() => {
|
req.on('error', common.mustCall(() => {
|
||||||
server.close();
|
server.close();
|
||||||
}));
|
}));
|
||||||
|
@ -38,7 +38,7 @@ function testHttp() {
|
|||||||
host: 'localhost',
|
host: 'localhost',
|
||||||
port: httpServer.address().port,
|
port: httpServer.address().port,
|
||||||
rejectUnauthorized: false
|
rejectUnauthorized: false
|
||||||
}, cb).on('error', common.fail);
|
}, cb).on('error', common.mustNotCall());
|
||||||
|
|
||||||
http.request({
|
http.request({
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
@ -46,7 +46,7 @@ function testHttp() {
|
|||||||
host: 'localhost',
|
host: 'localhost',
|
||||||
port: httpServer.address().port,
|
port: httpServer.address().port,
|
||||||
rejectUnauthorized: false
|
rejectUnauthorized: false
|
||||||
}, cb).on('error', common.fail).end();
|
}, cb).on('error', common.mustNotCall()).end();
|
||||||
|
|
||||||
http.request({
|
http.request({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@ -54,7 +54,7 @@ function testHttp() {
|
|||||||
host: 'localhost',
|
host: 'localhost',
|
||||||
port: httpServer.address().port,
|
port: httpServer.address().port,
|
||||||
rejectUnauthorized: false
|
rejectUnauthorized: false
|
||||||
}, cb).on('error', common.fail).end();
|
}, cb).on('error', common.mustNotCall()).end();
|
||||||
|
|
||||||
http.request({
|
http.request({
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
@ -62,7 +62,7 @@ function testHttp() {
|
|||||||
host: 'localhost',
|
host: 'localhost',
|
||||||
port: httpServer.address().port,
|
port: httpServer.address().port,
|
||||||
rejectUnauthorized: false
|
rejectUnauthorized: false
|
||||||
}, cb).on('error', common.fail).end();
|
}, cb).on('error', common.mustNotCall()).end();
|
||||||
|
|
||||||
http.request({
|
http.request({
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
@ -70,6 +70,6 @@ function testHttp() {
|
|||||||
host: 'localhost',
|
host: 'localhost',
|
||||||
port: httpServer.address().port,
|
port: httpServer.address().port,
|
||||||
rejectUnauthorized: false
|
rejectUnauthorized: false
|
||||||
}, cb).on('error', common.fail).end();
|
}, cb).on('error', common.mustNotCall()).end();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ function newParser(type) {
|
|||||||
parser[kOnHeadersComplete] = function(info) {
|
parser[kOnHeadersComplete] = function(info) {
|
||||||
};
|
};
|
||||||
|
|
||||||
parser[kOnBody] = common.fail;
|
parser[kOnBody] = common.mustNotCall('kOnBody should not be called');
|
||||||
|
|
||||||
parser[kOnMessageComplete] = function() {
|
parser[kOnMessageComplete] = function() {
|
||||||
};
|
};
|
||||||
|
@ -38,7 +38,7 @@ function parent() {
|
|||||||
// may still be asked to process more requests if they were read before
|
// may still be asked to process more requests if they were read before
|
||||||
// the flood-prevention mechanism activated.
|
// the flood-prevention mechanism activated.
|
||||||
setImmediate(() => {
|
setImmediate(() => {
|
||||||
req.socket.on('data', () => common.fail('Unexpected data received'));
|
req.socket.on('data', common.mustNotCall('Unexpected data received'));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
backloggedReqs++;
|
backloggedReqs++;
|
||||||
|
@ -9,9 +9,7 @@ const reqstr = 'POST / HTTP/1.1\r\n' +
|
|||||||
'Content-Length: 1\r\n' +
|
'Content-Length: 1\r\n' +
|
||||||
'Transfer-Encoding: chunked\r\n\r\n';
|
'Transfer-Encoding: chunked\r\n\r\n';
|
||||||
|
|
||||||
const server = http.createServer((req, res) => {
|
const server = http.createServer(common.mustNotCall());
|
||||||
common.fail('callback should not be invoked');
|
|
||||||
});
|
|
||||||
server.on('clientError', common.mustCall((err) => {
|
server.on('clientError', common.mustCall((err) => {
|
||||||
assert(/^Parse Error/.test(err.message));
|
assert(/^Parse Error/.test(err.message));
|
||||||
assert.strictEqual(err.code, 'HPE_UNEXPECTED_CONTENT_LENGTH');
|
assert.strictEqual(err.code, 'HPE_UNEXPECTED_CONTENT_LENGTH');
|
||||||
|
@ -11,9 +11,7 @@ const str = 'GET / HTTP/1.1\r\n' +
|
|||||||
'\r\n';
|
'\r\n';
|
||||||
|
|
||||||
|
|
||||||
const server = http.createServer((req, res) => {
|
const server = http.createServer(common.mustNotCall());
|
||||||
common.fail('this should not be called');
|
|
||||||
});
|
|
||||||
server.on('clientError', common.mustCall((err) => {
|
server.on('clientError', common.mustCall((err) => {
|
||||||
assert(/^Parse Error/.test(err.message));
|
assert(/^Parse Error/.test(err.message));
|
||||||
assert.strictEqual(err.code, 'HPE_LF_EXPECTED');
|
assert.strictEqual(err.code, 'HPE_LF_EXPECTED');
|
||||||
@ -21,9 +19,7 @@ server.on('clientError', common.mustCall((err) => {
|
|||||||
}));
|
}));
|
||||||
server.listen(0, () => {
|
server.listen(0, () => {
|
||||||
const client = net.connect({port: server.address().port}, () => {
|
const client = net.connect({port: server.address().port}, () => {
|
||||||
client.on('data', (chunk) => {
|
client.on('data', common.mustNotCall());
|
||||||
common.fail('this should not be called');
|
|
||||||
});
|
|
||||||
client.on('end', common.mustCall(() => {
|
client.on('end', common.mustCall(() => {
|
||||||
server.close();
|
server.close();
|
||||||
}));
|
}));
|
||||||
|
@ -2,10 +2,7 @@
|
|||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const http = require('http');
|
const http = require('http');
|
||||||
|
|
||||||
const testServer = http.createServer((req, res) => {
|
const testServer = http.createServer(common.mustNotCall());
|
||||||
common.fail('Should not be called');
|
|
||||||
res.end();
|
|
||||||
});
|
|
||||||
testServer.on('connect', common.mustCall((req, socket, head) => {
|
testServer.on('connect', common.mustCall((req, socket, head) => {
|
||||||
socket.write('HTTP/1.1 200 Connection Established' + '\r\n' +
|
socket.write('HTTP/1.1 200 Connection Established' + '\r\n' +
|
||||||
'Proxy-agent: Node-Proxy' + '\r\n' +
|
'Proxy-agent: Node-Proxy' + '\r\n' +
|
||||||
|
@ -53,7 +53,7 @@ server.on('listening', function() {
|
|||||||
c.on('connect', function() {
|
c.on('connect', function() {
|
||||||
outstanding_reqs++;
|
outstanding_reqs++;
|
||||||
c.write('GET / HTTP/1.1\r\n\r\n');
|
c.write('GET / HTTP/1.1\r\n\r\n');
|
||||||
tid = setTimeout(common.fail, 2000, 'Couldn\'t find last chunk.');
|
tid = setTimeout(common.mustNotCall(), 2000, 'Couldn\'t find last chunk.');
|
||||||
});
|
});
|
||||||
|
|
||||||
c.on('data', function(chunk) {
|
c.on('data', function(chunk) {
|
||||||
|
@ -81,6 +81,6 @@ function third(server) {
|
|||||||
assert(!req.socket.isSessionReused());
|
assert(!req.socket.isSessionReused());
|
||||||
server.close();
|
server.close();
|
||||||
});
|
});
|
||||||
req.on('error', common.fail);
|
req.on('error', common.mustNotCall());
|
||||||
req.end();
|
req.end();
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ function authorized() {
|
|||||||
port: server.address().port,
|
port: server.address().port,
|
||||||
rejectUnauthorized: true,
|
rejectUnauthorized: true,
|
||||||
ca: [fs.readFileSync(path.join(common.fixturesDir, 'keys/ca2-cert.pem'))]
|
ca: [fs.readFileSync(path.join(common.fixturesDir, 'keys/ca2-cert.pem'))]
|
||||||
}, common.fail);
|
}, common.mustNotCall());
|
||||||
req.on('error', function(err) {
|
req.on('error', function(err) {
|
||||||
override();
|
override();
|
||||||
});
|
});
|
||||||
|
@ -44,7 +44,7 @@ function rejectUnauthorized() {
|
|||||||
port: server.address().port
|
port: server.address().port
|
||||||
};
|
};
|
||||||
options.agent = new https.Agent(options);
|
options.agent = new https.Agent(options);
|
||||||
const req = https.request(options, common.fail);
|
const req = https.request(options, common.mustNotCall());
|
||||||
req.on('error', function(err) {
|
req.on('error', function(err) {
|
||||||
authorized();
|
authorized();
|
||||||
});
|
});
|
||||||
@ -62,6 +62,6 @@ function authorized() {
|
|||||||
assert(req.socket.authorized);
|
assert(req.socket.authorized);
|
||||||
server.close();
|
server.close();
|
||||||
});
|
});
|
||||||
req.on('error', common.fail);
|
req.on('error', common.mustNotCall());
|
||||||
req.end();
|
req.end();
|
||||||
}
|
}
|
||||||
|
@ -10,10 +10,10 @@ if (!common.hasCrypto) {
|
|||||||
}
|
}
|
||||||
const https = require('https');
|
const https = require('https');
|
||||||
|
|
||||||
const server = http.createServer(common.fail);
|
const server = http.createServer(common.mustNotCall());
|
||||||
|
|
||||||
server.listen(0, common.mustCall(function() {
|
server.listen(0, common.mustCall(function() {
|
||||||
const req = https.get({ port: this.address().port }, common.fail);
|
const req = https.get({ port: this.address().port }, common.mustNotCall());
|
||||||
|
|
||||||
req.on('error', common.mustCall(function(e) {
|
req.on('error', common.mustCall(function(e) {
|
||||||
console.log('Got expected error: ', e.message);
|
console.log('Got expected error: ', e.message);
|
||||||
|
@ -97,7 +97,7 @@ test(function serverResponseTimeout(cb) {
|
|||||||
test(function serverRequestNotTimeoutAfterEnd(cb) {
|
test(function serverRequestNotTimeoutAfterEnd(cb) {
|
||||||
function handler(req, res) {
|
function handler(req, res) {
|
||||||
// just do nothing, we should get a timeout event.
|
// just do nothing, we should get a timeout event.
|
||||||
req.setTimeout(50, common.fail);
|
req.setTimeout(50, common.mustNotCall());
|
||||||
res.on('timeout', common.mustCall(function(socket) {}));
|
res.on('timeout', common.mustCall(function(socket) {}));
|
||||||
}
|
}
|
||||||
const server = https.createServer(serverOptions, common.mustCall(handler));
|
const server = https.createServer(serverOptions, common.mustCall(handler));
|
||||||
@ -147,8 +147,8 @@ test(function serverResponseTimeoutWithPipeline(cb) {
|
|||||||
test(function idleTimeout(cb) {
|
test(function idleTimeout(cb) {
|
||||||
const server = https.createServer(serverOptions,
|
const server = https.createServer(serverOptions,
|
||||||
common.mustCall(function(req, res) {
|
common.mustCall(function(req, res) {
|
||||||
req.on('timeout', common.fail);
|
req.on('timeout', common.mustNotCall());
|
||||||
res.on('timeout', common.fail);
|
res.on('timeout', common.mustNotCall());
|
||||||
res.end();
|
res.end();
|
||||||
}));
|
}));
|
||||||
server.setTimeout(50, common.mustCall(function(socket) {
|
server.setTimeout(50, common.mustCall(function(socket) {
|
||||||
|
@ -17,7 +17,7 @@ const options = {
|
|||||||
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
|
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
|
||||||
};
|
};
|
||||||
|
|
||||||
const server = https.createServer(options, common.fail);
|
const server = https.createServer(options, common.mustNotCall());
|
||||||
|
|
||||||
server.on('secureConnection', function(cleartext) {
|
server.on('secureConnection', function(cleartext) {
|
||||||
const s = cleartext.setTimeout(50, function() {
|
const s = cleartext.setTimeout(50, function() {
|
||||||
|
@ -17,7 +17,7 @@ const options = {
|
|||||||
handshakeTimeout: 50
|
handshakeTimeout: 50
|
||||||
};
|
};
|
||||||
|
|
||||||
const server = https.createServer(options, common.fail);
|
const server = https.createServer(options, common.mustNotCall());
|
||||||
|
|
||||||
server.on('clientError', common.mustCall(function(err, conn) {
|
server.on('clientError', common.mustCall(function(err, conn) {
|
||||||
// Don't hesitate to update the asserts if the internal structure of
|
// Don't hesitate to update the asserts if the internal structure of
|
||||||
|
@ -3,9 +3,9 @@ const common = require('../common');
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const net = require('net');
|
const net = require('net');
|
||||||
|
|
||||||
net.createServer(common.fail).listen({fd: 2})
|
net.createServer(common.mustNotCall()).listen({fd: 2})
|
||||||
.on('error', common.mustCall(onError));
|
.on('error', common.mustCall(onError));
|
||||||
net.createServer(common.fail).listen({fd: 42})
|
net.createServer(common.mustNotCall()).listen({fd: 42})
|
||||||
.on('error', common.mustCall(onError));
|
.on('error', common.mustCall(onError));
|
||||||
|
|
||||||
function onError(ex) {
|
function onError(ex) {
|
||||||
|
@ -3,8 +3,8 @@ const common = require('../common');
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const net = require('net');
|
const net = require('net');
|
||||||
const fp = '/blah/fadfa';
|
const fp = '/blah/fadfa';
|
||||||
const server = net.createServer(common.fail);
|
const server = net.createServer(common.mustNotCall());
|
||||||
server.listen(fp, common.fail);
|
server.listen(fp, common.mustNotCall());
|
||||||
server.on('error', common.mustCall(function(e) {
|
server.on('error', common.mustCall(function(e) {
|
||||||
assert.strictEqual(e.address, fp);
|
assert.strictEqual(e.address, fp);
|
||||||
}));
|
}));
|
||||||
|
@ -3,8 +3,8 @@ const common = require('../common');
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const net = require('net');
|
const net = require('net');
|
||||||
|
|
||||||
const server = net.createServer(common.fail);
|
const server = net.createServer(common.mustNotCall());
|
||||||
server.listen(1, '1.1.1.1', common.fail);
|
server.listen(1, '1.1.1.1', common.mustNotCall());
|
||||||
server.on('error', common.mustCall(function(e) {
|
server.on('error', common.mustCall(function(e) {
|
||||||
assert.strictEqual(e.address, '1.1.1.1');
|
assert.strictEqual(e.address, '1.1.1.1');
|
||||||
assert.strictEqual(e.port, 1);
|
assert.strictEqual(e.port, 1);
|
||||||
|
@ -5,7 +5,7 @@ const assert = require('assert');
|
|||||||
const fp = '/tmp/fadagagsdfgsdf';
|
const fp = '/tmp/fadagagsdfgsdf';
|
||||||
const c = net.connect(fp);
|
const c = net.connect(fp);
|
||||||
|
|
||||||
c.on('connect', common.fail);
|
c.on('connect', common.mustNotCall());
|
||||||
|
|
||||||
c.on('error', common.mustCall(function(e) {
|
c.on('error', common.mustCall(function(e) {
|
||||||
assert.strictEqual(e.code, 'ENOENT');
|
assert.strictEqual(e.code, 'ENOENT');
|
||||||
|
@ -5,7 +5,7 @@ const assert = require('assert');
|
|||||||
|
|
||||||
const c = net.createConnection(common.PORT, '***');
|
const c = net.createConnection(common.PORT, '***');
|
||||||
|
|
||||||
c.on('connect', common.fail);
|
c.on('connect', common.mustNotCall());
|
||||||
|
|
||||||
c.on('error', common.mustCall(function(e) {
|
c.on('error', common.mustCall(function(e) {
|
||||||
assert.strictEqual(e.code, 'ENOTFOUND');
|
assert.strictEqual(e.code, 'ENOTFOUND');
|
||||||
|
@ -5,7 +5,7 @@ const assert = require('assert');
|
|||||||
|
|
||||||
const c = net.createConnection(common.PORT);
|
const c = net.createConnection(common.PORT);
|
||||||
|
|
||||||
c.on('connect', common.fail);
|
c.on('connect', common.mustNotCall());
|
||||||
|
|
||||||
c.on('error', common.mustCall(function(e) {
|
c.on('error', common.mustCall(function(e) {
|
||||||
assert.strictEqual(e.code, 'ECONNREFUSED');
|
assert.strictEqual(e.code, 'ECONNREFUSED');
|
||||||
|
@ -3,10 +3,10 @@ const common = require('../common');
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const net = require('net');
|
const net = require('net');
|
||||||
|
|
||||||
const server1 = net.createServer(common.fail);
|
const server1 = net.createServer(common.mustNotCall());
|
||||||
server1.listen(0, '127.0.0.1', common.mustCall(function() {
|
server1.listen(0, '127.0.0.1', common.mustCall(function() {
|
||||||
const server2 = net.createServer(common.fail);
|
const server2 = net.createServer(common.mustNotCall());
|
||||||
server2.listen(this.address().port, '127.0.0.1', common.fail);
|
server2.listen(this.address().port, '127.0.0.1', common.mustNotCall());
|
||||||
|
|
||||||
server2.on('error', common.mustCall(function(e) {
|
server2.on('error', common.mustCall(function(e) {
|
||||||
assert.strictEqual(e.code, 'EADDRINUSE');
|
assert.strictEqual(e.code, 'EADDRINUSE');
|
||||||
|
@ -7,9 +7,7 @@ const assert = require('assert');
|
|||||||
// Hopefully nothing is running on common.PORT
|
// Hopefully nothing is running on common.PORT
|
||||||
const c = net.createConnection(common.PORT);
|
const c = net.createConnection(common.PORT);
|
||||||
|
|
||||||
c.on('connect', function() {
|
c.on('connect', common.mustNotCall());
|
||||||
common.fail('connected?!');
|
|
||||||
});
|
|
||||||
|
|
||||||
c.on('error', common.mustCall(function(e) {
|
c.on('error', common.mustCall(function(e) {
|
||||||
console.error('couldn\'t connect.');
|
console.error('couldn\'t connect.');
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const net = require('net');
|
const net = require('net');
|
||||||
|
|
||||||
const socket = net.connect(common.PORT, common.localhostIPv4, common.fail);
|
const socket = net.connect(common.PORT, common.localhostIPv4,
|
||||||
socket.on('error', common.fail);
|
common.mustNotCall());
|
||||||
|
socket.on('error', common.mustNotCall());
|
||||||
socket.destroy();
|
socket.destroy();
|
||||||
|
@ -8,7 +8,5 @@ net.createServer(function(conn) {
|
|||||||
}).listen(0, function() {
|
}).listen(0, function() {
|
||||||
net.connect(this.address().port, 'localhost').pause();
|
net.connect(this.address().port, 'localhost').pause();
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(common.mustNotCall('expected to exit'), 1000).unref();
|
||||||
common.fail('expected to exit');
|
|
||||||
}, 1000).unref();
|
|
||||||
}).unref();
|
}).unref();
|
||||||
|
@ -10,7 +10,8 @@ function check(addressType) {
|
|||||||
|
|
||||||
const address = addressType === 4 ? '127.0.0.1' : '::1';
|
const address = addressType === 4 ? '127.0.0.1' : '::1';
|
||||||
server.listen(0, address, function() {
|
server.listen(0, address, function() {
|
||||||
net.connect(this.address().port, address).on('lookup', common.fail);
|
net.connect(this.address().port, address)
|
||||||
|
.on('lookup', common.mustNotCall());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const net = require('net');
|
const net = require('net');
|
||||||
|
|
||||||
const server = net.createServer(common.fail);
|
const server = net.createServer(common.mustNotCall());
|
||||||
|
|
||||||
server.on('close', common.mustCall(function() {}));
|
server.on('close', common.mustCall(function() {}));
|
||||||
|
|
||||||
server.listen(0, common.fail);
|
server.listen(0, common.mustNotCall());
|
||||||
|
|
||||||
server.close('bad argument');
|
server.close('bad argument');
|
||||||
|
@ -4,6 +4,6 @@ const net = require('net');
|
|||||||
|
|
||||||
const server = net.createServer(function(socket) {
|
const server = net.createServer(function(socket) {
|
||||||
});
|
});
|
||||||
server.listen(0, common.fail);
|
server.listen(0, common.mustNotCall());
|
||||||
server.on('error', common.fail);
|
server.on('error', common.mustNotCall());
|
||||||
server.close();
|
server.close();
|
||||||
|
@ -4,5 +4,5 @@ const net = require('net');
|
|||||||
|
|
||||||
const server = net.createServer(function(socket) {
|
const server = net.createServer(function(socket) {
|
||||||
});
|
});
|
||||||
server.listen(1, '1.1.1.1', common.fail); // EACCESS or EADDRNOTAVAIL
|
server.listen(1, '1.1.1.1', common.mustNotCall()); // EACCESS or EADDRNOTAVAIL
|
||||||
server.on('error', common.mustCall(function(error) {}));
|
server.on('error', common.mustCall(function(error) {}));
|
||||||
|
@ -4,7 +4,7 @@ const assert = require('assert');
|
|||||||
const net = require('net');
|
const net = require('net');
|
||||||
|
|
||||||
// This should fail with an async EINVAL error, not throw an exception
|
// This should fail with an async EINVAL error, not throw an exception
|
||||||
net.createServer(common.fail)
|
net.createServer(common.mustNotCall())
|
||||||
.listen({fd: 0})
|
.listen({fd: 0})
|
||||||
.on('error', common.mustCall(function(e) {
|
.on('error', common.mustCall(function(e) {
|
||||||
assert(e instanceof Error);
|
assert(e instanceof Error);
|
||||||
|
@ -35,11 +35,11 @@ listenVariants.forEach((listenVariant, i) => {
|
|||||||
// skip this, because listen(port) can also be listen(path)
|
// skip this, because listen(port) can also be listen(path)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
assert.throws(() => listenVariant(port, common.fail),
|
assert.throws(() => listenVariant(port, common.mustNotCall()),
|
||||||
/"port" argument must be >= 0 and < 65536/i);
|
/"port" argument must be >= 0 and < 65536/i);
|
||||||
});
|
});
|
||||||
|
|
||||||
[null, true, false].forEach((port) =>
|
[null, true, false].forEach((port) =>
|
||||||
assert.throws(() => listenVariant(port, common.fail),
|
assert.throws(() => listenVariant(port, common.mustNotCall()),
|
||||||
/invalid listen argument/i));
|
/invalid listen argument/i));
|
||||||
});
|
});
|
||||||
|
@ -34,7 +34,7 @@ server.listen(0, function() {
|
|||||||
// Client 3
|
// Client 3
|
||||||
conn = require('net').createConnection(this.address().port, 'localhost');
|
conn = require('net').createConnection(this.address().port, 'localhost');
|
||||||
conn.pause();
|
conn.pause();
|
||||||
conn.on('data', common.fail);
|
conn.on('data', common.mustNotCall());
|
||||||
scheduleTearDown(conn);
|
scheduleTearDown(conn);
|
||||||
|
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ server.listen(0, function() {
|
|||||||
conn.resume();
|
conn.resume();
|
||||||
conn.resume();
|
conn.resume();
|
||||||
conn.pause();
|
conn.pause();
|
||||||
conn.on('data', common.fail);
|
conn.on('data', common.mustNotCall());
|
||||||
scheduleTearDown(conn);
|
scheduleTearDown(conn);
|
||||||
|
|
||||||
function onDataOk() {
|
function onDataOk() {
|
||||||
|
@ -48,7 +48,7 @@ function pingPongTest(port, host) {
|
|||||||
socket.end();
|
socket.end();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
socket.on('error', common.fail);
|
socket.on('error', common.mustNotCall());
|
||||||
|
|
||||||
socket.on('close', common.mustCall(function() {
|
socket.on('close', common.mustCall(function() {
|
||||||
assert.strictEqual(socket.writable, false);
|
assert.strictEqual(socket.writable, false);
|
||||||
@ -99,7 +99,7 @@ function pingPongTest(port, host) {
|
|||||||
assert.strictEqual(sent_final_ping, true);
|
assert.strictEqual(sent_final_ping, true);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
client.on('error', common.fail);
|
client.on('error', common.mustNotCall());
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,9 +57,8 @@ noEntSocketClient.on('error', common.mustCall(function(err) {
|
|||||||
// On Windows or when running as root, a chmod has no effect on named pipes
|
// On Windows or when running as root, a chmod has no effect on named pipes
|
||||||
if (!common.isWindows && process.getuid() !== 0) {
|
if (!common.isWindows && process.getuid() !== 0) {
|
||||||
// Trying to connect to a socket one has no access to should result in EACCES
|
// Trying to connect to a socket one has no access to should result in EACCES
|
||||||
const accessServer = net.createServer(function() {
|
const accessServer = net.createServer(
|
||||||
common.fail('server callback should not run');
|
common.mustNotCall('server callback should not run'));
|
||||||
});
|
|
||||||
accessServer.listen(common.PIPE, common.mustCall(function() {
|
accessServer.listen(common.PIPE, common.mustCall(function() {
|
||||||
fs.chmodSync(common.PIPE, 0);
|
fs.chmodSync(common.PIPE, 0);
|
||||||
|
|
||||||
|
@ -9,9 +9,7 @@ let disconnect_count = 0;
|
|||||||
// Hopefully nothing is running on common.PORT
|
// Hopefully nothing is running on common.PORT
|
||||||
const c = net.createConnection(common.PORT);
|
const c = net.createConnection(common.PORT);
|
||||||
|
|
||||||
c.on('connect', function() {
|
c.on('connect', common.mustNotCall('client should not have connected'));
|
||||||
common.fail('client should not have connected');
|
|
||||||
});
|
|
||||||
|
|
||||||
c.on('error', function(e) {
|
c.on('error', function(e) {
|
||||||
console.error('CLIENT error: ' + e.code);
|
console.error('CLIENT error: ' + e.code);
|
||||||
|
@ -9,4 +9,4 @@ server.listen();
|
|||||||
|
|
||||||
// If the timeout fires, that means the server held the event loop open
|
// If the timeout fires, that means the server held the event loop open
|
||||||
// and the unref() was not persistent. Close the server and fail the test.
|
// and the unref() was not persistent. Close the server and fail the test.
|
||||||
setTimeout(common.fail, 1000).unref();
|
setTimeout(common.mustNotCall(), 1000).unref();
|
||||||
|
@ -6,4 +6,4 @@ const s = net.createServer();
|
|||||||
s.listen(0);
|
s.listen(0);
|
||||||
s.unref();
|
s.unref();
|
||||||
|
|
||||||
setTimeout(common.fail, 1000).unref();
|
setTimeout(common.mustNotCall(), 1000).unref();
|
||||||
|
@ -15,9 +15,7 @@ const server = net.createServer(common.mustCall((c) => {
|
|||||||
server.listen(0, function() {
|
server.listen(0, function() {
|
||||||
const socket = net.createConnection(this.address().port, 'localhost');
|
const socket = net.createConnection(this.address().port, 'localhost');
|
||||||
|
|
||||||
const s = socket.setTimeout(T, () => {
|
const s = socket.setTimeout(T, common.mustNotCall());
|
||||||
common.fail('Socket timeout event is not expected to fire');
|
|
||||||
});
|
|
||||||
assert.ok(s instanceof net.Socket);
|
assert.ok(s instanceof net.Socket);
|
||||||
|
|
||||||
socket.on('data', common.mustCall(() => {
|
socket.on('data', common.mustCall(() => {
|
||||||
|
@ -22,5 +22,5 @@ process.nextTick(function(a, b) {
|
|||||||
}, 42, obj);
|
}, 42, obj);
|
||||||
|
|
||||||
process.on('exit', function() {
|
process.on('exit', function() {
|
||||||
process.nextTick(common.fail);
|
process.nextTick(common.mustNotCall());
|
||||||
});
|
});
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const net = require('net');
|
const net = require('net');
|
||||||
const server = net.createServer(common.fail);
|
const server = net.createServer(common.mustNotCall());
|
||||||
|
|
||||||
common.refreshTmpDir();
|
common.refreshTmpDir();
|
||||||
|
|
||||||
|
@ -8,4 +8,4 @@ const s = net.Server();
|
|||||||
s.listen(common.PIPE);
|
s.listen(common.PIPE);
|
||||||
s.unref();
|
s.unref();
|
||||||
|
|
||||||
setTimeout(common.fail, 1000).unref();
|
setTimeout(common.mustNotCall(), 1000).unref();
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
|
||||||
process.on('beforeExit', common.mustCall(function() {
|
process.on('beforeExit', common.mustCall(function() {
|
||||||
setTimeout(common.fail, 5);
|
setTimeout(common.mustNotCall(), 5);
|
||||||
process.exit(0); // Should execute immediately even if we schedule new work.
|
process.exit(0); // Should execute immediately even if we schedule new work.
|
||||||
common.fail();
|
common.fail();
|
||||||
}));
|
}));
|
||||||
|
@ -16,15 +16,15 @@ net.Server().listen(common.PORT, function() {
|
|||||||
|
|
||||||
// The first argument is a configuration object
|
// The first argument is a configuration object
|
||||||
assert.throws(() => {
|
assert.throws(() => {
|
||||||
net.Server().listen({ port: invalidPort }, common.fail);
|
net.Server().listen({ port: invalidPort }, common.mustNotCall());
|
||||||
}, errorMessage);
|
}, errorMessage);
|
||||||
|
|
||||||
// The first argument is the port, no IP given.
|
// The first argument is the port, no IP given.
|
||||||
assert.throws(() => {
|
assert.throws(() => {
|
||||||
net.Server().listen(invalidPort, common.fail);
|
net.Server().listen(invalidPort, common.mustNotCall());
|
||||||
}, errorMessage);
|
}, errorMessage);
|
||||||
|
|
||||||
// The first argument is the port, the second an IP.
|
// The first argument is the port, the second an IP.
|
||||||
assert.throws(() => {
|
assert.throws(() => {
|
||||||
net.Server().listen(invalidPort, '0.0.0.0', common.fail);
|
net.Server().listen(invalidPort, '0.0.0.0', common.mustNotCall());
|
||||||
}, errorMessage);
|
}, errorMessage);
|
||||||
|
@ -11,7 +11,7 @@ const testMe = repl.start('', putIn, function(cmd, context, filename,
|
|||||||
callback(null, cmd);
|
callback(null, cmd);
|
||||||
});
|
});
|
||||||
|
|
||||||
testMe._domain.on('error', common.fail);
|
testMe._domain.on('error', common.mustNotCall());
|
||||||
|
|
||||||
testMe.complete('', function(err, results) {
|
testMe.complete('', function(err, results) {
|
||||||
assert.strictEqual(err, null);
|
assert.strictEqual(err, null);
|
||||||
|
@ -29,7 +29,7 @@ setInterval(function() {
|
|||||||
|
|
||||||
// Test on condition where a watcher for SIGNAL
|
// Test on condition where a watcher for SIGNAL
|
||||||
// has been previously registered, and `process.listeners(SIGNAL).length === 1`
|
// has been previously registered, and `process.listeners(SIGNAL).length === 1`
|
||||||
process.on('SIGHUP', function() { common.fail('should not run'); });
|
process.on('SIGHUP', common.mustNotCall());
|
||||||
process.removeAllListeners('SIGHUP');
|
process.removeAllListeners('SIGHUP');
|
||||||
process.on('SIGHUP', common.mustCall(function() {}));
|
process.on('SIGHUP', common.mustCall(function() {}));
|
||||||
process.kill(process.pid, 'SIGHUP');
|
process.kill(process.pid, 'SIGHUP');
|
||||||
|
@ -25,7 +25,7 @@ source.unpipe(dest2);
|
|||||||
assert.strictEqual(source._readableState.pipes, dest1);
|
assert.strictEqual(source._readableState.pipes, dest1);
|
||||||
assert.notStrictEqual(source._readableState.pipes, dest2);
|
assert.notStrictEqual(source._readableState.pipes, dest2);
|
||||||
|
|
||||||
dest2.on('unpipe', common.fail);
|
dest2.on('unpipe', common.mustNotCall());
|
||||||
source.unpipe(dest2);
|
source.unpipe(dest2);
|
||||||
|
|
||||||
source.unpipe(dest1);
|
source.unpipe(dest1);
|
||||||
|
@ -11,7 +11,7 @@ const Readable = require('stream').Readable;
|
|||||||
highWaterMark: 3
|
highWaterMark: 3
|
||||||
});
|
});
|
||||||
|
|
||||||
r._read = common.fail;
|
r._read = common.mustNotCall();
|
||||||
|
|
||||||
// This triggers a 'readable' event, which is lost.
|
// This triggers a 'readable' event, which is lost.
|
||||||
r.push(Buffer.from('blerg'));
|
r.push(Buffer.from('blerg'));
|
||||||
@ -50,7 +50,7 @@ const Readable = require('stream').Readable;
|
|||||||
highWaterMark: 30
|
highWaterMark: 30
|
||||||
});
|
});
|
||||||
|
|
||||||
r._read = common.fail;
|
r._read = common.mustNotCall();
|
||||||
|
|
||||||
// This triggers a 'readable' event, which is lost.
|
// This triggers a 'readable' event, which is lost.
|
||||||
r.push(Buffer.from('blerg'));
|
r.push(Buffer.from('blerg'));
|
||||||
|
@ -38,9 +38,7 @@ function test(decode, uncork, multi, next) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const w = new stream.Writable({ decodeStrings: decode });
|
const w = new stream.Writable({ decodeStrings: decode });
|
||||||
w._write = function(chunk, e, cb) {
|
w._write = common.mustNotCall('Should not call _write');
|
||||||
common.fail('Should not call _write');
|
|
||||||
};
|
|
||||||
|
|
||||||
const expectChunks = decode ? [
|
const expectChunks = decode ? [
|
||||||
{ encoding: 'buffer',
|
{ encoding: 'buffer',
|
||||||
|
@ -8,4 +8,4 @@ const Timer = process.binding('timer_wrap').Timer;
|
|||||||
const t = new Timer();
|
const t = new Timer();
|
||||||
|
|
||||||
t.close(common.mustCall(function() {}));
|
t.close(common.mustCall(function() {}));
|
||||||
t.close(() => common.fail('This should never be called'));
|
t.close(common.mustNotCall());
|
||||||
|
@ -12,9 +12,7 @@ setImmediate(common.mustCall(function() {
|
|||||||
clearImmediate(immediateB);
|
clearImmediate(immediateB);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const immediateB = setImmediate(function() {
|
const immediateB = setImmediate(common.mustNotCall());
|
||||||
common.fail('this immediate should not run');
|
|
||||||
});
|
|
||||||
|
|
||||||
setImmediate(function(x, y, z) {
|
setImmediate(function(x, y, z) {
|
||||||
immediateC = [x, y, z];
|
immediateC = [x, y, z];
|
||||||
|
@ -14,10 +14,6 @@ setImmediate(common.mustCall(function() {
|
|||||||
clearImmediate(i3);
|
clearImmediate(i3);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const i2 = setImmediate(function() {
|
const i2 = setImmediate(common.mustNotCall());
|
||||||
common.fail('immediate callback should not have fired');
|
|
||||||
});
|
|
||||||
|
|
||||||
const i3 = setImmediate(function() {
|
const i3 = setImmediate(common.mustNotCall());
|
||||||
common.fail('immediate callback should not have fired');
|
|
||||||
});
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user