diff --git a/test/eslint.config_partial.mjs b/test/eslint.config_partial.mjs index f523d6f86f..d19e98a4bf 100644 --- a/test/eslint.config_partial.mjs +++ b/test/eslint.config_partial.mjs @@ -178,6 +178,7 @@ export default [ 'pummel', 'report', 'sea', + 'sequential', 'sqlite', 'system-ca', 'test426', diff --git a/test/sequential/test-child-process-execsync.js b/test/sequential/test-child-process-execsync.js index 53ee42b214..ed7f78d421 100644 --- a/test/sequential/test-child-process-execsync.js +++ b/test/sequential/test-child-process-execsync.js @@ -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; }); } diff --git a/test/sequential/test-child-process-pass-fd.js b/test/sequential/test-child-process-pass-fd.js index 0a77aca0f4..9b62c3edb3 100644 --- a/test/sequential/test-child-process-pass-fd.js +++ b/test/sequential/test-child-process-pass-fd.js @@ -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(); diff --git a/test/sequential/test-cluster-send-handle-large-payload.js b/test/sequential/test-cluster-send-handle-large-payload.js index c5226ceb40..81e4f79781 100644 --- a/test/sequential/test-cluster-send-handle-large-payload.js +++ b/test/sequential/test-cluster-send-handle-large-payload.js @@ -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) => { diff --git a/test/sequential/test-debugger-pid.js b/test/sequential/test-debugger-pid.js index 972c8448bc..97218b796c 100644 --- a/test/sequential/test-debugger-pid.js +++ b/test/sequential/test-debugger-pid.js @@ -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()); diff --git a/test/sequential/test-deprecation-flags.js b/test/sequential/test-deprecation-flags.js index 30ac4a605e..0cbc0a6cde 100644 --- a/test/sequential/test-deprecation-flags.js +++ b/test/sequential/test-deprecation-flags.js @@ -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/); -}); +})); diff --git a/test/sequential/test-dgram-pingpong.js b/test/sequential/test-dgram-pingpong.js index 33b01fbe22..87118ae85b 100644 --- a/test/sequential/test-dgram-pingpong.js +++ b/test/sequential/test-dgram-pingpong.js @@ -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; } diff --git a/test/sequential/test-fs-readdir-recursive.js b/test/sequential/test-fs-readdir-recursive.js index 0b2da41969..15bc75c6c9 100644 --- a/test/sequential/test-fs-readdir-recursive.js +++ b/test/sequential/test-fs-readdir-recursive.js @@ -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 ); } diff --git a/test/sequential/test-heapdump-flag-custom-dir.js b/test/sequential/test-heapdump-flag-custom-dir.js index ea53cb6604..ece1f5b92b 100644 --- a/test/sequential/test-heapdump-flag-custom-dir.js +++ b/test/sequential/test-heapdump-flag-custom-dir.js @@ -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'; diff --git a/test/sequential/test-http-econnrefused.js b/test/sequential/test-http-econnrefused.js index 4d0f7a174e..e326357a51 100644 --- a/test/sequential/test-http-econnrefused.js +++ b/test/sequential/test-http-econnrefused.js @@ -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)); } diff --git a/test/sequential/test-http-keepalive-maxsockets.js b/test/sequential/test-http-keepalive-maxsockets.js index 9c98a140f6..a9775e88ad 100644 --- a/test/sequential/test-http-keepalive-maxsockets.js +++ b/test/sequential/test-http-keepalive-maxsockets.js @@ -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); } -}); +})); diff --git a/test/sequential/test-http2-max-session-memory.js b/test/sequential/test-http2-max-session-memory.js index 9b77a45c32..229bd73744 100644 --- a/test/sequential/test-http2-max-session-memory.js +++ b/test/sequential/test-http2-max-session-memory.js @@ -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()); diff --git a/test/sequential/test-http2-ping-flood.js b/test/sequential/test-http2-ping-flood.js index b414aca8a4..0f324c30d0 100644 --- a/test/sequential/test-http2-ping-flood.js +++ b/test/sequential/test-http2-ping-flood.js @@ -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(); })); diff --git a/test/sequential/test-http2-settings-flood.js b/test/sequential/test-http2-settings-flood.js index 15b3696b9c..8d9efc4c1a 100644 --- a/test/sequential/test-http2-settings-flood.js +++ b/test/sequential/test-http2-settings-flood.js @@ -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(); diff --git a/test/sequential/test-http2-timeout-large-write-file.js b/test/sequential/test-http2-timeout-large-write-file.js index a35268b612..15c7d9f0ae 100644 --- a/test/sequential/test-http2-timeout-large-write-file.js +++ b/test/sequential/test-http2-timeout-large-write-file.js @@ -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}`, diff --git a/test/sequential/test-http2-timeout-large-write.js b/test/sequential/test-http2-timeout-large-write.js index 73114776df..9f21042d88 100644 --- a/test/sequential/test-http2-timeout-large-write.js +++ b/test/sequential/test-http2-timeout-large-write.js @@ -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}`, diff --git a/test/sequential/test-inspector-open-dispose.mjs b/test/sequential/test-inspector-open-dispose.mjs index d3add569c9..2e57354fbb 100644 --- a/test/sequential/test-inspector-open-dispose.mjs +++ b/test/sequential/test-inspector-open-dispose.mjs @@ -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) { diff --git a/test/sequential/test-module-loading.js b/test/sequential/test-module-loading.js index 1d30a2ba73..b4f2d26330 100644 --- a/test/sequential/test-module-loading.js +++ b/test/sequential/test-module-loading.js @@ -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 diff --git a/test/sequential/test-net-connect-econnrefused.js b/test/sequential/test-net-connect-econnrefused.js index c55a9ebe24..67f5820221 100644 --- a/test/sequential/test-net-connect-econnrefused.js +++ b/test/sequential/test-net-connect-econnrefused.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++; } } diff --git a/test/sequential/test-net-localport.js b/test/sequential/test-net-localport.js index e90df73e52..4539acaaee 100644 --- a/test/sequential/test-net-localport.js +++ b/test/sequential/test-net-localport.js @@ -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); - }); -}); + })); +})); diff --git a/test/sequential/test-net-server-bind.js b/test/sequential/test-net-server-bind.js index 56216d0ed6..f1f274a01d 100644 --- a/test/sequential/test-net-server-bind.js +++ b/test/sequential/test-net-server-bind.js @@ -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() diff --git a/test/sequential/test-pipe.js b/test/sequential/test-pipe.js index c3e0ddef9f..4defd4628e 100644 --- a/test/sequential/test-pipe.js +++ b/test/sequential/test-pipe.js @@ -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); diff --git a/test/sequential/test-process-title.js b/test/sequential/test-process-title.js index 13a030decf..b4f4b02517 100644 --- a/test/sequential/test-process-title.js +++ b/test/sequential/test-process-title.js @@ -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); diff --git a/test/sequential/test-process-warnings.js b/test/sequential/test-process-warnings.js index f4457e137e..eca6432fbe 100644 --- a/test/sequential/test-process-warnings.js +++ b/test/sequential/test-process-warnings.js @@ -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\.\s\(.+warnings\.js:3:9\)/); -}); +})); diff --git a/test/sequential/test-repl-timeout-throw.js b/test/sequential/test-repl-timeout-throw.js index f788ab295b..d8f1df9564 100644 --- a/test/sequential/test-repl-timeout-throw.js +++ b/test/sequential/test-repl-timeout-throw.js @@ -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'); -}); +})); diff --git a/test/sequential/test-stream2-fs.js b/test/sequential/test-stream2-fs.js index 3d06abc921..10414eaab3 100644 --- a/test/sequential/test-stream2-fs.js +++ b/test/sequential/test-stream2-fs.js @@ -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); diff --git a/test/sequential/test-stream2-stderr-sync.js b/test/sequential/test-stream2-stderr-sync.js index db0ed180ed..7704ba8fd2 100644 --- a/test/sequential/test-stream2-stderr-sync.js +++ b/test/sequential/test-stream2-stderr-sync.js @@ -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}`); - }); + })); }); } diff --git a/test/sequential/test-timers-block-eventloop.js b/test/sequential/test-timers-block-eventloop.js index 6118695c92..25f96d6b37 100644 --- a/test/sequential/test-timers-block-eventloop.js +++ b/test/sequential/test-timers-block-eventloop.js @@ -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); diff --git a/test/sequential/test-timers-set-interval-excludes-callback-duration.js b/test/sequential/test-timers-set-interval-excludes-callback-duration.js index b32c7e7e3c..23127afc59 100644 --- a/test/sequential/test-timers-set-interval-excludes-callback-duration.js +++ b/test/sequential/test-timers-set-interval-excludes-callback-duration.js @@ -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); diff --git a/test/sequential/test-tls-psk-client.js b/test/sequential/test-tls-psk-client.js index c07b1f92d9..c9a904e729 100644 --- a/test/sequential/test-tls-psk-client.js +++ b/test/sequential/test-tls-psk-client.js @@ -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); diff --git a/test/sequential/test-tls-session-timeout.js b/test/sequential/test-tls-session-timeout.js index 14baabd7a6..44e8d537fc 100644 --- a/test/sequential/test-tls-session-timeout.js +++ b/test/sequential/test-tls-session-timeout.js @@ -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) => { diff --git a/test/sequential/test-without-async-context-frame.mjs b/test/sequential/test-without-async-context-frame.mjs index 087bb67b71..e7342f03a4 100644 --- a/test/sequential/test-without-async-context-frame.mjs +++ b/test/sequential/test-without-async-context-frame.mjs @@ -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); diff --git a/test/sequential/test-worker-eventlooputil.js b/test/sequential/test-worker-eventlooputil.js index bf7ff7da00..39c6d723ff 100644 --- a/test/sequential/test-worker-eventlooputil.js +++ b/test/sequential/test-worker-eventlooputil.js @@ -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) {