commit:     a44c00576d2cf6141c24774848b56a8d4e71b7f5
Author:     Mattéo Rossillol‑‑Laruelle <beatussum <AT> protonmail <DOT> com>
AuthorDate: Sun Aug 18 13:40:13 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Aug 29 01:17:23 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a44c0057

dev-util/kcov: fix test failures

These changes do not affect the installed program.

Closes: https://bugs.gentoo.org/937314
Closes: https://bugs.gentoo.org/937315
Signed-off-by: Mattéo Rossillol‑‑Laruelle <beatussum <AT> protonmail.com>
Closes: https://github.com/gentoo/gentoo/pull/38185
Signed-off-by: Sam James <sam <AT> gentoo.org>

 ...ove-failing-test-conflicting-with-sandbox.patch | 51 ++++++++++++++++++++++
 dev-util/kcov/kcov-43.ebuild                       | 18 +++++---
 dev-util/kcov/kcov-9999.ebuild                     | 18 +++++---
 3 files changed, 75 insertions(+), 12 deletions(-)

diff --git 
a/dev-util/kcov/files/kcov-remove-failing-test-conflicting-with-sandbox.patch 
b/dev-util/kcov/files/kcov-remove-failing-test-conflicting-with-sandbox.patch
new file mode 100644
index 000000000000..8229d30be52e
--- /dev/null
+++ 
b/dev-util/kcov/files/kcov-remove-failing-test-conflicting-with-sandbox.patch
@@ -0,0 +1,51 @@
+From c3c89cfca876b9c56586afc374ea92a7b25998c3 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Matt=C3=A9o=20Rossillol=E2=80=91=E2=80=91Laruelle?=
+ <[email protected]>
+Date: Sun, 18 Aug 2024 15:18:19 +0200
+Subject: [PATCH] remove failing test conflicting with sandbox
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+sys-apps/sandbox is based on `LD_PRELOAD`; however,
+`--bash-handle-sh-invocation` uses it too. This option seems to conflict with
+the sandbox environment and the associated test fails fails.
+
+Indeed, according to the Kcov man page, this option handles "invocations of
+/bin/sh scripts via using a LD_PRELOADed library that replaces execve (i.e.,
+/bin/sh is executed as /bin/bash)".
+
+Signed-off-by: Mattéo Rossillol‑‑Laruelle <[email protected]>
+---
+ tests/tools/test_bash_linux_only.py | 15 ---------------
+ 1 file changed, 15 deletions(-)
+
+diff --git a/tests/tools/test_bash_linux_only.py 
b/tests/tools/test_bash_linux_only.py
+index d0a46bb..87022e0 100644
+--- a/tests/tools/test_bash_linux_only.py
++++ b/tests/tools/test_bash_linux_only.py
+@@ -2,21 +2,6 @@ import libkcov
+ from libkcov import cobertura
+ 
+ 
+-class bash_sh_shebang(libkcov.TestCase):
+-    def runTest(self):
+-        rv, o = self.do(
+-            self.kcov
+-            + " --bash-handle-sh-invocation "
+-            + self.outbase
+-            + "/kcov "
+-            + self.sources
+-            + "/tests/bash/shell-main"
+-        )
+-
+-        dom = cobertura.parseFile(self.outbase + 
"/kcov/shell-main/cobertura.xml")
+-        assert cobertura.hitsPerLine(dom, "sh-shebang.sh", 4) == 1
+-
+-
+ class bash_exit_before_child(libkcov.TestCase):
+     def runTest(self):
+         # kcovKcov shouldn't wait for the background process, so call it with 
kcovKcov = False
+-- 
+2.44.2
+

diff --git a/dev-util/kcov/kcov-43.ebuild b/dev-util/kcov/kcov-43.ebuild
index 2c1f929f9a7a..32f6b0358b92 100644
--- a/dev-util/kcov/kcov-43.ebuild
+++ b/dev-util/kcov/kcov-43.ebuild
@@ -39,6 +39,10 @@ DEPEND="
 BDEPEND="test? ( ${PYTHON_DEPS} )"
 RDEPEND="${DEPEND}"
 
+PATCHES=(
+       "${FILESDIR}/${PN}-remove-failing-test-conflicting-with-sandbox.patch"
+)
+
 DOCS=(
        doc/
        CONTRIBUTING.md
@@ -51,24 +55,26 @@ pkg_setup() {
 }
 
 src_prepare() {
-       cmake_src_prepare
-
        if use test; then
                sed -Ei "/skip_python2/ s/= .+/= True/" 
tests/tools/test_python.py \
-                       || die
+                       || die "Cannot disable Python 2 tests"
 
-               echo "add_subdirectory (tests)" >> CMakeLists.txt || die
+               cat <<- EOF >> CMakeLists.txt || die "Cannot enable test 
building"
+               add_compile_options (-g)
+               add_subdirectory (tests)
+               EOF
        fi
+
+       cmake_src_prepare
 }
 
 src_configure() {
        local mycmakeargs=( -DKCOV_INSTALL_DOCDIR:PATH="share/doc/${PF}" )
-
        cmake_src_configure
 }
 
 src_test() {
-       PYTHONPATH="${S}/tests/tools" edo python3 -m libkcov \
+       PYTHONPATH="${S}/tests/tools" edo "${PYTHON}" -m libkcov \
                -v \
                "${BUILD_DIR}/src/kcov" \
                "${T}" \

diff --git a/dev-util/kcov/kcov-9999.ebuild b/dev-util/kcov/kcov-9999.ebuild
index 2c1f929f9a7a..32f6b0358b92 100644
--- a/dev-util/kcov/kcov-9999.ebuild
+++ b/dev-util/kcov/kcov-9999.ebuild
@@ -39,6 +39,10 @@ DEPEND="
 BDEPEND="test? ( ${PYTHON_DEPS} )"
 RDEPEND="${DEPEND}"
 
+PATCHES=(
+       "${FILESDIR}/${PN}-remove-failing-test-conflicting-with-sandbox.patch"
+)
+
 DOCS=(
        doc/
        CONTRIBUTING.md
@@ -51,24 +55,26 @@ pkg_setup() {
 }
 
 src_prepare() {
-       cmake_src_prepare
-
        if use test; then
                sed -Ei "/skip_python2/ s/= .+/= True/" 
tests/tools/test_python.py \
-                       || die
+                       || die "Cannot disable Python 2 tests"
 
-               echo "add_subdirectory (tests)" >> CMakeLists.txt || die
+               cat <<- EOF >> CMakeLists.txt || die "Cannot enable test 
building"
+               add_compile_options (-g)
+               add_subdirectory (tests)
+               EOF
        fi
+
+       cmake_src_prepare
 }
 
 src_configure() {
        local mycmakeargs=( -DKCOV_INSTALL_DOCDIR:PATH="share/doc/${PF}" )
-
        cmake_src_configure
 }
 
 src_test() {
-       PYTHONPATH="${S}/tests/tools" edo python3 -m libkcov \
+       PYTHONPATH="${S}/tests/tools" edo "${PYTHON}" -m libkcov \
                -v \
                "${BUILD_DIR}/src/kcov" \
                "${T}" \

Reply via email to