commit:     74d3bc3916a6fefac6f5a1f810b855b7046696bb
Author:     Eli Schwartz <eschwartz <AT> gentoo <DOT> org>
AuthorDate: Wed Sep  3 05:32:25 2025 +0000
Commit:     Eli Schwartz <eschwartz <AT> gentoo <DOT> org>
CommitDate: Mon Sep  8 17:21:19 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=74d3bc39

sci-physics/espresso: fix multitude of extremely severe runtime / test issues

At the heart of this issue is that tests were disabled, via a wholly
bogus and clearly unresearched claim that a dep isn't packaged. No such
dep exists -- the "dep" is a source code file inside the package
sources. It "does not exist" because cmake does not build tests when
running ctest. This is evidenced by loads of other C++ tests not running
at all because... they weren't built.

To fix this, patch the cmake files to expose a target for building
tests.

Next step: for absolutely unfathomable reasons, the package set up
-DCMAKE_SKIP_RPATH=YES, which exists solely to break the software into a
million pieces, as libraries are installed to site-packages and none of
the code can find the dependencies. This cmake option is seriously
advanced low-level debugging, using it at all is a huge red flag.

And the cherry on top is that using it also breaks running tests! Tests
cannot run if test programs cannot find the just-built libraries which
aren't in ld.so.conf. To work around *this*, the ebuild -- in the same
commit adding the bogus RESTRICT=test -- added an LD_PRELOAD of one out
of the four ${BUILD_DIR} libraries loaded by test code. This is *totally
insane*, as the correct solution is either rpath or LD_LIBRARY_PATH, and
LD_PRELOAD injects code into programs such as `mkdir -p "${BUILD_DIR}"`
which in case it wasn't completely obvious, DOES NOT WORK.
```
 *   environment, line  276:  Called die
 * The specific snippet of code:
*** The MPI_Type_free() function was called before MPI_INIT was invoked.
*** This is disallowed by the MPI standard.
*** Your MPI job will now abort.
[localhost:00084] Local abort before MPI_INIT completed completed successfully, 
but am not able to aggregate error messages, and not able to guarantee that all 
other processes were killed!
*** The MPI_Type_free() function was called before MPI_INIT was invoked.
*** This is disallowed by the MPI standard.
*** Your MPI job will now abort.
[localhost:00085] Local abort before MPI_INIT completed completed successfully, 
but am not able to aggregate error messages, and not able to guarantee that all 
other processes were killed!
 *       mkdir -p "${BUILD_DIR}" || die
```

Again, there was no reason to ever assume this could work, and the fact
that it was even possible to think it might be a good idea should have
been worrying: it implied that the installed software might not run
without injecting libraries. Indeed, it didn't run.

Since we are massively renovating the testsuite already, add a couple
needed bdeps, some backport patches fixing issues with the tests, and
skip the final remaining test failures. Additionally, it seems numpy
needs to be pinned to 1.* as indicated by some test fails.

Bug: https://github.com/espressomd/espresso/issues/5166
Bug: https://bugs.gentoo.org/811186
Signed-off-by: Eli Schwartz <eschwartz <AT> gentoo.org>

 sci-physics/espresso/espresso-4.2.0.ebuild | 44 ++++++++++++++++++++++++++----
 1 file changed, 38 insertions(+), 6 deletions(-)

diff --git a/sci-physics/espresso/espresso-4.2.0.ebuild 
b/sci-physics/espresso/espresso-4.2.0.ebuild
index e5a5919f291c..9ccffbce0805 100644
--- a/sci-physics/espresso/espresso-4.2.0.ebuild
+++ b/sci-physics/espresso/espresso-4.2.0.ebuild
@@ -24,9 +24,6 @@ LICENSE="GPL-3"
 SLOT="0"
 IUSE="cuda doc examples +fftw +hdf5 test"
 
-# unittest_decorators not packaged
-RESTRICT="test"
-
 REQUIRED_USE="
        ${PYTHON_REQUIRED_USE}"
 
@@ -34,7 +31,7 @@ RDEPEND="
        ${PYTHON_DEPS}
        $(python_gen_cond_dep '
                >=dev-python/cython-0.26.1[${PYTHON_USEDEP}]
-               dev-python/numpy[${PYTHON_USEDEP}]
+               <dev-python/numpy-2[${PYTHON_USEDEP}]
        ')
        cuda? ( >=dev-util/nvidia-cuda-toolkit-4.2.9-r1 )
        fftw? ( sci-libs/fftw:3.0 )
@@ -48,6 +45,11 @@ DEPEND="${RDEPEND}
                dev-texlive/texlive-latexextra
                virtual/latex-base
        )
+       test? (
+               $(python_gen_cond_dep '
+                       dev-python/scipy[${PYTHON_USEDEP}]
+               ')
+       )
 "
 
 DOCS=( AUTHORS NEWS Readme.md ChangeLog )
@@ -57,11 +59,19 @@ PATCHES=(
        # https://github.com/espressomd/espresso/pull/4655
        # boost 1.81
        "${FILESDIR}"/${P}-boost1.81.patch
+       
"${FILESDIR}"/0001-allow-building-test-deps-without-running-ctest-indir.patch
+       "${FILESDIR}"/${P}-test-deprecations.patch
+       "${FILESDIR}"/${P}-test-rounding.patch
 )
 
 src_prepare() {
        use cuda && cuda_src_prepare
        cmake_src_prepare
+
+       # These produce tests that aren't run by "make check", but ctest picks
+       # them up by default, against upstream's intention.
+       cd testsuite || die
+       cmake_comment_add_subdirectory cmake scripts
 }
 
 src_configure() {
@@ -73,7 +83,6 @@ src_configure() {
                -DCMAKE_DISABLE_FIND_PACKAGE_FFTW3=$(usex !fftw)
                -DWITH_HDF5=$(usex hdf5)
                -DCMAKE_DISABLE_FIND_PACKAGE_HDF5=$(usex !hdf5)
-               -DCMAKE_SKIP_RPATH=YES
        )
        cmake_src_configure
 }
@@ -85,7 +94,30 @@ src_compile() {
 }
 
 src_test() {
-       LD_PRELOAD="${BUILD_DIR}/src/core/Espresso_core.so" cmake_src_test
+       CMAKE_SKIP_TESTS=(
+               # These 13 tests fail with
+               # "The MPI_Type_free() function was called before MPI_INIT was 
invoked."
+               #
+               # I do not know why. But, we didn't used to run any tests at 
all,
+               # so, baby steps.
+               SingleReaction_test
+               reaction_methods_utils_test
+               rotation_test
+               grid_test
+               Lattice_test
+               lb_exceptions
+               thermostats_test
+               bonded_interactions_map_test
+               ObjectHandle_test
+               AutoParameters_test
+               Accumulators_test
+               Constraints_test
+               Actors_test
+       )
+
+       # testsuite uses exclude_from_all, and lists all targets as deps for 
their custom rule
+       cmake_build check
+       cmake_src_test
 }
 
 src_install() {

Reply via email to