mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 00:20:08 +01:00
test: ensure assertions are reachable in test/sequential
PR-URL: https://github.com/nodejs/node/pull/60412 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
This commit is contained in:
parent
53e325ffd0
commit
646e19e2b4
|
|
@ -178,6 +178,7 @@ export default [
|
|||
'pummel',
|
||||
'report',
|
||||
'sea',
|
||||
'sequential',
|
||||
'sqlite',
|
||||
'system-ca',
|
||||
'test426',
|
||||
|
|
|
|||
|
|
@ -147,9 +147,9 @@ const args = [
|
|||
assert.strictEqual(typeof err.pid, 'number');
|
||||
spawnSyncKeys
|
||||
.filter((key) => key !== 'pid')
|
||||
.forEach((key) => {
|
||||
.forEach(common.mustCallAtLeast((key) => {
|
||||
assert.deepStrictEqual(err[key], spawnSyncResult[key]);
|
||||
});
|
||||
}));
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ const N = 80;
|
|||
let messageCallbackCount = 0;
|
||||
|
||||
function forkWorker() {
|
||||
const messageCallback = (msg, handle) => {
|
||||
const messageCallback = common.mustCall((msg, handle) => {
|
||||
messageCallbackCount++;
|
||||
assert.strictEqual(msg, 'handle');
|
||||
assert.ok(handle);
|
||||
|
|
@ -32,11 +32,11 @@ function forkWorker() {
|
|||
recvData += data;
|
||||
}));
|
||||
|
||||
handle.on('end', () => {
|
||||
handle.on('end', common.mustCall(() => {
|
||||
assert.strictEqual(recvData, 'hello');
|
||||
worker.kill();
|
||||
}));
|
||||
});
|
||||
};
|
||||
|
||||
const worker = fork(__filename, ['child']);
|
||||
worker.on('error', (err) => {
|
||||
|
|
@ -70,13 +70,13 @@ if (process.argv[2] !== 'child') {
|
|||
// thus no work to do, and will exit immediately, preventing process leaks.
|
||||
process.on('message', common.mustCall());
|
||||
|
||||
const server = net.createServer((c) => {
|
||||
process.once('message', (msg) => {
|
||||
const server = net.createServer(common.mustCall((c) => {
|
||||
process.once('message', common.mustCall((msg) => {
|
||||
assert.strictEqual(msg, 'got');
|
||||
c.end('hello');
|
||||
});
|
||||
}));
|
||||
socketConnected();
|
||||
}).unref();
|
||||
})).unref();
|
||||
server.listen(0, common.localhostIPv4, () => {
|
||||
const { port } = server.address();
|
||||
socket = net.connect(port, common.localhostIPv4, socketConnected).unref();
|
||||
|
|
|
|||
|
|
@ -23,10 +23,9 @@ if (cluster.isPrimary) {
|
|||
server.listen(0, common.mustCall(() => {
|
||||
const port = server.address().port;
|
||||
const socket = new net.Socket();
|
||||
socket.connect(port, (err) => {
|
||||
assert.ifError(err);
|
||||
socket.connect(port, common.mustSucceed(() => {
|
||||
worker.send({ payload }, socket);
|
||||
});
|
||||
}));
|
||||
}));
|
||||
} else {
|
||||
process.on('message', common.mustCall(({ payload: received }, handle) => {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ const { spawn } = require('child_process');
|
|||
|
||||
const script = fixtures.path('debugger', 'alive.js');
|
||||
|
||||
const runTest = async () => {
|
||||
(async () => {
|
||||
const target = spawn(process.execPath, [script]);
|
||||
const cli = startCLI(['-p', `${target.pid}`], [], {}, { randomPort: false });
|
||||
|
||||
|
|
@ -24,12 +24,8 @@ const runTest = async () => {
|
|||
cli.output,
|
||||
/> 3 {3}\+\+x;/,
|
||||
'marks the 3rd line');
|
||||
} catch (error) {
|
||||
assert.ifError(error);
|
||||
} finally {
|
||||
await cli.quit();
|
||||
target.kill();
|
||||
}
|
||||
};
|
||||
|
||||
runTest().then(common.mustCall());
|
||||
})().then(common.mustCall());
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
'use strict';
|
||||
require('../common');
|
||||
const common = require('../common');
|
||||
const fixtures = require('../common/fixtures');
|
||||
const assert = require('assert');
|
||||
const execFile = require('child_process').execFile;
|
||||
|
|
@ -40,49 +40,43 @@ const normal = [depmod];
|
|||
const noDep = ['--no-deprecation', depmod];
|
||||
const traceDep = ['--trace-deprecation', depmod];
|
||||
|
||||
execFile(node, normal, function(er, stdout, stderr) {
|
||||
execFile(node, normal, common.mustSucceed((stdout, stderr) => {
|
||||
console.error('normal: show deprecation warning');
|
||||
assert.strictEqual(er, null);
|
||||
assert.strictEqual(stdout, '');
|
||||
assert.match(stderr, /this function is deprecated/);
|
||||
console.log('normal ok');
|
||||
});
|
||||
}));
|
||||
|
||||
execFile(node, noDep, function(er, stdout, stderr) {
|
||||
execFile(node, noDep, common.mustSucceed((stdout, stderr) => {
|
||||
console.error('--no-deprecation: silence deprecations');
|
||||
assert.strictEqual(er, null);
|
||||
assert.strictEqual(stdout, '');
|
||||
assert.strictEqual(stderr.trim(), 'This is deprecated');
|
||||
console.log('silent ok');
|
||||
});
|
||||
}));
|
||||
|
||||
execFile(node, traceDep, function(er, stdout, stderr) {
|
||||
execFile(node, traceDep, common.mustSucceed((stdout, stderr) => {
|
||||
console.error('--trace-deprecation: show stack');
|
||||
assert.strictEqual(er, null);
|
||||
assert.strictEqual(stdout, '');
|
||||
const stack = stderr.trim().split('\n');
|
||||
// Just check the top and bottom.
|
||||
assert.match(stack[1], /this function is deprecated/);
|
||||
assert.match(stack[0], /This is deprecated/);
|
||||
console.log('trace ok');
|
||||
});
|
||||
}));
|
||||
|
||||
execFile(node, [depUserlandFunction], function(er, stdout, stderr) {
|
||||
execFile(node, [depUserlandFunction], common.mustSucceed((stdout, stderr) => {
|
||||
console.error('normal: testing deprecated userland function');
|
||||
assert.strictEqual(er, null);
|
||||
assert.strictEqual(stdout, '');
|
||||
assert.match(stderr, /deprecatedFunction is deprecated/);
|
||||
console.error('normal: ok');
|
||||
});
|
||||
}));
|
||||
|
||||
execFile(node, [depUserlandClass], function(er, stdout, stderr) {
|
||||
assert.strictEqual(er, null);
|
||||
execFile(node, [depUserlandClass], common.mustSucceed((stdout, stderr) => {
|
||||
assert.strictEqual(stdout, '');
|
||||
assert.match(stderr, /deprecatedClass is deprecated/);
|
||||
});
|
||||
}));
|
||||
|
||||
execFile(node, [depUserlandSubClass], function(er, stdout, stderr) {
|
||||
assert.strictEqual(er, null);
|
||||
execFile(node, [depUserlandSubClass], common.mustSucceed((stdout, stderr) => {
|
||||
assert.strictEqual(stdout, '');
|
||||
assert.match(stderr, /deprecatedClass is deprecated/);
|
||||
});
|
||||
}));
|
||||
|
|
|
|||
|
|
@ -14,17 +14,17 @@ function pingPongTest(port, host) {
|
|||
throw e;
|
||||
});
|
||||
|
||||
server.on('listening', function() {
|
||||
server.on('listening', common.mustCall(() => {
|
||||
console.log(`server listening on ${port}`);
|
||||
|
||||
const client = dgram.createSocket('udp4');
|
||||
|
||||
client.on('message', function(msg) {
|
||||
client.on('message', common.mustCall((msg) => {
|
||||
assert.strictEqual(msg.toString('ascii'), 'PONG');
|
||||
|
||||
client.close();
|
||||
server.close();
|
||||
});
|
||||
}));
|
||||
|
||||
client.on('error', function(e) {
|
||||
throw e;
|
||||
|
|
@ -37,7 +37,7 @@ function pingPongTest(port, host) {
|
|||
}
|
||||
|
||||
clientSend();
|
||||
});
|
||||
}));
|
||||
server.bind(port, host);
|
||||
return server;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -134,11 +134,11 @@ function assertDirents(dirents) {
|
|||
assert.strictEqual(dirents.length, expected.length);
|
||||
dirents.sort((a, b) => (getDirentPath(a) < getDirentPath(b) ? -1 : 1));
|
||||
assert.deepStrictEqual(
|
||||
dirents.map((dirent) => {
|
||||
dirents.map(common.mustCallAtLeast((dirent) => {
|
||||
assert(dirent instanceof fs.Dirent);
|
||||
assert.notStrictEqual(dirent.name, undefined);
|
||||
return getDirentPath(dirent);
|
||||
}),
|
||||
})),
|
||||
expected
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ if (common.isWindows)
|
|||
|
||||
const assert = require('assert');
|
||||
|
||||
const validateHeapSnapshotFile = () => {
|
||||
if (process.argv[2] === 'child') {
|
||||
const fs = require('fs');
|
||||
|
||||
assert.strictEqual(process.listenerCount('SIGUSR2'), 1);
|
||||
|
|
@ -31,10 +31,6 @@ const validateHeapSnapshotFile = () => {
|
|||
JSON.parse(fs.readFileSync(files[i]));
|
||||
}
|
||||
})();
|
||||
};
|
||||
|
||||
if (process.argv[2] === 'child') {
|
||||
validateHeapSnapshotFile();
|
||||
} else {
|
||||
// Modify the timezone. So we can check the file date string still returning correctly.
|
||||
process.env.TZ = 'America/New_York';
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ const common = require('../common');
|
|||
const http = require('http');
|
||||
const assert = require('assert');
|
||||
|
||||
const server = http.createServer(function(req, res) {
|
||||
const server = http.createServer(common.mustCallAtLeast((req, res) => {
|
||||
let body = '';
|
||||
|
||||
req.setEncoding('utf8');
|
||||
|
|
@ -40,12 +40,12 @@ const server = http.createServer(function(req, res) {
|
|||
body += chunk;
|
||||
});
|
||||
|
||||
req.on('end', function() {
|
||||
req.on('end', common.mustCall(() => {
|
||||
assert.strictEqual(body, 'PING');
|
||||
res.writeHead(200, { 'Connection': 'close' });
|
||||
res.end('PONG');
|
||||
});
|
||||
});
|
||||
}));
|
||||
}));
|
||||
|
||||
|
||||
server.on('listening', pingping);
|
||||
|
|
@ -109,7 +109,7 @@ function ping() {
|
|||
method: 'POST'
|
||||
};
|
||||
|
||||
const req = http.request(opt, function(res) {
|
||||
const req = http.request(opt, common.mustCallAtLeast((res) => {
|
||||
let body = '';
|
||||
|
||||
res.setEncoding('utf8');
|
||||
|
|
@ -117,20 +117,20 @@ function ping() {
|
|||
body += chunk;
|
||||
});
|
||||
|
||||
res.on('end', function() {
|
||||
res.on('end', common.mustCall(() => {
|
||||
assert.strictEqual(body, 'PONG');
|
||||
assert.ok(!hadError);
|
||||
gotEnd = true;
|
||||
afterPing('success');
|
||||
});
|
||||
});
|
||||
}));
|
||||
}, 0));
|
||||
|
||||
req.end('PING');
|
||||
|
||||
let gotEnd = false;
|
||||
let hadError = false;
|
||||
|
||||
req.on('error', function(error) {
|
||||
req.on('error', common.mustCallAtLeast((error) => {
|
||||
console.log(`Error making ping req: ${error}`);
|
||||
hadError = true;
|
||||
assert.ok(!gotEnd);
|
||||
|
|
@ -138,7 +138,7 @@ function ping() {
|
|||
// Family autoselection might be skipped if only a single address is returned by DNS.
|
||||
const actualError = Array.isArray(error.errors) ? error.errors[0] : error;
|
||||
afterPing(actualError.message);
|
||||
});
|
||||
}, 0));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
'use strict';
|
||||
require('../common');
|
||||
const common = require('../common');
|
||||
const assert = require('assert');
|
||||
|
||||
const http = require('http');
|
||||
|
|
@ -33,7 +33,7 @@ const server = http.createServer(function(req, res) {
|
|||
}
|
||||
res.end(req.url);
|
||||
});
|
||||
server.listen(0, function() {
|
||||
server.listen(0, common.mustCall(() => {
|
||||
const agent = http.Agent({
|
||||
keepAlive: true,
|
||||
maxSockets: 5,
|
||||
|
|
@ -41,16 +41,14 @@ server.listen(0, function() {
|
|||
});
|
||||
|
||||
let closed = false;
|
||||
makeReqs(10, function(er) {
|
||||
assert.ifError(er);
|
||||
makeReqs(10, common.mustSucceed(() => {
|
||||
assert.strictEqual(count(agent.freeSockets), 2);
|
||||
assert.strictEqual(count(agent.sockets), 0);
|
||||
assert.strictEqual(serverSockets.length, 5);
|
||||
|
||||
// Now make 10 more reqs.
|
||||
// should use the 2 free reqs from the pool first.
|
||||
makeReqs(10, function(er) {
|
||||
assert.ifError(er);
|
||||
makeReqs(10, common.mustSucceed(() => {
|
||||
assert.strictEqual(count(agent.freeSockets), 2);
|
||||
assert.strictEqual(count(agent.sockets), 0);
|
||||
assert.strictEqual(serverSockets.length, 8);
|
||||
|
|
@ -59,8 +57,8 @@ server.listen(0, function() {
|
|||
server.close(function() {
|
||||
closed = true;
|
||||
});
|
||||
});
|
||||
});
|
||||
}));
|
||||
}));
|
||||
|
||||
process.on('exit', function() {
|
||||
assert(closed);
|
||||
|
|
@ -86,17 +84,17 @@ server.listen(0, function() {
|
|||
port: server.address().port,
|
||||
path: `/${i}`,
|
||||
agent: agent
|
||||
}, function(res) {
|
||||
}, common.mustCall((res) => {
|
||||
let data = '';
|
||||
res.setEncoding('ascii');
|
||||
res.on('data', function(c) {
|
||||
data += c;
|
||||
});
|
||||
res.on('end', function() {
|
||||
res.on('end', common.mustCall(() => {
|
||||
assert.strictEqual(data, `/${i}`);
|
||||
cb();
|
||||
});
|
||||
}).end();
|
||||
}));
|
||||
})).end();
|
||||
}
|
||||
|
||||
function count(sockets) {
|
||||
|
|
@ -104,4 +102,4 @@ server.listen(0, function() {
|
|||
return n + sockets[name].length;
|
||||
}, 0);
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ server.listen(0, common.mustCall(() => {
|
|||
{
|
||||
const req = client.request();
|
||||
|
||||
req.on('response', () => {
|
||||
req.on('response', common.mustCall(() => {
|
||||
// This one should be rejected because the server is over budget
|
||||
// on the current memory allocation
|
||||
const req = client.request();
|
||||
|
|
@ -40,7 +40,7 @@ server.listen(0, common.mustCall(() => {
|
|||
server.close();
|
||||
client.destroy();
|
||||
}));
|
||||
});
|
||||
}));
|
||||
|
||||
req.resume();
|
||||
req.on('close', common.mustCall());
|
||||
|
|
|
|||
|
|
@ -21,11 +21,11 @@ let interval;
|
|||
|
||||
server.on('stream', common.mustNotCall());
|
||||
server.on('session', common.mustCall((session) => {
|
||||
session.on('error', (e) => {
|
||||
session.on('error', common.mustCallAtLeast((e) => {
|
||||
assert.strictEqual(e.code, 'ERR_HTTP2_ERROR');
|
||||
assert(e.message.includes('Flooding was detected'));
|
||||
clearInterval(interval);
|
||||
});
|
||||
}, 0));
|
||||
session.on('close', common.mustCall(() => {
|
||||
server.close();
|
||||
}));
|
||||
|
|
|
|||
|
|
@ -20,11 +20,11 @@ let interval;
|
|||
|
||||
server.on('stream', common.mustNotCall());
|
||||
server.on('session', common.mustCall((session) => {
|
||||
session.on('error', (e) => {
|
||||
session.on('error', common.mustCallAtLeast((e) => {
|
||||
assert.strictEqual(e.code, 'ERR_HTTP2_ERROR');
|
||||
assert(e.message.includes('Flooding was detected'));
|
||||
clearInterval(interval);
|
||||
});
|
||||
}, 0));
|
||||
|
||||
session.on('close', common.mustCall(() => {
|
||||
server.close();
|
||||
|
|
|
|||
|
|
@ -47,9 +47,9 @@ server.on('stream', common.mustCall((stream) => {
|
|||
stream.end();
|
||||
}));
|
||||
server.setTimeout(serverTimeout);
|
||||
server.on('timeout', () => {
|
||||
server.on('timeout', common.mustCallAtLeast(() => {
|
||||
assert.ok(!didReceiveData, 'Should not timeout');
|
||||
});
|
||||
}, 0));
|
||||
|
||||
server.listen(0, common.mustCall(() => {
|
||||
const client = http2.connect(`https://localhost:${server.address().port}`,
|
||||
|
|
|
|||
|
|
@ -28,6 +28,9 @@ const server = http2.createSecureServer({
|
|||
key: fixtures.readKey('agent1-key.pem'),
|
||||
cert: fixtures.readKey('agent1-cert.pem')
|
||||
});
|
||||
const onTimeout = common.mustCallAtLeast(() => {
|
||||
assert.ok(!didReceiveData, 'Should not timeout');
|
||||
}, 0);
|
||||
server.on('stream', common.mustCall((stream) => {
|
||||
const content = Buffer.alloc(writeSize, 0x44);
|
||||
|
||||
|
|
@ -39,15 +42,11 @@ server.on('stream', common.mustCall((stream) => {
|
|||
|
||||
stream.write(content);
|
||||
stream.setTimeout(serverTimeout);
|
||||
stream.on('timeout', () => {
|
||||
assert.ok(!didReceiveData, 'Should not timeout');
|
||||
});
|
||||
stream.on('timeout', onTimeout);
|
||||
stream.end();
|
||||
}));
|
||||
server.setTimeout(serverTimeout);
|
||||
server.on('timeout', () => {
|
||||
assert.ok(!didReceiveData, 'Should not timeout');
|
||||
});
|
||||
server.on('timeout', onTimeout);
|
||||
|
||||
server.listen(0, common.mustCall(() => {
|
||||
const client = http2.connect(`https://localhost:${server.address().port}`,
|
||||
|
|
|
|||
|
|
@ -34,11 +34,11 @@ if (process.env.BE_CHILD) {
|
|||
function wasDisposedWhenOpenHandler(msg) {
|
||||
assert.strictEqual(msg.cmd, 'url');
|
||||
assert.strictEqual(msg.url, undefined);
|
||||
ping(firstPort, (err) => {
|
||||
ping(firstPort, common.mustCall((err) => {
|
||||
assert(err, 'expected ping to inspector port to fail');
|
||||
child.send({ cmd: 'dispose' });
|
||||
child.once('message', common.mustCall(wasReDisposedHandler));
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
function wasReDisposedHandler(msg) {
|
||||
|
|
|
|||
|
|
@ -165,13 +165,13 @@ try {
|
|||
assert.strictEqual(path.dirname(__filename), __dirname);
|
||||
|
||||
console.error('load custom file types with extensions');
|
||||
require.extensions['.test'] = function(module, filename) {
|
||||
require.extensions['.test'] = common.mustCall(function(module, filename) {
|
||||
let content = fs.readFileSync(filename).toString();
|
||||
assert.strictEqual(content, 'this is custom source\n');
|
||||
content = content.replace('this is custom source',
|
||||
'exports.test = \'passed\'');
|
||||
module._compile(content, filename);
|
||||
};
|
||||
});
|
||||
|
||||
assert.strictEqual(require('../fixtures/registerExt').test, 'passed');
|
||||
// Unknown extension, load as .js
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ const server = net.createServer().listen(0, common.mustCall(() => {
|
|||
function pummel() {
|
||||
let pending;
|
||||
for (pending = 0; pending < ATTEMPTS_PER_ROUND; pending++) {
|
||||
net.createConnection({ port, autoSelectFamily: false }).on('error', function(error) {
|
||||
net.createConnection({ port, autoSelectFamily: false }).on('error', common.mustCallAtLeast((error) => {
|
||||
// Family autoselection might be skipped if only a single address is returned by DNS.
|
||||
const actualError = Array.isArray(error.errors) ? error.errors[0] : error;
|
||||
|
||||
|
|
@ -50,7 +50,7 @@ function pummel() {
|
|||
if (rounds === ROUNDS) return check();
|
||||
rounds++;
|
||||
pummel();
|
||||
});
|
||||
}, 0));
|
||||
reqs++;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,18 +3,18 @@ const common = require('../common');
|
|||
const assert = require('assert');
|
||||
const net = require('net');
|
||||
|
||||
const server = net.createServer(function(socket) {
|
||||
const server = net.createServer(common.mustCall((socket) => {
|
||||
assert.strictEqual(socket.remotePort, common.PORT);
|
||||
socket.end();
|
||||
socket.on('close', function() {
|
||||
server.close();
|
||||
});
|
||||
}).listen(0).on('listening', function() {
|
||||
})).listen(0).on('listening', common.mustCall(function() {
|
||||
const client = net.connect({
|
||||
host: '127.0.0.1',
|
||||
port: this.address().port,
|
||||
localPort: common.PORT,
|
||||
}).on('connect', function() {
|
||||
}).on('connect', common.mustCall(() => {
|
||||
assert.strictEqual(client.localPort, common.PORT);
|
||||
});
|
||||
});
|
||||
}));
|
||||
}));
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ const net = require('net');
|
|||
|
||||
server.listen(common.PORT);
|
||||
|
||||
setTimeout(function() {
|
||||
setTimeout(common.mustCall(() => {
|
||||
const address = server.address();
|
||||
assert.strictEqual(address.port, common.PORT);
|
||||
|
||||
|
|
@ -30,7 +30,7 @@ const net = require('net');
|
|||
assert.strictEqual(server._connectionKey, `4:0.0.0.0:${address.port}`);
|
||||
|
||||
server.close();
|
||||
}, 100);
|
||||
}), 100);
|
||||
}
|
||||
|
||||
// Callback to listen()
|
||||
|
|
|
|||
|
|
@ -57,9 +57,7 @@ const web = http.Server(common.mustCall((req, res) => {
|
|||
res.end();
|
||||
}));
|
||||
|
||||
req.connection.on('error', (e) => {
|
||||
assert.ifError(e);
|
||||
});
|
||||
req.connection.on('error', common.mustNotCall());
|
||||
}));
|
||||
|
||||
web.listen(webPort, startClient);
|
||||
|
|
@ -70,21 +68,19 @@ const tcp = net.Server(common.mustCall((s) => {
|
|||
|
||||
let i = 0;
|
||||
|
||||
s.on('data', (d) => {
|
||||
s.on('data', common.mustCallAtLeast((d) => {
|
||||
tcpLengthSeen += d.length;
|
||||
for (let j = 0; j < d.length; j++) {
|
||||
assert.strictEqual(d[j], buffer[i]);
|
||||
i++;
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
s.on('end', common.mustCall(() => {
|
||||
s.end();
|
||||
}));
|
||||
|
||||
s.on('error', (e) => {
|
||||
assert.ifError(e);
|
||||
});
|
||||
s.on('error', common.mustNotCall());
|
||||
}));
|
||||
|
||||
tcp.listen(tcpPort, startClient);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
const common = require('../common');
|
||||
const { spawnSync } = require('child_process');
|
||||
const { strictEqual } = require('assert');
|
||||
const assert = require('assert');
|
||||
|
||||
// FIXME add sunos support
|
||||
if (common.isSunOS)
|
||||
|
|
@ -19,4 +19,4 @@ if (common.isWindows)
|
|||
|
||||
const xs = 'x'.repeat(1024);
|
||||
const proc = spawnSync(process.execPath, ['-p', 'process.title', xs]);
|
||||
strictEqual(proc.stdout.toString().trim(), process.execPath);
|
||||
assert.strictEqual(proc.stdout.toString().trim(), process.execPath);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
require('../common');
|
||||
const common = require('../common');
|
||||
const fixtures = require('../common/fixtures');
|
||||
const assert = require('assert');
|
||||
const execFile = require('child_process').execFile;
|
||||
|
|
@ -13,24 +13,24 @@ const traceWarn = ['--trace-warnings', warnmod];
|
|||
|
||||
const warningMessage = /^\(.+\)\sWarning: a bad practice warning/;
|
||||
|
||||
execFile(node, normal, function(er, stdout, stderr) {
|
||||
execFile(node, normal, common.mustCall((er, stdout, stderr) => {
|
||||
// Show Process Warnings
|
||||
assert.strictEqual(er, null);
|
||||
assert.strictEqual(stdout, '');
|
||||
assert.match(stderr, warningMessage);
|
||||
});
|
||||
}));
|
||||
|
||||
execFile(node, noWarn, function(er, stdout, stderr) {
|
||||
execFile(node, noWarn, common.mustCall((er, stdout, stderr) => {
|
||||
// Hide Process Warnings
|
||||
assert.strictEqual(er, null);
|
||||
assert.strictEqual(stdout, '');
|
||||
assert.doesNotMatch(stderr, warningMessage);
|
||||
});
|
||||
}));
|
||||
|
||||
execFile(node, traceWarn, function(er, stdout, stderr) {
|
||||
execFile(node, traceWarn, common.mustCall((er, stdout, stderr) => {
|
||||
// Show Warning Trace
|
||||
assert.strictEqual(er, null);
|
||||
assert.strictEqual(stdout, '');
|
||||
assert.match(stderr, warningMessage);
|
||||
assert.match(stderr, /at Object\.<anonymous>\s\(.+warnings\.js:3:9\)/);
|
||||
});
|
||||
}));
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
'use strict';
|
||||
require('../common');
|
||||
const common = require('../common');
|
||||
const assert = require('assert');
|
||||
|
||||
const spawn = require('child_process').spawn;
|
||||
|
|
@ -51,9 +51,9 @@ child.stdout.once('data', function() {
|
|||
}
|
||||
});
|
||||
|
||||
child.on('close', function(c) {
|
||||
child.on('close', common.mustCall((c) => {
|
||||
assert.strictEqual(c, 0);
|
||||
// Make sure we got 3 throws, in the end.
|
||||
const lastLine = stdout.trim().split(/\r?\n/).pop();
|
||||
assert.strictEqual(lastLine, '> 3');
|
||||
});
|
||||
}));
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
'use strict';
|
||||
require('../common');
|
||||
const common = require('../common');
|
||||
const fixtures = require('../common/fixtures');
|
||||
const assert = require('assert');
|
||||
|
||||
|
|
@ -58,13 +58,13 @@ class TestWriter extends Stream {
|
|||
const r = new FSReadable(file);
|
||||
const w = new TestWriter();
|
||||
|
||||
w.on('results', function(res) {
|
||||
w.on('results', common.mustCall((res) => {
|
||||
console.error(res, w.length);
|
||||
assert.strictEqual(w.length, size);
|
||||
assert.deepStrictEqual(res.map(function(c) {
|
||||
return c.length;
|
||||
}), expectLengths);
|
||||
console.log('ok');
|
||||
});
|
||||
}));
|
||||
|
||||
r.pipe(w);
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
'use strict';
|
||||
// Make sure that sync writes to stderr get processed before exiting.
|
||||
|
||||
require('../common');
|
||||
const common = require('../common');
|
||||
|
||||
function parent() {
|
||||
const spawn = require('child_process').spawn;
|
||||
|
|
@ -36,12 +36,12 @@ function parent() {
|
|||
err += c;
|
||||
});
|
||||
|
||||
child.on('close', function() {
|
||||
child.on('close', common.mustCall(() => {
|
||||
assert.strictEqual(err, `child ${c}\nfoo\nbar\nbaz\n`);
|
||||
console.log(`ok ${++i} child #${c}`);
|
||||
if (i === children.length)
|
||||
console.log(`1..${i}`);
|
||||
});
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,14 +6,14 @@ const assert = require('assert');
|
|||
const { sleep } = require('internal/util');
|
||||
|
||||
let called = false;
|
||||
const t1 = setInterval(() => {
|
||||
const t1 = setInterval(common.mustCallAtLeast(() => {
|
||||
assert(!called);
|
||||
called = true;
|
||||
setImmediate(common.mustCall(() => {
|
||||
clearInterval(t1);
|
||||
clearInterval(t2);
|
||||
}));
|
||||
}, 10);
|
||||
}), 10);
|
||||
|
||||
const t2 = setInterval(() => {
|
||||
sleep(20);
|
||||
|
|
|
|||
|
|
@ -1,23 +1,23 @@
|
|||
// Flags: --expose-internals
|
||||
'use strict';
|
||||
require('../common');
|
||||
const common = require('../common');
|
||||
const assert = require('assert');
|
||||
const { sleep } = require('internal/util');
|
||||
|
||||
let cntr = 0;
|
||||
let first;
|
||||
const t = setInterval(() => {
|
||||
const t = setInterval(common.mustCallAtLeast(() => {
|
||||
cntr++;
|
||||
if (cntr === 1) {
|
||||
sleep(100);
|
||||
// Ensure that the event loop passes before the second interval
|
||||
setImmediate(() => assert.strictEqual(cntr, 1));
|
||||
setImmediate(common.mustCall(() => assert.strictEqual(cntr, 1)));
|
||||
first = Date.now();
|
||||
} else if (cntr === 2) {
|
||||
assert(Date.now() - first < 100);
|
||||
clearInterval(t);
|
||||
}
|
||||
}, 100);
|
||||
}), 100);
|
||||
const t2 = setInterval(() => {
|
||||
if (cntr === 2) {
|
||||
clearInterval(t2);
|
||||
|
|
|
|||
|
|
@ -36,12 +36,12 @@ let serverOut = '';
|
|||
server.stderr.on('data', (data) => serverErr += data);
|
||||
server.stdout.on('data', (data) => serverOut += data);
|
||||
server.on('error', common.mustNotCall());
|
||||
server.on('exit', (code, signal) => {
|
||||
server.on('exit', common.mustCall((code, signal) => {
|
||||
// Server is expected to be terminated by cleanUp().
|
||||
assert.strictEqual(code, null,
|
||||
`'${server.spawnfile} ${server.spawnargs.join(' ')}' unexpected exited with output:\n${serverOut}\n${serverErr}`);
|
||||
assert.strictEqual(signal, 'SIGTERM');
|
||||
});
|
||||
}));
|
||||
|
||||
const cleanUp = (err) => {
|
||||
clearTimeout(timeout);
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ function doTest() {
|
|||
client.stdout.on('data', (data) => {
|
||||
clientOutput += data.toString();
|
||||
});
|
||||
client.on('exit', (code) => {
|
||||
client.on('exit', common.mustCall((code) => {
|
||||
let connectionType;
|
||||
// Log the output for debugging purposes. Don't remove them or otherwise
|
||||
// the CI output is useless when this test flakes.
|
||||
|
|
@ -120,7 +120,7 @@ function doTest() {
|
|||
assert.strictEqual(code, 0);
|
||||
assert.strictEqual(connectionType, expectedType);
|
||||
cb(connectionType);
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
const server = tls.createServer(options, (cleartext) => {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { isWindows } from '../common/index.mjs';
|
|||
import { spawn } from 'node:child_process';
|
||||
import { once } from 'node:events';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { strictEqual } from 'node:assert';
|
||||
import assert from 'node:assert';
|
||||
|
||||
const python = process.env.PYTHON || (isWindows ? 'python' : 'python3');
|
||||
|
||||
|
|
@ -21,4 +21,4 @@ const proc = spawn(python, [
|
|||
});
|
||||
|
||||
const [code] = await once(proc, 'exit');
|
||||
strictEqual(code, 0);
|
||||
assert.strictEqual(code, 0);
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ function checkWorkerActive() {
|
|||
const w = workerELU();
|
||||
|
||||
metricsCh.port2.postMessage({ cmd: 'spin', dur: 50 });
|
||||
metricsCh.port2.once('message', (wElu) => {
|
||||
metricsCh.port2.once('message', mustCall((wElu) => {
|
||||
const w2 = workerELU(w);
|
||||
|
||||
assert.ok(w2.active >= 50, `${w2.active} < 50`);
|
||||
|
|
@ -107,7 +107,7 @@ function checkWorkerActive() {
|
|||
`${idleActive(wElu)} >= ${idleActive(w2)}`);
|
||||
|
||||
metricsCh.port2.postMessage({ cmd: 'close' });
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
function idleActive(elu) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user