Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report an errror if a package has duplicates allowed but there are no duplicates #19325

Merged
merged 1 commit into from Nov 22, 2017
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -339,10 +339,17 @@ def find_reverse_dependencies(name, content):
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 @@ def test_lock(self):
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)
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.