mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Auto merge of #11621 - h4xr:mach_fix, r=Wafflespeanut
Make mach test-tidy consider ignored dirs Made changes so that mach test-tidy considers the ignored directories Fixes #11386 <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11621) <!-- Reviewable:end -->
This commit is contained in:
commit
bc2f4c3450
3 changed files with 13 additions and 2 deletions
|
@ -650,11 +650,12 @@ def get_file_list(directory, only_changed_files=False, exclude_dirs=[]):
|
|||
args = ["git", "ls-files", "--others", "--exclude-standard", directory]
|
||||
file_list += subprocess.check_output(args)
|
||||
for f in file_list.splitlines():
|
||||
yield os.path.join('.', f)
|
||||
if os.path.join('.', os.path.dirname(f)) not in ignored_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 ignored_dirs)]
|
||||
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:
|
||||
|
|
0
python/tidy/servo_tidy_tests/test_ignored/whee/test.rs
Normal file
0
python/tidy/servo_tidy_tests/test_ignored/whee/test.rs
Normal file
|
@ -114,6 +114,16 @@ class CheckTidiness(unittest.TestCase):
|
|||
self.assertEqual(msg, errors.next()[2])
|
||||
self.assertNoMoreErrors(errors)
|
||||
|
||||
def test_file_list(self):
|
||||
base_path='./python/tidy/servo_tidy_tests/test_ignored'
|
||||
file_list = tidy.get_file_list(base_path, only_changed_files=False,
|
||||
exclude_dirs=[])
|
||||
lst = list(file_list)
|
||||
self.assertEqual([os.path.join(base_path, 'whee', 'test.rs')], lst)
|
||||
file_list = tidy.get_file_list(base_path, only_changed_files=False,
|
||||
exclude_dirs=[os.path.join(base_path,'whee')])
|
||||
lst = list(file_list)
|
||||
self.assertEqual([], lst)
|
||||
|
||||
def do_tests():
|
||||
suite = unittest.TestLoader().loadTestsFromTestCase(CheckTidiness)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue