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

pre-commit: fix repo_depends check #1701

Merged
merged 1 commit into from
Jul 2, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ from time import strftime
from subprocess import Popen, PIPE
from unittest import TestCase, TestLoader, TextTestRunner, skip
from io import StringIO
from typing import Generator

# need python-yaml package
import yaml
Expand Down Expand Up @@ -272,7 +273,7 @@ def load_lilac_yaml_schema():
YAML_SCHEMA = yaml.load(schema, Loader=yaml.SafeLoader)


def iter_packages():
def iter_packages(all_pkgs: bool = False) -> Generator[str, None, None]:
packagesfolder = SUBFOLDER
if not git_isdir(packagesfolder):
packagesfolder = '.'
Expand All @@ -281,7 +282,7 @@ def iter_packages():
continue
if package[0] == '.':
continue
if not(package in CHANGED_PACKAGES or CHECK_ALL):
if not(package in CHANGED_PACKAGES or CHECK_ALL or all_pkgs):
continue
yield package

Expand Down Expand Up @@ -375,6 +376,7 @@ class RepoTreeTest(TestCase):

def test_repo_depends_valid(self):
pkgs = list(iter_packages())
all_pkgs = list(iter_packages(all_pkgs=True))
for package in pkgs:
with self.subTest(package=package):
self.assertFalse(
Expand All @@ -394,7 +396,7 @@ class RepoTreeTest(TestCase):
else:
dep_package = dep
self.assertTrue(
dep_package in pkgs,
dep_package in all_pkgs,
msg=('package "\033[1;31m{0}\033[m" depends on '
'"\033[1;31m{1}\033[m", which does not exist '
'or is unmanaged').format(package, dep_package))
Expand Down