From: Vasek Sraier Date: Tue, 17 May 2022 09:34:46 +0000 (+0200) Subject: manager packaging tests: added a test checking existance of dependencies X-Git-Tag: v6.0.0a1~29^2~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8bcf9251fe66b221cc353beff33bc1edfa96dd71;p=thirdparty%2Fknot-resolver.git manager packaging tests: added a test checking existance of dependencies --- diff --git a/ci/pkgtest.yaml b/ci/pkgtest.yaml index 6d6def6da..08a53dc34 100644 --- a/ci/pkgtest.yaml +++ b/ci/pkgtest.yaml @@ -5,9 +5,9 @@ stages: # pkgbuild {{{ .pkgbuild: &pkgbuild stage: pkgbuild - tags: - - lxc - - amd64 +# tags: +# - lxc +# - amd64 before_script: - git config --global user.name CI - git config --global user.email ci@nic diff --git a/distro/tests/manager-packaging/control b/distro/tests/manager-packaging/control index 09bc0e7c0..c820dbe61 100644 --- a/distro/tests/manager-packaging/control +++ b/distro/tests/manager-packaging/control @@ -1,3 +1,8 @@ +{# Test that all packages are installed #} +Tests: dependencies.py +Tests-Directory: manager/tests/packaging/ + + {# Test that kresctl command exists and is in $PATH #} Tests: kresctl.sh Tests-Directory: manager/tests/packaging diff --git a/manager/knot_resolver_manager/__main__.py b/manager/knot_resolver_manager/__main__.py index 33151e962..e533e360b 100644 --- a/manager/knot_resolver_manager/__main__.py +++ b/manager/knot_resolver_manager/__main__.py @@ -1,3 +1,6 @@ +# pylint: skip-file +# flake8: noqa + # throws nice syntax error on old Python versions: 0_0 # Python >= 3.6 required diff --git a/manager/tests/packaging/dependencies.py b/manager/tests/packaging/dependencies.py new file mode 100755 index 000000000..20ad02d9a --- /dev/null +++ b/manager/tests/packaging/dependencies.py @@ -0,0 +1,33 @@ +#!/usr/bin/python3 + +import importlib +import importlib.util +import sys +from types import ModuleType + +import pkg_resources + +# replace imports with mocks +dummy = ModuleType("dummy") +dummy.__dict__["setup"] = lambda *args, **kwargs: None +dummy.__dict__["build"] = lambda *args, **kwargs: None +sys.modules["setuptools"] = dummy +sys.modules["build"] = dummy + +# load install_requires array from setup.py +spec = importlib.util.spec_from_file_location("setup", "manager/setup.py") +mod = importlib.util.module_from_spec(spec) +spec.loader.exec_module(mod) +install_requires = mod.install_requires + +# stip version codes +deps = set((x[: x.index(">")].lower() for x in install_requires)) + +# find out which packages are missing +installed = {pkg.key for pkg in pkg_resources.working_set} +missing = deps - installed + +# fail if there are some missing +if len(missing) > 0: + print(f"Some required packages are missing: {missing}", file=sys.stderr) + exit(1)