From e29ab4aa9bb6f8134193c3a5212669f90fdc8489 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcus=20Sch=C3=A4fer?= Date: Tue, 18 Jun 2024 15:48:31 +0200 Subject: [PATCH 1/2] Add %check section to run pytest at build time --- package/python-kiwi-spec-template | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/package/python-kiwi-spec-template b/package/python-kiwi-spec-template index 325c405bf7a..05876633885 100644 --- a/package/python-kiwi-spec-template +++ b/package/python-kiwi-spec-template @@ -20,6 +20,14 @@ # If they aren't provided by a system installed macro, define them %{!?_defaultdocdir: %global _defaultdocdir %{_datadir}/doc} +# Userland install of python modules such that new namespaces +# gets added to this environment properly. I did not find another +# way to install a python module as non root into this build environment +# such that importlib.* methods would find them. With the former +# pkg_resources this could be handled by setting the PYTHONPATH +# variable but this doesn't work anymore with importlib. +%global pip_install pip install --break-system-packages + %if 0%{?suse_version} && 0%{?suse_version} < 1600 %global __python3 /usr/bin/python3.11 %global python3_pkgversion 311 @@ -69,6 +77,12 @@ Source1: %{name}-rpmlintrc ## PATCH-FIX-OPENSUSE kiwi-revert-bls-default-for-suse.patch -- temporary until opensuse has bls Patch1001: kiwi-revert-bls-default-for-suse.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build +BuildRequires: kiwi-systemdeps +BuildRequires: python%{python3_pkgversion}-pytest +BuildRequires: python%{python3_pkgversion}-pip +BuildRequires: python%{python3_pkgversion}-anymarkup-core +BuildRequires: python%{python3_pkgversion}-toml +BuildRequires: python%{python3_pkgversion}-xmltodict %if 0%{?fedora} || 0%{?suse_version} BuildRequires: fdupes %endif @@ -755,6 +769,11 @@ fi %endif %endif +%check +# install kiwi to userland and run the tests +%pip_install dist/kiwi-%{version}-py3-none-any.whl +cd test/unit && pytest + %files -n kiwi-systemdeps-core # Empty metapackage From 93030722b53cb38563c154e09c32e5e74c8613fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcus=20Sch=C3=A4fer?= Date: Wed, 23 Oct 2024 17:34:16 +0200 Subject: [PATCH 2/2] Run %check for TW only For full test coverage the anymarkup module must be installed. However the module is an optional module for kiwi and only required when running tests to reach the 100% code coverage. Unfortunately not all distros provide anymarkup which is the reason why I limited the %check execution to only TW for the moment. --- package/python-kiwi-spec-template | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/package/python-kiwi-spec-template b/package/python-kiwi-spec-template index 05876633885..39a2a304fc8 100644 --- a/package/python-kiwi-spec-template +++ b/package/python-kiwi-spec-template @@ -80,7 +80,9 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: kiwi-systemdeps BuildRequires: python%{python3_pkgversion}-pytest BuildRequires: python%{python3_pkgversion}-pip +%if 0%{?suse_version} > 1600 BuildRequires: python%{python3_pkgversion}-anymarkup-core +%endif BuildRequires: python%{python3_pkgversion}-toml BuildRequires: python%{python3_pkgversion}-xmltodict %if 0%{?fedora} || 0%{?suse_version} @@ -771,8 +773,10 @@ fi %check # install kiwi to userland and run the tests +%if 0%{?suse_version} > 1600 %pip_install dist/kiwi-%{version}-py3-none-any.whl cd test/unit && pytest +%endif %files -n kiwi-systemdeps-core # Empty metapackage