Bug 1494069 - [mozlint] Make sure exclude paths always get discarded when necessary, r=rwood
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Tue, 16 Oct 2018 21:04:14 +0000
changeset 500147 8a1fd7460ad555447b8d9d8e7dd3724d2ac2427f
parent 500146 b9beb91e999214dfce51b7829b1f28de6b4e5581
child 500148 b062b1682bbd328a0327edf51f9040dcd9e1680a
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrwood
bugs1494069
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1494069 - [mozlint] Make sure exclude paths always get discarded when necessary, r=rwood We were currently adding exclude paths to the "discard" set if the path contains the include, but we weren't adding them if the include contains the path. Depends on D5863 Differential Revision: https://phabricator.services.mozilla.com/D8845
python/mozlint/mozlint/pathutils.py
python/mozlint/test/test_pathutils.py
--- a/python/mozlint/mozlint/pathutils.py
+++ b/python/mozlint/mozlint/pathutils.py
@@ -183,16 +183,17 @@ def filterpaths(root, paths, include, ex
                 discard.update(excs)
 
             elif inc.contains(path):
                 # If the include path is an ancestor of the specified
                 # path, then add the specified path only if there are
                 # no exclude paths in-between them.
                 if not any(e.contains(path) for e in excs):
                     keep.add(path)
+                    discard.update([e for e in excs if path.contains(e)])
 
         # Next expand excludes with globs in them so we can add them to
         # the set of files to discard.
         for pattern in excludeglobs:
             for p, f in path.finder.find(pattern):
                 discard.add(path.join(p))
 
     return [f.path for f in keep], collapse([f.path for f in discard])
--- a/python/mozlint/test/test_pathutils.py
+++ b/python/mozlint/test/test_pathutils.py
@@ -54,16 +54,24 @@ TEST_CASES = (
     },
     {
         'paths': ['a.py', 'a.js', 'subdir2'],
         'include': ['.'],
         'exclude': [],
         'extensions': ['py'],
         'expected': ['a.py', 'subdir2'],
     },
+    {
+        'paths': ['subdir1'],
+        'include': ['.'],
+        'exclude': ['subdir1/subdir3'],
+        'extensions': ['py'],
+        'expected': ['subdir1'],
+        'expected_exclude': ['subdir1/subdir3'],
+    },
 )
 
 
 @pytest.mark.parametrize('test', TEST_CASES)
 def test_filterpaths(test):
     expected = test.pop('expected')
     expected_exclude = test.pop('expected_exclude', [])