py2/py3 linters don't exclude directories properly

RESOLVED FIXED in Firefox 57


2 years ago
2 years ago


(Reporter: ahal, Assigned: ahal)


(Blocks 1 bug)

Dependency tree / graph

Firefox Tracking Flags

(firefox57 fixed)



(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/', '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,


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
Fix directory exclusion bug in py-compat linters, r=gps
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.