Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions test/eslint.config_partial.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ export default [
'pummel',
'report',
'sea',
'sequential',
'sqlite',
'system-ca',
'test426',
Expand Down
4 changes: 2 additions & 2 deletions test/sequential/test-child-process-execsync.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
}
Expand Down
16 changes: 8 additions & 8 deletions test/sequential/test-child-process-pass-fd.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) => {
Expand Down Expand Up @@ -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();
Expand Down
5 changes: 2 additions & 3 deletions test/sequential/test-cluster-send-handle-large-payload.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
8 changes: 2 additions & 6 deletions test/sequential/test-debugger-pid.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });

Expand All @@ -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());
32 changes: 13 additions & 19 deletions test/sequential/test-deprecation-flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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/);
});
}));
8 changes: 4 additions & 4 deletions test/sequential/test-dgram-pingpong.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -37,7 +37,7 @@ function pingPongTest(port, host) {
}

clientSend();
});
}));
server.bind(port, host);
return server;
}
Expand Down
4 changes: 2 additions & 2 deletions test/sequential/test-fs-readdir-recursive.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
Expand Down
6 changes: 1 addition & 5 deletions test/sequential/test-heapdump-flag-custom-dir.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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';
Expand Down
20 changes: 10 additions & 10 deletions test/sequential/test-http-econnrefused.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,20 @@ 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');
req.on('data', function(chunk) {
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);
Expand Down Expand Up @@ -109,36 +109,36 @@ function ping() {
method: 'POST'
};

const req = http.request(opt, function(res) {
const req = http.request(opt, common.mustCallAtLeast((res) => {
let body = '';

res.setEncoding('utf8');
res.on('data', function(chunk) {
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);

// 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));
}


Expand Down
24 changes: 11 additions & 13 deletions test/sequential/test-http-keepalive-maxsockets.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -33,24 +33,22 @@ 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,
maxFreeSockets: 2
});

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);
Expand All @@ -59,8 +57,8 @@ server.listen(0, function() {
server.close(function() {
closed = true;
});
});
});
}));
}));

process.on('exit', function() {
assert(closed);
Expand All @@ -86,22 +84,22 @@ 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) {
return Object.keys(sockets).reduce(function(n, name) {
return n + sockets[name].length;
}, 0);
}
});
}));
4 changes: 2 additions & 2 deletions test/sequential/test-http2-max-session-memory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -40,7 +40,7 @@ server.listen(0, common.mustCall(() => {
server.close();
client.destroy();
}));
});
}));

req.resume();
req.on('close', common.mustCall());
Expand Down
Loading
Loading