From de4bcae551c6789dea8bad50cc243f59f44a83d9 Mon Sep 17 00:00:00 2001 From: Denys Otrishko Date: Mon, 24 Feb 2020 14:54:51 +0200 Subject: [PATCH 1/2] test: fix usage of invalid common properties --- test/common/index.js | 2 +- test/common/index.mjs | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/test/common/index.js b/test/common/index.js index 2e2d14dc0e6d43..1e66e32c9c1260 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -717,7 +717,7 @@ module.exports = { skipIfReportDisabled, skipIfWorker, - get enoughTestCPU() { + get enoughTestCpu() { const cpus = require('os').cpus(); return Array.isArray(cpus) && (cpus.length > 1 || cpus[0].speed > 999); }, diff --git a/test/common/index.mjs b/test/common/index.mjs index a5774fc008a9b3..96e6699e3c6f99 100644 --- a/test/common/index.mjs +++ b/test/common/index.mjs @@ -37,7 +37,6 @@ const { mustNotCall, printSkipMessage, skip, - ArrayStream, nodeProcessAborted, isAlive, expectWarning, @@ -83,7 +82,6 @@ export { mustNotCall, printSkipMessage, skip, - ArrayStream, nodeProcessAborted, isAlive, expectWarning, From 1badb1582e1586fc071f68a315cc03d0bb6cee92 Mon Sep 17 00:00:00 2001 From: Denys Otrishko Date: Mon, 24 Feb 2020 14:55:14 +0200 Subject: [PATCH 2/2] test: validate common property usage `common` contains multiple 'check'(boolean) properties that will be false if mistyped and may lead to errors. This makes sure that the used property exists in the `common`. --- test/common/index.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/test/common/index.js b/test/common/index.js index 1e66e32c9c1260..653de4685ca7a0 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -672,7 +672,7 @@ function invalidArgTypeHelper(input) { return ` Received type ${typeof input} (${inspected})`; } -module.exports = { +const common = { allowGlobals, buildType, canCreateSymLink, @@ -815,3 +815,12 @@ module.exports = { } }; + +const validProperties = new Set(Object.keys(common)); +module.exports = new Proxy(common, { + get(obj, prop) { + if (!validProperties.has(prop)) + throw new Error(`Using invalid common property: '${prop}'`); + return obj[prop]; + } +});