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 <luigipinca@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
  • Loading branch information
lundibundi authored and codebytere committed Feb 27, 2020
1 parent ab8f060 commit f1e7648
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 @@ -672,7 +672,7 @@ function invalidArgTypeHelper(input) {
return ` Received type ${typeof input} (${inspected})`;
}

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

0 comments on commit f1e7648

Please sign in to comment.