Files
jq/tests/setup
T

47 lines
960 B
Bash
Raw Normal View History

2015-06-18 19:38:25 -07:00
#!/bin/sh
2015-06-26 23:36:34 -05:00
# This is meant to be included by each test's shell script driver.
2016-01-17 12:23:05 -06:00
if [ -n "$TRACE_TESTS" ]; then
set -x
fi
2015-06-26 23:36:34 -05:00
set -eu
2015-06-18 19:38:25 -07:00
JQTESTDIR=$(cd "$(dirname "$0")" && pwd)
JQBASEDIR=$JQTESTDIR/..
JQ=${JQ:-$JQBASEDIR/jq}
2015-06-18 19:38:25 -07:00
2024-02-10 18:23:50 +01:00
# Some tests have locale-dependent output; use C locale. Fixes #3038
LC_ALL=C
export LC_ALL
if [ -n "${ENABLE_VALGRIND-}" ] && which valgrind > /dev/null; then
2015-06-18 19:38:25 -07:00
VALGRIND="valgrind --error-exitcode=1 --leak-check=full \
--suppressions=$JQTESTDIR/onig.supp \
--suppressions=$JQTESTDIR/local.supp"
2017-02-22 23:01:56 -06:00
VG_EXIT0=--error-exitcode=0
2015-06-18 19:38:25 -07:00
Q=-q
else
VALGRIND=
2017-02-22 23:01:56 -06:00
VG_EXIT0=
2015-06-18 19:38:25 -07:00
Q=
fi
mods=$JQTESTDIR/modules
clean=true
d=
clean () {
if ! $clean; then
echo "See temp files in $d!"
elif [ -n "$d" ]; then
rm -rf "$d"
fi
}
trap clean EXIT
2017-10-28 10:51:59 -04:00
d=$(mktemp -d -t jqXXXXXX || true)
2015-06-18 19:38:25 -07:00
if [ -z "$d" ]; then
echo "Your OS does not support mktemp(1) -d" 1>&2
exit 1
2015-06-18 19:38:25 -07:00
fi