Skip to content

Commit

Permalink
test: validate common property usage
Browse files Browse the repository at this point in the history
`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: #31933
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Shelley Vohr <[email protected]>
Reviewed-By: Yongsheng Zhang <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
  • Loading branch information
lundibundi authored and codebytere committed Mar 30, 2020
1 parent 26d9f4c commit 67c3a95
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion test/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ function invalidArgTypeHelper(input) {
return ` Received type ${typeof input} (${inspected})`;
}

module.exports = {
const common = {
allowGlobals,
buildType,
canCreateSymLink,
Expand Down Expand Up @@ -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];
}
});

0 comments on commit 67c3a95

Please sign in to comment.