Function | src_test |
---|---|
Purpose | Run pre-install test scripts |
Sandbox | Enabled |
Privilege | user |
Called for | ebuild |
src_test
From sys-apps/portage-2.1.2.9
src_test() {
if emake -j1 check -n &> /dev/null; then
vecho ">>> Test phase [check]: ${CATEGORY}/${PF}"
if ! emake -j1 check; then
hasq test $FEATURES && die "Make check failed. See above for details."
hasq test $FEATURES || eerror "Make check failed. See above for details."
fi
elif emake -j1 test -n &> /dev/null; then
vecho ">>> Test phase [test]: ${CATEGORY}/${PF}"
if ! emake -j1 test; then
hasq test $FEATURES && die "Make test failed. See above for details."
hasq test $FEATURES || eerror "Make test failed. See above for details."
fi
else
vecho ">>> Test phase [none]: ${CATEGORY}/${PF}"
fi
}
src_test
src_test() {
cd "${S}"/src/testdir
# Test 49 won't work inside a portage environment
sed -i -e 's~test49.out~~g' Makefile
# Try to run the non-gui tests only
make test-nongui \
|| die "At least one test failed"
}
src_test
Tasks
Often the default src_test
is fine. Sometimes it is necessary
to remove certain tests from the list if they cannot be used with a
portage environment. Reasons for such a failure could include:
Usually, removing the relevant test from the Makefile
using sed
or skipping a particular make
target is
sufficient.
emake
should not be used for src_test
—
trying to
parallelise tests unless the Makefile
was specifically designed
for this can cause all sorts of strange problems.
Try to ensure that tests work properly for your ebuild. A good test suite is extremely helpful for arch maintainers.
Sometimes it is necessary to skip tests entirely. This can be done
using a dummy src_test
function:
src_test() {
# Tests don't even remotely work inside portage
true
}
Another option would be to set RESTRICT="test"
in the ebuild.