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

Ensure that tests-affected picks up changes to webidl/idlharness #8069

Merged
merged 1 commit into from
Nov 6, 2017

Conversation

jgraham
Copy link
Contributor

@jgraham jgraham commented Nov 5, 2017

When checking the tests that are affected by a change we previously
had a rule to ignore all files under reources, so that changes to
testharness.js don't cause the entire repository to be rerun. However
changes to WebIDL2 or idlharness.js probably should cause all
interfaces.html tests to be rerun. That requires two changes:

  • Support for the rewrite rule that causes /resources/WebIDLParser.js
    to be interpreted as the resources/webidl2/lib/webidl2.js path

  • Support for more precise exclude rules so that we can exclude
    resources/testharness.js without excluding all of the WebIDL stuff.

For the latter --ignore-dirs has been replaced by --ignore-rules,
where the rules can include a * to match anything other than a path
separator or ** to match anything. In either case the patterns are
only valid at the end of a path segment (i.e. before a seperator or
the end of the path).

Further changes may be required if we want to allow changes to webidl2
that don't affect the webidl2.js file itself to be seen as affecting
all idlharness tests.


This change is Reviewable

@ghost
Copy link

ghost commented Nov 5, 2017

Build BROKEN

Started: 2017-11-06 00:22:03
Finished: 2017-11-06 00:32:32

Failing Jobs

  • wpt_integration in py27

View more information about this build on:

@foolip
Copy link
Member

foolip commented Nov 5, 2017

Typo: reources

@foolip
Copy link
Member

foolip commented Nov 5, 2017

Typo: seperator

def files_changed(revish, ignore_rules=None, include_uncommitted=False, include_new=False):
"""Get and return files changed since current branch diverged from master,
excluding those that are located within any directory specifed by
`ignore_changes`."""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There isn't anything called ignore_changes.

parts = rule.split("/")
re_parts = []
for part in parts:
if part.endswith("**"):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parsing out what the body of this loop does isn't easy, for me. Maybe a test for this that hits each of the branches? (Don't need to apply the rules, just stringify the resulting regexes and asssert that they are what they should be.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests now in test_files_changed_ignore_rules()

@@ -91,6 +91,14 @@ def test_files_changed(capsys):
assert err == ""


def test_files_changed_ignore(capsys):
from wpt.testfiles import exclude_ignored
files = ["resources/testharness.js", "resources/webidl2/index.js", "test/test.js"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having webidl2.js show up in a test would be nice, since that was the thing that originally didn't work.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not entirely trivial to test since it only affects tests_affected rather than get_files_changed and that's mostly about reading files to see what data they contain, so it would either need to be refactored or we'd need to find some commit with a webidl2 change to test, but there aren't many of those. Maybe land the upgrade and use that commit for the test.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would a previous commit that changes webidl2.js do the job? 960a3d2?

@jgraham jgraham force-pushed the idl_affected branch 2 times, most recently from aa8c0ff to 28b1265 Compare November 6, 2017 00:21
When checking the tests that are affected by a change we previously
had a rule to ignore all files under resources, so that changes to
testharness.js don't cause the entire repository to be rerun. However
changes to WebIDL2 or idlharness.js probably should cause all
interfaces.html tests to be rerun. That requires two changes:

* Support for the rewrite rule that causes /resources/WebIDLParser.js
  to be interpreted as the resources/webidl2/lib/webidl2.js path

* Support for more precise exclude rules so that we can exclude
  resources/testharness.js without excluding all of the WebIDL stuff.

For the latter --ignore-dirs has been replaced by --ignore-rules,
where the rules can include a * to match anything other than a path
separator or ** to match anything. In either case the patterns are
only valid at the end of a path segment (i.e. before a separator or
the end of the path).

Further changes may be required if we want to allow changes to webidl2
that don't affect the webidl2.js file itself to be seen as affecting
all idlharness tests.

def test_files_changed_ignore_rules():
from tools.wpt.testfiles import compile_ignore_rule
assert compile_ignore_rule("foo*bar*/baz").pattern == "^foo\*bar[^/]*/baz$"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really right? Why is \* part of the pattern here or anywhere, and not .*?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just doing prefix matching on path parts. It could do something different, but this is enough to satisfy the current use cases.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, the comment "* before a separator or the end matching" explains this.

parts = rule.split("/")
re_parts = []
for part in parts:
if part.endswith("**"):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests now in test_files_changed_ignore_rules()

@jgraham jgraham merged commit 4814022 into master Nov 6, 2017
@gsnedders gsnedders deleted the idl_affected branch November 7, 2017 00:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants