flatpak/buildutil/tap-test
Sebastian Wick 14bfb56ba3 tests: Make it possible to use mesontest --test-args
This makes it possible to pass arguments to g_test_init via mesons
--test-args. This can be useful when one wants to run a single test with
`meson test testlibrary --test-args='-p /context'.
2025-10-13 18:31:33 +00:00

26 lines
583 B
Bash
Executable File

#! /bin/bash
#
# Run a test in tap mode, ensuring we have a temporary directory.
#
# The test binary is passed as $1
srcd=$(cd $(dirname $1) && pwd)
bn=$(basename $1)
shift
tempdir=$(mktemp -d /tmp/tap-test.XXXXXX)
touch ${tempdir}/.testtmp
function cleanup () {
if test -n "${TEST_SKIP_CLEANUP:-}"; then
echo "Skipping cleanup of ${tempdir}"
else if test -f ${tempdir}/.testtmp; then
rm "${tempdir}" -rf
fi
fi
}
trap cleanup EXIT
cd ${tempdir}
if [[ $bn == *.wrap ]]; then
WRAPPER=${srcd}/test-wrapper.sh
fi
$WRAPPER ${srcd}/${bn} -k --tap "$@"