servo: Merge #12313 - test-tidy command now ignores files in subdirectories of ignored dirs (from cynicaldevil:tidy-test); r=Wafflespeanut
authorNikhil Shagrithaya <nikhilshagri@gmail.com>
Thu, 07 Jul 2016 19:16:31 -0700
changeset 339235 c851afd334003550ef8e8cf2f85458ebbec601cf
parent 339234 37b7513b4c2ed40e1769595956655852b70ac81a
child 339236 3ad22df5e53805afc25009d7eca72cd5794531d6
push id31307
push usergszorc@mozilla.com
push dateSat, 04 Feb 2017 00:59:06 +0000
treeherdermozilla-central@94079d43835f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersWafflespeanut
servo: Merge #12313 - test-tidy command now ignores files in subdirectories of ignored dirs (from cynicaldevil:tidy-test); r=Wafflespeanut <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #12225 . I did not add a test for this, instead I added a directory with an empty file inside the ignored directory, and checked whether this file was being ignored or not. <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Source-Repo: https://github.com/servo/servo Source-Revision: 9c00331634c2c753637a873f600b9804e6145e62
servo/python/tidy/servo_tidy/tidy.py
servo/python/tidy/servo_tidy_tests/test_ignored/whee/foo/bar.rs
--- a/servo/python/tidy/servo_tidy/tidy.py
+++ b/servo/python/tidy/servo_tidy/tidy.py
@@ -631,17 +631,17 @@ def get_file_list(directory, only_change
         args = ["git", "log", "-n1", "--author=bors-servo", "--format=%H"]
         last_merge = subprocess.check_output(args).strip()
         args = ["git", "diff", "--name-only", last_merge, directory]
         file_list = subprocess.check_output(args)
         # also check untracked files
         args = ["git", "ls-files", "--others", "--exclude-standard", directory]
         file_list += subprocess.check_output(args)
         for f in file_list.splitlines():
-            if os.path.join('.', os.path.dirname(f)) not in exclude_dirs:
+            if not any(os.path.join('.', os.path.dirname(f)).startswith(path) for path in exclude_dirs):
                 yield os.path.join('.', f)
     elif exclude_dirs:
         for root, dirs, files in os.walk(directory, topdown=True):
             # modify 'dirs' in-place so that we don't do unwanted traversals in excluded directories
             dirs[:] = [d for d in dirs if not any(os.path.join(root, d).startswith(name) for name in exclude_dirs)]
             for rel_path in files:
                 yield os.path.join(root, rel_path)
     else:
copy from servo/python/tidy/servo_tidy_tests/test_ignored/whee/test.rs
copy to servo/python/tidy/servo_tidy_tests/test_ignored/whee/foo/bar.rs