Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate IDLs in idl_test() #18382

Merged
merged 3 commits into from
Sep 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 26 additions & 8 deletions resources/idlharness.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,11 @@ IdlArray.prototype.is_excluded_by_options = function (name, options)

IdlArray.prototype.add_dependency_idls = function(raw_idls, options)
{
const parsed_idls = WebIDL2.parse(raw_idls);
return this.internal_add_dependency_idls(WebIDL2.parse(raw_idls), options);
};

IdlArray.prototype.internal_add_dependency_idls = function(parsed_idls, options)
{
const new_options = { only: [] }

const all_deps = new Set();
Expand Down Expand Up @@ -3297,16 +3301,30 @@ function idl_test(srcs, deps, idl_setup_func) {
srcs = (srcs instanceof Array) ? srcs : [srcs] || [];
deps = (deps instanceof Array) ? deps : [deps] || [];
var setup_error = null;
const validationIgnored = [
"constructor-member",
"dict-arg-default",
"require-exposed"
];
return Promise.all(
srcs.concat(deps).map(function(spec) {
return fetch_spec(spec);
}))
.then(function(idls) {
srcs.concat(deps).map(fetch_spec))
.then(function(results) {
const astArray = results.map(result =>
WebIDL2.parse(result.idl, { sourceName: result.spec })
);
test(() => {
const validations = WebIDL2.validate(astArray)
.filter(v => !validationIgnored.includes(v.ruleName));
if (validations.length) {
const message = validations.map(v => v.message).join("\n\n");
throw new Error(message);
}
}, "idl_test validation");
for (var i = 0; i < srcs.length; i++) {
idl_array.add_idls(idls[i]);
idl_array.internal_add_idls(astArray[i]);
saschanaz marked this conversation as resolved.
Show resolved Hide resolved
}
for (var i = srcs.length; i < srcs.length + deps.length; i++) {
idl_array.add_dependency_idls(idls[i]);
idl_array.internal_add_dependency_idls(astArray[i]);
}
})
.then(function() {
Expand Down Expand Up @@ -3341,6 +3359,6 @@ function fetch_spec(spec) {
throw new IdlHarnessError("Error fetching " + url + ".");
}
return r.text();
});
}).then(idl => ({ spec, idl }));
}
// vim: set expandtab shiftwidth=4 tabstop=4 foldmarker=@{,@} foldmethod=marker:
126 changes: 111 additions & 15 deletions resources/webidl2/lib/webidl2.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.