From 8e57090d2ffe0d219048fa6402b1609b94253da3 Mon Sep 17 00:00:00 2001 From: Denys Otrishko Date: Mon, 24 Feb 2020 14:55:14 +0200 Subject: [PATCH] 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`. PR-URL: https://github.com/nodejs/node/pull/31933 Reviewed-By: Luigi Pinca Reviewed-By: Shelley Vohr Reviewed-By: Yongsheng Zhang Reviewed-By: Rich Trott Reviewed-By: Anna Henningsen --- 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 1b82d8487287bf..a1388a20a1d53e 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -739,7 +739,7 @@ function invalidArgTypeHelper(input) { return ` Received type ${typeof input} (${inspected})`; } -module.exports = { +const common = { allowGlobals, buildType, canCreateSymLink, @@ -882,3 +882,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]; + } +});