Skip to content

Commit

Permalink
test: add trailing commas in async-hooks tests (#45549)
Browse files Browse the repository at this point in the history
PR-URL: #45549
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
  • Loading branch information
aduh95 authored and danielleadams committed Jan 3, 2023
1 parent d5b0844 commit 8f7109a
Show file tree
Hide file tree
Showing 49 changed files with 78 additions and 79 deletions.
1 change: 0 additions & 1 deletion test/.eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ globals:

overrides:
- files:
- async-hooks/*.js
- es-module/*.js
- es-module/*.mjs
- internet/*.js
Expand Down
2 changes: 1 addition & 1 deletion test/async-hooks/hook-checks.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ exports.checkInvocations = function checkInvocations(activity, hooks, stage) {

assert.ok(activity != null,
`${stageInfo} Trying to check invocation for an activity, ` +
'but it was empty/undefined.'
'but it was empty/undefined.',
);

// Check that actual invocations for all hooks match the expected invocations
Expand Down
10 changes: 5 additions & 5 deletions test/async-hooks/init-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ActivityCollector {
ondestroy,
onpromiseResolve,
logid = null,
logtype = null
logtype = null,
} = {}) {
this._start = start;
this._allowNoInit = allowNoInit;
Expand All @@ -49,7 +49,7 @@ class ActivityCollector {
before: this._before.bind(this),
after: this._after.bind(this),
destroy: this._destroy.bind(this),
promiseResolve: this._promiseResolve.bind(this)
promiseResolve: this._promiseResolve.bind(this),
});
}

Expand Down Expand Up @@ -181,7 +181,7 @@ class ActivityCollector {
// In some cases (e.g. Timeout) the handle is a function, thus the usual
// `typeof handle === 'object' && handle !== null` check can't be used.
handleIsObject: handle instanceof Object,
handle
handle,
};
this._stamp(activity, 'init');
this._activities.set(uid, activity);
Expand Down Expand Up @@ -233,7 +233,7 @@ exports = module.exports = function initHooks({
onpromiseResolve,
allowNoInit,
logid,
logtype
logtype,
} = {}) {
return new ActivityCollector(process.hrtime(), {
oninit,
Expand All @@ -243,6 +243,6 @@ exports = module.exports = function initHooks({
onpromiseResolve,
allowNoInit,
logid,
logtype
logtype,
});
};
2 changes: 1 addition & 1 deletion test/async-hooks/test-async-await.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const hooks = initHooks({
onbefore,
onafter,
ondestroy: null, // Intentionally not tested, since it will be removed soon
onpromiseResolve
onpromiseResolve,
});
hooks.enable();

Expand Down
2 changes: 1 addition & 1 deletion test/async-hooks/test-async-exec-resource-http-32060.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const hooked = {};
createHook({
init(asyncId, type, triggerAsyncId, resource) {
hooked[asyncId] = resource;
}
},
}).enable();

const server = http.createServer((req, res) => {
Expand Down
2 changes: 1 addition & 1 deletion test/async-hooks/test-async-exec-resource-http.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const hooked = {};
createHook({
init(asyncId, type, triggerAsyncId, resource) {
hooked[asyncId] = resource;
}
},
}).enable();

const server = http.createServer((req, res) => {
Expand Down
4 changes: 2 additions & 2 deletions test/async-hooks/test-async-exec-resource-match.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { readFile } = require('fs');
const {
createHook,
executionAsyncResource,
AsyncResource
AsyncResource,
} = require('async_hooks');

// Ignore any asyncIds created before our hook is active.
Expand All @@ -32,7 +32,7 @@ createHook({
if (asyncId >= firstSeenAsyncId) {
afterHook(asyncId);
}
}
},
}).enable();

const beforeHook = common.mustCallAtLeast(
Expand Down
2 changes: 1 addition & 1 deletion test/async-hooks/test-async-local-storage-http-agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const http = require('http');
const asyncLocalStorage = new AsyncLocalStorage();

const agent = new http.Agent({
maxSockets: 1
maxSockets: 1,
});

const N = 3;
Expand Down
6 changes: 3 additions & 3 deletions test/async-hooks/test-async-local-storage-stop-propagation.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function onPropagate(type, store) {
}

const als = new AsyncLocalStorage({
onPropagate: common.mustCall(onPropagate, 2)
onPropagate: common.mustCall(onPropagate, 2),
});

const myStore = {};
Expand All @@ -40,11 +40,11 @@ als.run(myStore, common.mustCall(() => {
assert.throws(() => new AsyncLocalStorage(15), {
message: 'The "options" argument must be of type object. Received type number (15)',
code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError'
name: 'TypeError',
});

assert.throws(() => new AsyncLocalStorage({ onPropagate: 'bar' }), {
message: 'The "options.onPropagate" property must be of type function. Received type string (\'bar\')',
code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError'
name: 'TypeError',
});
2 changes: 1 addition & 1 deletion test/async-hooks/test-async-local-storage-thenable.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const then = common.mustCall((cb) => {

function thenable() {
return {
then
then,
};
}

Expand Down
2 changes: 1 addition & 1 deletion test/async-hooks/test-async-local-storage-tlssocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const { AsyncLocalStorage } = require('async_hooks');
const options = {
cert: fixtures.readKey('rsa_cert.crt'),
key: fixtures.readKey('rsa_private.pem'),
rejectUnauthorized: false
rejectUnauthorized: false,
};

tls
Expand Down
6 changes: 3 additions & 3 deletions test/async-hooks/test-callback-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ const arg = process.argv[2];
switch (arg) {
case 'test_init_callback':
initHooks({
oninit: common.mustCall(() => { throw new Error(arg); })
oninit: common.mustCall(() => { throw new Error(arg); }),
}).enable();
new async_hooks.AsyncResource(`${arg}_type`);
return;

case 'test_callback': {
initHooks({
onbefore: common.mustCall(() => { throw new Error(arg); })
onbefore: common.mustCall(() => { throw new Error(arg); }),
}).enable();
const resource = new async_hooks.AsyncResource(`${arg}_type`);
resource.runInAsyncScope(() => {});
Expand All @@ -25,7 +25,7 @@ switch (arg) {

case 'test_callback_abort':
initHooks({
oninit: common.mustCall(() => { throw new Error(arg); })
oninit: common.mustCall(() => { throw new Error(arg); }),
}).enable();
new async_hooks.AsyncResource(`${arg}_type`);
return;
Expand Down
10 changes: 5 additions & 5 deletions test/async-hooks/test-destroy-not-blocked.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ createHook({
if (activeId === id) {
activeId = -1;
}
}
},
}).enable();

function testNextTick() {
Expand All @@ -33,7 +33,7 @@ function testNextTick() {
res.emitDestroy();
// nextTick has higher prio than emit destroy
process.nextTick(common.mustCall(() =>
assert.strictEqual(activeId, res.asyncId()))
assert.strictEqual(activeId, res.asyncId())),
);
}

Expand All @@ -44,7 +44,7 @@ function testQueueMicrotask() {
res.emitDestroy();
// queueMicrotask has higher prio than emit destroy
queueMicrotask(common.mustCall(() =>
assert.strictEqual(activeId, res.asyncId()))
assert.strictEqual(activeId, res.asyncId())),
);
}

Expand All @@ -54,7 +54,7 @@ function testImmediate() {
assert.strictEqual(activeId, res.asyncId());
res.emitDestroy();
setImmediate(common.mustCall(() =>
assert.strictEqual(activeId, -1))
assert.strictEqual(activeId, -1)),
);
}

Expand All @@ -65,7 +65,7 @@ function testPromise() {
res.emitDestroy();
// Promise has higher prio than emit destroy
Promise.resolve().then(common.mustCall(() =>
assert.strictEqual(activeId, res.asyncId()))
assert.strictEqual(activeId, res.asyncId())),
);
}

Expand Down
4 changes: 2 additions & 2 deletions test/async-hooks/test-disable-in-init.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ async_hooks.createHook({
nestedCall = true;
fs.access(__filename, common.mustCall());
}
}, 2)
}, 2),
}).enable();

const nestedHook = async_hooks.createHook({
init: common.mustCall(2)
init: common.mustCall(2),
}).enable();

fs.access(__filename, common.mustCall());
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ if (process.argv[2] === 'child') {
[null, undefined, 1, Date, {}, []].forEach((i) => {
assert.throws(() => new Foo(i), {
code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError'
name: 'TypeError',
});
});

Expand Down
2 changes: 1 addition & 1 deletion test/async-hooks/test-embedder.api.async-resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ assert.throws(() => {

assert.strictEqual(
new AsyncResource('default_trigger_id').triggerAsyncId(),
async_hooks.executionAsyncId()
async_hooks.executionAsyncId(),
);

// Create first custom event 'alcazares' with triggerAsyncId derived
Expand Down
2 changes: 1 addition & 1 deletion test/async-hooks/test-emit-after-on-destroyed.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const heartbeatMsg = /heartbeat: still alive/;

const {
newAsyncId, getDefaultTriggerAsyncId,
emitInit, emitBefore, emitAfter, emitDestroy
emitInit, emitBefore, emitAfter, emitDestroy,
} = internal_async_hooks;

const initHooks = require('./init-hooks');
Expand Down
2 changes: 1 addition & 1 deletion test/async-hooks/test-emit-before-after.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const checkOnce = (fn) => {
initHooks({
onbefore: checkOnce(chkBefore),
onafter: checkOnce(chkAfter),
allowNoInit: true
allowNoInit: true,
}).enable();

async_hooks.emitInit(expectedId, expectedType, expectedTriggerId);
Expand Down
2 changes: 1 addition & 1 deletion test/async-hooks/test-emit-before-on-destroyed.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const heartbeatMsg = /heartbeat: still alive/;

const {
newAsyncId, getDefaultTriggerAsyncId,
emitInit, emitBefore, emitAfter, emitDestroy
emitInit, emitBefore, emitAfter, emitDestroy,
} = internal_async_hooks;

const initHooks = require('./init-hooks');
Expand Down
4 changes: 2 additions & 2 deletions test/async-hooks/test-emit-init.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const hooks1 = initHooks({
assert.strictEqual(type, expectedType);
assert.strictEqual(triggerAsyncId, expectedTriggerId);
assert.strictEqual(resource.key, expectedResource.key);
})
}),
});

hooks1.enable();
Expand All @@ -33,7 +33,7 @@ initHooks({
assert.strictEqual(type, expectedType);
assert.notStrictEqual(triggerAsyncId, expectedTriggerId);
assert.strictEqual(resource.key, expectedResource.key);
})
}),
}).enable();

async_hooks.emitInit(expectedId, expectedType, null, expectedResource);
4 changes: 2 additions & 2 deletions test/async-hooks/test-enable-in-init.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const async_hooks = require('async_hooks');
const fs = require('fs');

const nestedHook = async_hooks.createHook({
init: common.mustNotCall()
init: common.mustNotCall(),
});
let nestedCall = false;

Expand All @@ -16,7 +16,7 @@ async_hooks.createHook({
nestedCall = true;
fs.access(__filename, common.mustCall());
}
}, 2)
}, 2),
}).enable();

fs.access(__filename, common.mustCall());
4 changes: 2 additions & 2 deletions test/async-hooks/test-filehandle-no-reuse.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const hooks = initHooks();
hooks.enable();

const {
HTTP2_HEADER_CONTENT_TYPE
HTTP2_HEADER_CONTENT_TYPE,
} = http2.constants;

// Use large fixture to get several file operations.
Expand All @@ -27,7 +27,7 @@ const fd = fs.openSync(fname, 'r');
const server = http2.createServer();
server.on('stream', (stream) => {
stream.respondWithFD(fd, {
[HTTP2_HEADER_CONTENT_TYPE]: 'text/plain'
[HTTP2_HEADER_CONTENT_TYPE]: 'text/plain',
});
});
server.on('close', common.mustCall(() => fs.closeSync(fd)));
Expand Down
2 changes: 1 addition & 1 deletion test/async-hooks/test-graph.fsreq-readFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ function onexit() {
[ { type: 'FSREQCALLBACK', id: 'fsreq:1', triggerAsyncId: null },
{ type: 'FSREQCALLBACK', id: 'fsreq:2', triggerAsyncId: 'fsreq:1' },
{ type: 'FSREQCALLBACK', id: 'fsreq:3', triggerAsyncId: 'fsreq:2' },
{ type: 'FSREQCALLBACK', id: 'fsreq:4', triggerAsyncId: 'fsreq:3' } ]
{ type: 'FSREQCALLBACK', id: 'fsreq:4', triggerAsyncId: 'fsreq:3' } ],
);
}
4 changes: 2 additions & 2 deletions test/async-hooks/test-graph.http.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ server.listen(0, common.mustCall(() => {
http.get({
host: '::1',
family: 6,
port: server.address().port
port: server.address().port,
}, common.mustCall());
}));

Expand Down Expand Up @@ -47,6 +47,6 @@ process.on('exit', () => {
triggerAsyncId: null },
{ type: 'SHUTDOWNWRAP',
id: 'shutdown:1',
triggerAsyncId: 'tcp:2' } ]
triggerAsyncId: 'tcp:2' } ],
);
});
2 changes: 1 addition & 1 deletion test/async-hooks/test-graph.intervals.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ function onexit() {
verifyGraph(
hooks,
[ { type: 'Timeout', id: 'timeout:1', triggerAsyncId: null },
{ type: 'Timeout', id: 'timeout:2', triggerAsyncId: 'timeout:1' }]
{ type: 'Timeout', id: 'timeout:2', triggerAsyncId: 'timeout:1' }],
);
}
2 changes: 1 addition & 1 deletion test/async-hooks/test-graph.pipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ function onexit() {
[ { type: 'PROCESSWRAP', id: 'process:1', triggerAsyncId: null },
{ type: 'PIPEWRAP', id: 'pipe:1', triggerAsyncId: null },
{ type: 'PIPEWRAP', id: 'pipe:2', triggerAsyncId: null },
{ type: 'PIPEWRAP', id: 'pipe:3', triggerAsyncId: null } ]
{ type: 'PIPEWRAP', id: 'pipe:3', triggerAsyncId: null } ],
);
}
2 changes: 1 addition & 1 deletion test/async-hooks/test-graph.pipeconnect.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ function onexit() {
{ type: 'PIPECONNECTWRAP', id: 'pipeconnect:1',
triggerAsyncId: 'pipe:1' },
{ type: 'PIPEWRAP', id: 'pipe:2', triggerAsyncId: 'pipeserver:1' },
{ type: 'SHUTDOWNWRAP', id: 'shutdown:1', triggerAsyncId: 'pipe:2' } ]
{ type: 'SHUTDOWNWRAP', id: 'shutdown:1', triggerAsyncId: 'pipe:2' } ],
);
}
2 changes: 1 addition & 1 deletion test/async-hooks/test-graph.shutdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ function onexit() {
{ type: 'TCPCONNECTWRAP',
id: 'tcpconnect:1', triggerAsyncId: 'tcp:1' },
{ type: 'TCPWRAP', id: 'tcp:2', triggerAsyncId: 'tcpserver:1' },
{ type: 'SHUTDOWNWRAP', id: 'shutdown:1', triggerAsyncId: 'tcp:2' } ]
{ type: 'SHUTDOWNWRAP', id: 'shutdown:1', triggerAsyncId: 'tcp:2' } ],
);
}
Loading

0 comments on commit 8f7109a

Please sign in to comment.