mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Auto merge of #19325 - m-novikov:tidy-ignore-without-duplicates, r=jdm
Report an errror if a package has duplicates allowed but there are no duplicates Resolves: #19306 <!-- 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 #19306 (github issue number if applicable). <!-- Either: --> - [X] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19325) <!-- Reviewable:end -->
This commit is contained in:
commit
a812af51d6
2 changed files with 27 additions and 2 deletions
|
@ -339,10 +339,17 @@ def check_lock(file_name, contents):
|
|||
packages_by_name.setdefault(package["name"], []).append((package["version"], source))
|
||||
|
||||
for (name, packages) in packages_by_name.iteritems():
|
||||
if name in exceptions or len(packages) <= 1:
|
||||
has_duplicates = len(packages) > 1
|
||||
duplicates_allowed = name in exceptions
|
||||
|
||||
if has_duplicates == duplicates_allowed:
|
||||
continue
|
||||
|
||||
message = "duplicate versions for package `{}`".format(name)
|
||||
if duplicates_allowed:
|
||||
message = 'duplicates for `{}` are allowed, but only single version found'.format(name)
|
||||
else:
|
||||
message = "duplicate versions for package `{}`".format(name)
|
||||
|
||||
packages.sort()
|
||||
packages_dependencies = list(find_reverse_dependencies(name, content))
|
||||
for version, source in packages:
|
||||
|
|
|
@ -233,6 +233,24 @@ class CheckTidiness(unittest.TestCase):
|
|||
self.assertEqual(msg2, errors.next()[2])
|
||||
self.assertNoMoreErrors(errors)
|
||||
|
||||
def test_lock_ignore_without_duplicates(self):
|
||||
tidy.config["ignore"]["packages"] = ["test", "test2", "test3", "test5"]
|
||||
errors = tidy.collect_errors_for_files(iterFile('duplicated_package.lock'), [tidy.check_lock], [], print_text=False)
|
||||
|
||||
msg = (
|
||||
"duplicates for `test2` are allowed, but only single version found"
|
||||
"\n\t\x1b[93mThe following packages depend on version 0.1.0 from 'https://github.com/user/test2':\x1b[0m"
|
||||
)
|
||||
self.assertEqual(msg, errors.next()[2])
|
||||
|
||||
msg2 = (
|
||||
"duplicates for `test5` are allowed, but only single version found"
|
||||
"\n\t\x1b[93mThe following packages depend on version 0.1.0 from 'https://github.com/':\x1b[0m"
|
||||
)
|
||||
self.assertEqual(msg2, errors.next()[2])
|
||||
|
||||
self.assertNoMoreErrors(errors)
|
||||
|
||||
def test_lint_runner(self):
|
||||
test_path = base_path + 'lints/'
|
||||
runner = tidy.LintRunner(only_changed_files=False, progress=False)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue