mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Report an errror if a package has duplicates allowed but there are no duplicates
Resolves: #19306
This commit is contained in:
parent
83c7f80baa
commit
e6d9fd8a4f
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
|
||||
|
||||
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