py2/py3 linters don't exclude directories properly

RESOLVED FIXED in Firefox 57

Status

enhancement
RESOLVED FIXED
2 years ago
2 years ago

People

(Reporter: ahal, Assigned: ahal)

Tracking

(Blocks 1 bug)

unspecified
mozilla57
Dependency tree / graph

Firefox Tracking Flags

(firefox57 fixed)

Details

Attachments

(1 attachment)

Currently the py2 and py3 linters use a big blacklist to exclude directories. For example, testing/mochitest is excluded, and if you run any of:

./mach lint -l py2 .
./mach lint -l py2 testing/mochitest

The exclusion is properly detected and the linter passes. But if you run:

./mach lint -l py2 testing

The exclusion is not picked up and mochitest files will be linted (and fail). This is happening because in FileFinder, the base is '/path/to/src/testing' but the exclusion is 'testing/mochitest'. This means we ultimately end up calling:

mozpack.match('mochitest/runtests.py', 'testing/mochitest')

This doesn't match up. To fix this, we need to preprocess the exclusions so they are relative to whatever FileFinder.base is (and discard exclusions that are outside of the base). I suspect this is something that would ideally be handled in FileFinder itself, but I'm afraid to change too much there as a ton of stuff depends on it. Plus solving it generically will involve thinking about a whole bunch of edge cases.

I'd rather just solve this in the compat linter for now.
Comment on attachment 8906684 [details]
Bug 1398765 - Fix directory exclusion bug in py-compat linters,

https://reviewboard.mozilla.org/r/178392/#review183954

LGTM.

There may be a pre-existing bug in here where a file can occur multiple times in ``files`` due to matching multiple patterns. But that's for another patch.
Attachment #8906684 - Flags: review?(gps) → review+
Pushed by ahalberstadt@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/237a3f842dc1
Fix directory exclusion bug in py-compat linters, r=gps
https://hg.mozilla.org/mozilla-central/rev/237a3f842dc1
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla57
Product: Testing → Firefox Build System
You need to log in before you can comment on or make changes to this bug.