Skip to content

Commit

Permalink
test: add trailing commas in test/common (#45550)
Browse files Browse the repository at this point in the history
PR-URL: #45550
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 ruyadorno committed Nov 21, 2022
1 parent 246cd35 commit d6c68ce
Show file tree
Hide file tree
Showing 23 changed files with 63 additions and 64 deletions.
1 change: 0 additions & 1 deletion test/.eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ overrides:
- files:
- addons/*/*.js
- async-hooks/*.js
- common/*.js
- es-module/*.js
- es-module/*.mjs
- internet/*.js
Expand Down
4 changes: 2 additions & 2 deletions test/common/benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function runBenchmark(name, env) {

const child = fork(runjs, argv, {
env: mergedEnv,
stdio: ['inherit', 'pipe', 'inherit', 'ipc']
stdio: ['inherit', 'pipe', 'inherit', 'ipc'],
});
child.stdout.setEncoding('utf8');

Expand All @@ -35,7 +35,7 @@ function runBenchmark(name, env) {
// get from testing the benchmark file.
assert.ok(
/^(?:\n.+?\n.+?\n)+$/.test(stdout),
`benchmark file not running exactly one configuration in test: ${stdout}`
`benchmark file not running exactly one configuration in test: ${stdout}`,
);
});
}
Expand Down
2 changes: 1 addition & 1 deletion test/common/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ module.exports = {
cleanupStaleProcess,
logAfterTime,
kExpiringChildRunTime,
kExpiringParentTimer
kExpiringParentTimer,
};
4 changes: 2 additions & 2 deletions test/common/cpu-prof.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ function verifyFrames(output, file, suffix) {
const kCpuProfInterval = 50;
const env = {
...process.env,
NODE_DEBUG_NATIVE: 'INSPECTOR_PROFILER'
NODE_DEBUG_NATIVE: 'INSPECTOR_PROFILER',
};

module.exports = {
getCpuProfiles,
kCpuProfInterval,
env,
getFrames,
verifyFrames
verifyFrames,
};
6 changes: 3 additions & 3 deletions test/common/crypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ function testDH({ publicKey: alicePublicKey, privateKey: alicePrivateKey },
expectedValue) {
const buf1 = crypto.diffieHellman({
privateKey: alicePrivateKey,
publicKey: bobPublicKey
publicKey: bobPublicKey,
});
const buf2 = crypto.diffieHellman({
privateKey: bobPrivateKey,
publicKey: alicePublicKey
publicKey: alicePublicKey,
});
assert.deepStrictEqual(buf1, buf2);

Expand All @@ -44,5 +44,5 @@ function testDH({ publicKey: alicePublicKey, privateKey: alicePrivateKey },

module.exports = {
modp2buf,
testDH
testDH,
};
10 changes: 5 additions & 5 deletions test/common/dns.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ const types = {
MX: 15,
TXT: 16,
ANY: 255,
CAA: 257
CAA: 257,
};

const classes = {
IN: 1
IN: 1,
};

// Naïve DNS parser/serializer.
Expand All @@ -34,7 +34,7 @@ function readDomainFromPacket(buffer, offset) {
const { nread, domain } = readDomainFromPacket(buffer, offset + length);
return {
nread: 1 + length + nread,
domain: domain ? `${chunk}.${domain}` : chunk
domain: domain ? `${chunk}.${domain}` : chunk,
};
}
// Pointer to another part of the packet.
Expand All @@ -43,7 +43,7 @@ function readDomainFromPacket(buffer, offset) {
const pointeeOffset = buffer.readUInt16BE(offset) &~ 0xC000;
return {
nread: 2,
domain: readDomainFromPacket(buffer, pointeeOffset)
domain: readDomainFromPacket(buffer, pointeeOffset),
};
}

Expand Down Expand Up @@ -316,5 +316,5 @@ module.exports = {
parseDNSPacket,
errorLookupMock,
mockedErrorCode,
mockedSysCall
mockedSysCall,
};
18 changes: 9 additions & 9 deletions test/common/heap.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function createJSHeapSnapshot(stream = getHeapSnapshot()) {
type,
to: toNode,
from: fromNode,
name: typeof name_or_index === 'string' ? name_or_index : null
name: typeof name_or_index === 'string' ? name_or_index : null,
};
toNode.incomingEdges.push(edge);
fromNode.outgoingEdges.push(edge);
Expand Down Expand Up @@ -130,7 +130,7 @@ class State {
const check = typeof expectedEdge === 'function' ? expectedEdge :
(edge) => (isEdge(edge, expectedEdge));
const hasChild = rootNodes.some(
(node) => node.outgoingEdges.some(check)
(node) => node.outgoingEdges.some(check),
);
// Don't use assert with a custom message here. Otherwise the
// inspection in the message is done eagerly and wastes a lot of CPU
Expand Down Expand Up @@ -164,7 +164,7 @@ class State {
// Validate our internal embedded graph representation
validateGraph(rootName, expected, { loose = false } = {}) {
const rootNodes = this.embedderGraph.filter(
(node) => node.name === rootName
(node) => node.name === rootName,
);
if (loose) {
assert(rootNodes.length >= expected.length,
Expand All @@ -185,7 +185,7 @@ class State {
// inspection in the message is done eagerly and wastes a lot of CPU
// time.
const hasChild = rootNodes.some(
(node) => node.edges.some(check)
(node) => node.edges.some(check),
);
if (!hasChild) {
throw new Error(
Expand Down Expand Up @@ -221,16 +221,16 @@ function getHeapSnapshotOptionTests() {
// We don't have anything special to test here yet
// because we don't use cppgc or embedder heap tracer.
{ edge_name: 'nonNumeric', node_name: 'test' },
]
}]
],
}],
},
{
options: { exposeNumericValues: true },
expected: [{
children: [
{ edge_name: 'numeric', node_name: 'smi number' },
]
}]
],
}],
},
];
return {
Expand All @@ -245,5 +245,5 @@ function getHeapSnapshotOptionTests() {
module.exports = {
recordState,
validateSnapshotNodes,
getHeapSnapshotOptionTests
getHeapSnapshotOptionTests,
};
2 changes: 1 addition & 1 deletion test/common/hijackstdio.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ module.exports = {
hijackStdout: hijackStdWritable.bind(null, 'stdout'),
hijackStderr: hijackStdWritable.bind(null, 'stderr'),
restoreStdout: restoreWritable.bind(null, 'stdout'),
restoreStderr: restoreWritable.bind(null, 'stderr')
restoreStderr: restoreWritable.bind(null, 'stderr'),
};
2 changes: 1 addition & 1 deletion test/common/http2.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,5 +144,5 @@ module.exports = {
PingFrame,
kFakeRequestHeaders,
kFakeResponseHeaders,
kClientMagic
kClientMagic,
};
16 changes: 8 additions & 8 deletions test/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const hasIntl = !!process.config.variables.v8_enable_i18n_support;

const {
atob,
btoa
btoa,
} = require('buffer');

// Some tests assume a umask of 0o022 so set that up front. Tests that need a
Expand Down Expand Up @@ -98,7 +98,7 @@ if (process.argv.length === 2 &&
console.log(
'NOTE: The test started as a child_process using these flags:',
inspect(flags),
'Use NODE_SKIP_FLAG_CHECK to run the test with the original flags.'
'Use NODE_SKIP_FLAG_CHECK to run the test with the original flags.',
);
const args = [...flags, ...process.execArgv, ...process.argv.slice(1)];
const options = { encoding: 'utf8', stdio: 'inherit' };
Expand Down Expand Up @@ -175,7 +175,7 @@ if (process.env.NODE_TEST_WITH_ASYNC_HOOKS) {
}
initHandles[id] = {
resource,
stack: inspect(new Error()).substr(6)
stack: inspect(new Error()).substr(6),
};
},
before() { },
Expand Down Expand Up @@ -435,7 +435,7 @@ function _mustCallInner(fn, criteria = 1, field) {
[field]: criteria,
actual: 0,
stack: inspect(new Error()),
name: fn.name || '<anonymous>'
name: fn.name || '<anonymous>',
};

// Add the exit listener only once to avoid listener leak warnings
Expand Down Expand Up @@ -478,7 +478,7 @@ function hasMultiLocalhost() {

function skipIfEslintMissing() {
if (!fs.existsSync(
path.join(__dirname, '..', '..', 'tools', 'node_modules', 'eslint')
path.join(__dirname, '..', '..', 'tools', 'node_modules', 'eslint'),
)) {
skip('missing ESLint');
}
Expand Down Expand Up @@ -567,7 +567,7 @@ function mustNotMutateObjectDeep(original) {
},
setPrototypeOf(target, prototype) {
assert.fail(`Expected no side effects, got set prototype to ${prototype}`);
}
},
};

const proxy = new Proxy(original, _mustNotMutateObjectDeepHandler);
Expand Down Expand Up @@ -670,7 +670,7 @@ function expectWarning(nameOrMap, expected, code) {
if (!catchWarning[warning.name]) {
throw new TypeError(
`"${warning.name}" was triggered without being expected.\n` +
inspect(warning)
inspect(warning),
);
}
catchWarning[warning.name](warning);
Expand Down Expand Up @@ -1034,5 +1034,5 @@ module.exports = new Proxy(common, {
if (!validProperties.has(prop))
throw new Error(`Using invalid common property: '${prop}'`);
return obj[prop];
}
},
});
6 changes: 3 additions & 3 deletions test/common/inspector-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,8 @@ class NodeInstance extends EventEmitter {
'Connection': 'Upgrade',
'Upgrade': 'websocket',
'Sec-WebSocket-Version': 13,
'Sec-WebSocket-Key': 'key=='
}
'Sec-WebSocket-Key': 'key==',
},
});
}

Expand Down Expand Up @@ -530,5 +530,5 @@ function fires(promise, error, timeoutMs) {
}

module.exports = {
NodeInstance
NodeInstance,
};
4 changes: 2 additions & 2 deletions test/common/internet.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const addresses = {
// An accessible IPv4 DNS server
DNS4_SERVER: '8.8.8.8',
// An accessible IPv4 DNS server
DNS6_SERVER: '2001:4860:4860::8888'
DNS6_SERVER: '2001:4860:4860::8888',
};

for (const key of Object.keys(addresses)) {
Expand All @@ -54,5 +54,5 @@ for (const key of Object.keys(addresses)) {
}

module.exports = {
addresses
addresses,
};
4 changes: 2 additions & 2 deletions test/common/measure-memory.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ function assertSingleDetailedShape(result) {
function expectExperimentalWarning() {
common.expectWarning(
'ExperimentalWarning',
'vm.measureMemory is an experimental feature and might change at any time'
'vm.measureMemory is an experimental feature and might change at any time',
);
}

module.exports = {
assertSummaryShape,
assertDetailedShape,
assertSingleDetailedShape,
expectExperimentalWarning
expectExperimentalWarning,
};
2 changes: 1 addition & 1 deletion test/common/ongc.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function onGC(obj, gcListener) {
this.gcListener.ongc();
onGcAsyncHook.disable();
}
}
},
}).enable();
onGcAsyncHook.gcListener = gcListener;

Expand Down
6 changes: 3 additions & 3 deletions test/common/prof.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function getHeapProfiles(dir) {

function findFirstFrameInNode(root, func) {
const first = root.children.find(
(child) => child.callFrame.functionName === func
(child) => child.callFrame.functionName === func,
);
if (first) {
return first;
Expand Down Expand Up @@ -53,7 +53,7 @@ const TEST_ALLOCATION = kHeapProfInterval * 2;
const env = {
...process.env,
TEST_ALLOCATION,
NODE_DEBUG_NATIVE: 'INSPECTOR_PROFILER'
NODE_DEBUG_NATIVE: 'INSPECTOR_PROFILER',
};

// TODO(joyeecheung): share the fixutres with v8 coverage tests
Expand All @@ -63,5 +63,5 @@ module.exports = {
findFirstFrame,
kHeapProfInterval,
TEST_ALLOCATION,
env
env,
};
2 changes: 1 addition & 1 deletion test/common/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ function _validateContent(report, fields = []) {
for (let i = 0; i < jsHeapFields.length - 1; i++) {
assert(
Number.isSafeInteger(heap[jsHeapFields[i]]),
`heap.${jsHeapFields[i]} is not a safe integer`
`heap.${jsHeapFields[i]} is not a safe integer`,
);
}
assert(typeof heap.heapSpaces === 'object' && heap.heapSpaces !== null);
Expand Down
2 changes: 1 addition & 1 deletion test/common/require-as.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const { Worker, isMainThread, workerData } = require('worker_threads');
if (isMainThread) {
if (process.argv[2] === 'worker') {
new Worker(__filename, {
workerData: process.argv[3]
workerData: process.argv[3],
});
return;
}
Expand Down
2 changes: 1 addition & 1 deletion test/common/shared-lib-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ function getBinaryPath() {
module.exports = {
addLibraryPath,
getBinaryPath,
getSharedLibPath
getSharedLibPath,
};
2 changes: 1 addition & 1 deletion test/common/snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function runWithSnapshot(entry, env) {
env: {
...process.env,
...env,
}
},
});

const stderr = child.stderr.toString();
Expand Down
2 changes: 1 addition & 1 deletion test/common/tls.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class TestTLSSocket extends net.Socket {
createClientKeyExchange() {
const encrypted_pre_primary_secret = crypto.publicEncrypt({
key: this.server_cert,
padding: crypto.constants.RSA_PKCS1_PADDING
padding: crypto.constants.RSA_PKCS1_PADDING,
}, this.pre_primary_secret);
const length = Buffer.alloc(2);
length.writeUIntBE(encrypted_pre_primary_secret.length, 0, 2);
Expand Down
2 changes: 1 addition & 1 deletion test/common/tmpdir.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,5 @@ function onexit() {

module.exports = {
path: tmpPath,
refresh
refresh,
};
Loading

0 comments on commit d6c68ce

Please sign in to comment.