commit:     b49e9b2821afc2f102fd44879871718c31080c04
Author:     Jonathan Davies <jpds <AT> protonmail <DOT> com>
AuthorDate: Wed Jul  7 13:16:06 2021 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Jul 19 22:21:28 2021 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b49e9b28

sys-apps/selinux-python: Fixed tests, thanks to Arie Artrip.

Closes: https://bugs.gentoo.org/715924
Closes: https://bugs.gentoo.org/741930

Signed-off-by: Jonathan Davies <jpds <AT> protonmail.com>
Closes: https://github.com/gentoo/gentoo/pull/21550
Signed-off-by: Sam James <sam <AT> gentoo.org>

 sys-apps/selinux-python/selinux-python-3.2.ebuild  | 23 ++++++++++++++++++++++
 sys-apps/selinux-python/selinux-python-9999.ebuild | 23 ++++++++++++++++++++++
 2 files changed, 46 insertions(+)

diff --git a/sys-apps/selinux-python/selinux-python-3.2.ebuild 
b/sys-apps/selinux-python/selinux-python-3.2.ebuild
index df7cfa14c51..bd9f2e663d8 100644
--- a/sys-apps/selinux-python/selinux-python-3.2.ebuild
+++ b/sys-apps/selinux-python/selinux-python-3.2.ebuild
@@ -7,6 +7,8 @@ PYTHON_REQ_USE="xml"
 
 inherit python-r1 toolchain-funcs
 
+IUSE="test"
+RESTRICT="!test? ( test )"
 REQUIRED_USE="${PYTHON_REQUIRED_USE}"
 
 DESCRIPTION="SELinux core utilities"
@@ -29,6 +31,7 @@ DEPEND=">=sys-libs/libselinux-${PV}:=[python]
        >=sys-libs/libsepol-${PV}:=
        >=app-admin/setools-4.2.0[${PYTHON_USEDEP}]
        >=sys-process/audit-1.5.1[python,${PYTHON_USEDEP}]
+       test? ( >=sys-apps/secilc-${PV} )
        ${PYTHON_DEPS}"
 
 RDEPEND="${DEPEND}"
@@ -49,6 +52,26 @@ src_compile() {
        python_foreach_impl building
 }
 
+src_test() {
+       testing() {
+               # The different subprojects have some interproject dependencies:
+               # - audit2allow depens on sepolgen
+               # - chcat depends on semanage
+               # and maybe others.
+               # Add all the modules of the individual subprojects to the
+               # PYTHONPATH, so they get actually found and used. In
+               # particular, already installed versions on the system are not
+               # used.
+               for dir in audit2allow chcat semanage sepolgen/src sepolicy ; do
+                       PYTHONPATH="${BUILD_DIR}/${dir}:${PYTHONPATH}"
+               done
+               PYTHONPATH=${PYTHONPATH} \
+                       emake -C "${BUILD_DIR}" \
+                               test
+       }
+       python_foreach_impl testing
+}
+
 src_install() {
        installation() {
                emake -C "${BUILD_DIR}" \

diff --git a/sys-apps/selinux-python/selinux-python-9999.ebuild 
b/sys-apps/selinux-python/selinux-python-9999.ebuild
index 2d1cc6d2b32..52abfe44946 100644
--- a/sys-apps/selinux-python/selinux-python-9999.ebuild
+++ b/sys-apps/selinux-python/selinux-python-9999.ebuild
@@ -7,6 +7,8 @@ PYTHON_REQ_USE="xml"
 
 inherit python-r1 toolchain-funcs
 
+IUSE="test"
+RESTRICT="!test? ( test )"
 REQUIRED_USE="${PYTHON_REQUIRED_USE}"
 
 DESCRIPTION="SELinux core utilities"
@@ -29,6 +31,7 @@ DEPEND=">=sys-libs/libselinux-${PV}:=[python]
        >=sys-libs/libsepol-${PV}:=
        >=app-admin/setools-4.2.0[${PYTHON_USEDEP}]
        >=sys-process/audit-1.5.1[python,${PYTHON_USEDEP}]
+       test? ( >=sys-apps/secilc-${PV} )
        ${PYTHON_DEPS}"
 
 RDEPEND="${DEPEND}"
@@ -49,6 +52,26 @@ src_compile() {
        python_foreach_impl building
 }
 
+src_test() {
+       testing() {
+               # The different subprojects have some interproject dependencies:
+               # - audit2allow depens on sepolgen
+               # - chcat depends on semanage
+               # and maybe others.
+               # Add all the modules of the individual subprojects to the
+               # PYTHONPATH, so they get actually found and used. In
+               # particular, already installed versions on the system are not
+               # used.
+               for dir in audit2allow chcat semanage sepolgen/src sepolicy ; do
+                       PYTHONPATH="${BUILD_DIR}/${dir}:${PYTHONPATH}"
+               done
+               PYTHONPATH=${PYTHONPATH} \
+                       emake -C "${BUILD_DIR}" \
+                               test
+       }
+       python_foreach_impl testing
+}
+
 src_install() {
        installation() {
                emake -C "${BUILD_DIR}" \

Reply via email to