Repository navigation
Support adding Idlharness dependencies - #10381
lukebjerring merged 10 commits into
Conversation
birtles
left a comment
There was a problem hiding this comment.
Changes to the web-animations tests look good to me.
foolip
left a comment
There was a problem hiding this comment.
Cool! Last time I tried to review this I was confused about what it was trying to do, reading more carefully I conclude that it's to pull in untested dependencies from unparsed IDL but filtering out that which nothing depends on, in order to get rid of incidental dependency-dependencies that one currently needs to spend time sorting out. Makes sense! A bunch of questions...
| Object.values(this["implements"]).forEach(v => all_deps.add(v)); | ||
| this.partials.map(p => p.name).forEach(v => all_deps.add(v)); | ||
|
|
||
| console.log('all deps', all_deps); |
There was a problem hiding this comment.
Remember to remove logging before merging :)
|
|
||
| const all_deps = new Set(); | ||
| Object.values(this["inheritance"]).forEach(v => all_deps.add(v)); | ||
| Object.values(this["implements"]).forEach(v => all_deps.add(v)); |
There was a problem hiding this comment.
Should "includes" also be processed here? That's for mixins, added in #8727
There was a problem hiding this comment.
I treat it as a dep type below, so yeah, I think it should.
| const all_deps = new Set(); | ||
| Object.values(this["inheritance"]).forEach(v => all_deps.add(v)); | ||
| Object.values(this["implements"]).forEach(v => all_deps.add(v)); | ||
| this.partials.map(p => p.name).forEach(v => all_deps.add(v)); |
There was a problem hiding this comment.
Use this["partials"] here, or this.inheritance + this.implements above?
| if (options && options.except && options.only) { | ||
| throw new IdlHarnessError("The only and except options can't be used together."); | ||
| } | ||
| const skip = name => { |
There was a problem hiding this comment.
This is very similar to the function should_skip(name) in internal_add_idls. Can you copy that so that any differences stand out, or, if it seems worthwhile, use a shared definition?
There was a problem hiding this comment.
Added is_excluded_by_options
| } | ||
|
|
||
| // Mark as untested. | ||
| for (var i = 0; i < parsed_idls.length; i++) { |
There was a problem hiding this comment.
Added mark_as_untested
| } | ||
| } | ||
|
|
||
| if (follow_up && skipped.has(follow_up)) { |
There was a problem hiding this comment.
This seems broken. follow_up is an array, and even an empty array is truthy in JS (unlike in Python). Should have been a loop?
| console.log(parsed); | ||
|
|
||
| new_options.only.push(name); | ||
| const follow_up = []; |
There was a problem hiding this comment.
Can you add a comment about what this bookkeeping is for? I think it's in case we have a dependency on B, which in turn depends on C, but we've already processed C. However, since add_dependency_idls can be called multiple times, once for each IDL file, it seems like this will still be broken for cross-spec dependencies. Most likely, some spec depends on something in HTML, that depends on something in DOM, but we process DOM before HTML. Does this still work then?
There was a problem hiding this comment.
No; it still requires the caller to load the dep files in the right order, unfortunately.
I could change things to be more global, but I think that's too stateful and risky.
There was a problem hiding this comment.
Yeah, something more global would not necessarily be an improvement, if we wanted order-agnosticism we should probably delay parsing until idl_array.test() or something. Not today.
The "Record of skipped items in case we later determine they are a dependency" comment is clear to me now. Could possibly say that it's not global, but that's a pretty far-fetched misunderstanding, so nah.
| if (parsed_idl.name in this["inheritance"] | ||
| && parsed_idl["inheritance"] != this["inheritance"][parsed_idl.name]) { | ||
| throw new IdlHarnessError( | ||
| `Inheritance for ${parsed_idl.name} was already defined`); |
There was a problem hiding this comment.
A new idlharness.js test for this error?
| const all_deps = new Set(); | ||
| Object.values(this["inheritance"]).forEach(v => all_deps.add(v)); | ||
| Object.values(this["implements"]).forEach(v => all_deps.add(v)); | ||
| this.partials.map(p => p.name).forEach(v => all_deps.add(v)); |
| Object.values(this["implements"]).forEach(v => all_deps.add(v)); | ||
| this.partials.map(p => p.name).forEach(v => all_deps.add(v)); | ||
|
|
||
| console.log('all deps', all_deps); |
| if (options && options.except && options.only) { | ||
| throw new IdlHarnessError("The only and except options can't be used together."); | ||
| } | ||
| const skip = name => { |
There was a problem hiding this comment.
Added is_excluded_by_options
| console.log(parsed); | ||
|
|
||
| new_options.only.push(name); | ||
| const follow_up = []; |
There was a problem hiding this comment.
No; it still requires the caller to load the dep files in the right order, unfortunately.
I could change things to be more global, but I think that's too stateful and risky.
| } | ||
| } | ||
|
|
||
| if (follow_up && skipped.has(follow_up)) { |
| } | ||
|
|
||
| // Mark as untested. | ||
| for (var i = 0; i < parsed_idls.length; i++) { |
There was a problem hiding this comment.
Added mark_as_untested
| if (parsed_idl.name in this["inheritance"] | ||
| && parsed_idl["inheritance"] != this["inheritance"][parsed_idl.name]) { | ||
| throw new IdlHarnessError( | ||
| `Inheritance for ${parsed_idl.name} was already defined`); |
foolip
left a comment
There was a problem hiding this comment.
LGTM % small nits. Although most changes are contained to add_dependency_idls it's still not far fetched that there might be regressions. Before merging, can you run the updated tests and a handful of tests that haven't been changed to see if it's all good? (Or put it through Chromium's CQ.)
| var parsed_idls = WebIDL2.parse(raw_idls); | ||
| for (var i = 0; i < parsed_idls.length; i++) | ||
| { | ||
| this.mark_as_untested(parsed_idls); |
There was a problem hiding this comment.
This is short and sweet now, nice!
| throw new IdlHarnessError("The only and except options can't be used together."); | ||
| } | ||
|
|
||
| const skip = name => { |
There was a problem hiding this comment.
Can you name this should_skip like the other one?
| IdlArray.prototype.is_excluded_by_options = function (name, options) | ||
| //@{ | ||
| { | ||
| return !name || |
There was a problem hiding this comment.
Can you hoist the !name part of this to the one (right?) call site where it's possible for it to be falsy? I actually don't really get why it can be falsy, but it does seem like when there's nothing to skip the return value from this method can't matter, and the purpose of the check will be more clear closer to the origin of the value.
| || parsed.type == "implements" && parsed.target | ||
| || parsed.type == "includes" && parsed.target; | ||
| if (skip(name) || !all_deps.has(name)) { | ||
| if (!name || should_skip(name) || !all_deps.has(name)) { |
There was a problem hiding this comment.
Still can't quite tell why it's possible for name to be null. Is it parsed.target which can be null?
There was a problem hiding this comment.
If the chunked is unnamed and doesn't implement/include. Can't recall the case that isn't any of these, but I definitely hit it in my testing.
There was a problem hiding this comment.
Is "chunked" a typo? This is fine in any case, but it probably will be hard to figure out if it's safe to change later. I guess checking if any tests are affected will always work though.
|
@foolip - to fix the breakage of Animation idl test, there are 2 major changes:
The second change occurs when Note that the reason to add_dependency_idls from the same file is that only part of the web-animation IDL is (currently) tested, so to get a no-op result, needed to stay that way. |
foolip
left a comment
There was a problem hiding this comment.
LGTM % possible comment.
Maybe it's just because I've read it over and over, but I think this is all nice and understandable now, which is rarely true in this file. Thanks!
| } | ||
|
|
||
| const should_skip = name => { | ||
| return this.is_excluded_by_options(name, options) || name in this.members; |
There was a problem hiding this comment.
Should this same condition also apply to the other should_skip? Just a comment about what the name in this.members bit is for would calm the nervous reader.
There was a problem hiding this comment.
No; we don't want to be lenient with tested IDL. Large comment added.
| // e.g. for 'idl' containing A:B, B:C, C:D | ||
| // array.add_idls(idl, {only: ['A','B']}). | ||
| // array.add_dependency_idls(idl); | ||
| // B would be encountered as tested, and encountered as a dep, so we ignore. |
This is a request for feedback on a potential solution to #10347
The PR adds a new
idlharness.jsapi:add_dependency_idls(raw_idls, options)EDIT: Explanation:
Currently, to get idl_array to stop complaining about missing interface definitions, the test author has a couple options:
{only: 'Foo'}helperhtml/dom)interface Foo {};This PR aims to add a better, 4th option: Add all the idl that get referenced (and nothing more!), whole file at a time. It's better because real interfaces are used, without bloating the test.
Usage examples are in the couple of modified tests.
Note that the
optionsobject was needed for adding deps in some cases, because some interfaces are re-declared in bothhtmlanddedicated-workers.idl, e.g.WorkerNavigator.See https://github.com/w3c/web-platform-tests/blob/master/budget-api/interfaces.any.js for example.
This change is