Exheredludis/paludis/util/run_test.sh
Marvin Schmidt b3f7c9b092 run_test.sh: Strip path from test program
TEST_SCRIPT_DIR already contains the path, so it should be removed from
the test program (seems like automake only includes the paths for test
programs with an extension, so TEST_SCRIPT_DIR is still needed for test
programs without extension).

Otherwise out-of-tree builds fail their python tests because the
cleanup/setup scripts aren't found due to the duplicated path:

>>> No ../../../python/../../../python/choices_TEST_setup.sh to run

It turns out that distcheck only worked with automake versions prior to
1.15 because of the folder structure it used. With the duplicated path
it ended up finding the scripts in paludis/python instead of the
distributed ones in paludis/paludis-x.y.z/python.
automake 1.15 changed the build folder for distcheck from $(distdir)/_build
to $(distdir)/_build/sub which caused the distcheck to fail and expose
this problem.

Change-Id: Ie0627bf507d791db7497eeca383160fa50ccbe18
Reviewed-on: https://galileo.mailstation.de/gerrit/5948
Reviewed-by: Bo Ørsted Andresen <zlin@exherbo.org>
2016-05-03 13:35:01 +02:00

61 lines
1.6 KiB
Bash

#!/usr/bin/env bash
# vim: set ft=sh sw=4 sts=4 et :
testname=$(basename ${2:-${1}})
interp=
[[ ${testname%.py} != ${testname} ]] && interp="${PYTHON}"
[[ ${testname%.rb} != ${testname} ]] && interp="${RUBY} -I ./.libs/"
testname=${testname%.rb}
testname=${testname%.py}
testname=${testname%.bash}
export PALUDIS_TEST_PROGRAM=$testname
if test -f "$TEST_SCRIPT_DIR""${testname}"_"cleanup.sh" ; then
echo ">>> cleanup for test ${testname}"
if ! "$TEST_SCRIPT_DIR""${testname}"_"cleanup.sh" ; then
echo ">>> exiting with error for test ${testname}"
exit 255
fi
else
echo ">>> No $TEST_SCRIPT_DIR${testname}_cleanup.sh to run"
fi
if test -f "$TEST_SCRIPT_DIR""${testname}"_"setup.sh" ; then
echo ">>> setup for test ${testname}"
if ! "$TEST_SCRIPT_DIR""${testname}"_"setup.sh" ; then
echo ">>> exiting with error for test ${testname}"
exit 255
fi
else
echo ">>> No $TEST_SCRIPT_DIR${testname}_setup.sh to run"
fi
now=$(date +'%s' )
echo ">>> test ${testname}"
$interp ${@}
code=$?
duration=$(( $(date +'%s' ) - ${now} ))
if [[ 0 != ${code} ]] ; then
echo ">>> test ${testname} returned ${code} [${duration}s]"
echo ">>> exiting with error for test ${testname}"
exit 255
fi
if test -f "$TEST_SCRIPT_DIR""${testname}"_"cleanup.sh" ; then
echo ">>> cleanup for test ${testname}"
if ! "$TEST_SCRIPT_DIR""${testname}"_"cleanup.sh" ; then
echo ">>> exiting with error for test ${testname}"
exit 255
fi
else
echo ">>> No $TEST_SCRIPT_DIR${testname}_cleanup.sh to run"
fi
echo ">>> exiting with success for test ${testname} [${duration}s]"
exit 0