The documentation at [1] states that the default src_test is this: src_test() { if emake check -n &> /dev/null; then emake check elif emake test -n &> /dev/null; then emake test fi } But when I create an ebuild with a src_test as above, tests fail if the Makefile does not provide tests. The reason is that emake forces the ebuild to die if it fails. Therefore emake must not be used for tests like above. [1] https://devmanual.gentoo.org/ebuild-writing/functions/src_test/index.html Reproducible: Always
@mgorny: The code snippet for src_test() originates from this commit of yours: https://gitweb.gentoo.org/proj/devmanual.git/commit/?id=96ce954fee8e464edadc473a5ba2da8b8352b6cb PMS doesn't provide a default implementation, but only says: "The default implementation used when the ebuild lacks the src_test function must, if tests are enabled, run emake check if and only if such a target is available, or if not run emake test if and only if such a target is available. In both cases, if emake returns non-zero the build must be aborted." The implementation in Portage's phase-helpers.sh is this: __eapi0_src_test() { # Since we don't want emake's automatic die # support (EAPI 4 and later), and we also don't # want the warning messages that it produces if # we call it in 'nonfatal' mode, we use emake_cmd # to emulate the desired parts of emake behavior. local emake_cmd="${MAKE:-make} ${MAKEOPTS} ${EXTRA_EMAKE}" local internal_opts= if ___eapi_default_src_test_disables_parallel_jobs; then internal_opts+=" -j1" fi if $emake_cmd ${internal_opts} check -n &> /dev/null; then __vecho "${emake_cmd} ${internal_opts} check" >&2 $emake_cmd ${internal_opts} check || \ die "Make check failed. See above for details." elif $emake_cmd ${internal_opts} test -n &> /dev/null; then __vecho "${emake_cmd} ${internal_opts} test" >&2 $emake_cmd ${internal_opts} test || \ die "Make test failed. See above for details." fi } This is too long (and too clumsy) and therefore unsuitable for the devmanual, but note its introductory comment. So, how about the following, which should be equivalent to the above except for its output? src_test() { if nonfatal emake check -n &> /dev/null; then emake check elif nonfatal emake test -n &> /dev/null; then emake test fi }
Yes, that makes sense.
Created attachment 654616 [details, diff] ebuild-writing/functions/src_test: Add nonfatal to if conditions.
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/proj/devmanual.git/commit/?id=929b5a3a85c3cf34cf967db579a45d8f3ee88564 commit 929b5a3a85c3cf34cf967db579a45d8f3ee88564 Author: Ulrich Müller <ulm@gentoo.org> AuthorDate: 2020-08-14 12:15:27 +0000 Commit: Ulrich Müller <ulm@gentoo.org> CommitDate: 2020-08-28 18:59:51 +0000 ebuild-writing/functions/src_test: Add nonfatal to if conditions. Closes: https://bugs.gentoo.org/722418 Signed-off-by: Ulrich Müller <ulm@gentoo.org> ebuild-writing/functions/src_test/text.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)