Set XDG variables on a per-test basis
This commit is contained in:
parent
bc798acffa
commit
d2d25d3621
@ -1,14 +1,25 @@
|
||||
set -e
|
||||
|
||||
REGEXS=()
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
-v|--verbose)
|
||||
VERBOSE=1
|
||||
shift;
|
||||
shift
|
||||
;;
|
||||
-h|--help)
|
||||
cat <<EOF
|
||||
USAGE: [flags] [test regexs...]
|
||||
FLAGS
|
||||
--verbose (-v)
|
||||
--help (-h)
|
||||
EOF
|
||||
exit 1
|
||||
;;
|
||||
*)
|
||||
echo "USAGE: [-v|--verbose]"
|
||||
exit 1
|
||||
REGEXS+=("$1")
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
@ -30,25 +41,35 @@ test_files=$(
|
||||
| sort -n\
|
||||
)
|
||||
|
||||
for r in "${REGEXS[@]}"; do
|
||||
test_files="$(echo "$test_files" | grep -P "$r")"
|
||||
done
|
||||
|
||||
echo -e "number of tests: $(echo "$test_files" | wc -l)\n"
|
||||
for file in $test_files; do
|
||||
echo "$file"
|
||||
|
||||
[ -z "$VERBOSE" ] && output="$TMPDIR/$file.log" || output=/dev/stdout
|
||||
|
||||
tmp="$TMPDIR/$file.tmp"
|
||||
mkdir -p "$tmp"
|
||||
(
|
||||
export TMPDIR="$TMPDIR/$file.tmp"
|
||||
export XDG_RUNTIME_DIR="$TMPDIR/.run"
|
||||
export XDG_DATA_HOME="$TMPDIR/.data"
|
||||
|
||||
if ! (cd "$tmp" && TMPDIR="$tmp" $SHELL -e -x "$root/$file" >"$output" 2>&1); then
|
||||
echo "$file FAILED"
|
||||
if [ -z "$VERBOSE" ]; then
|
||||
echo "output of test is as follows"
|
||||
echo "------------------------------"
|
||||
cat "$TMPDIR/$file.log"
|
||||
echo "------------------------------"
|
||||
mkdir -p "$TMPDIR" "$XDG_RUNTIME_DIR" "$XDG_DATA_HOME"
|
||||
cd "$TMPDIR"
|
||||
|
||||
if ! $SHELL -e -x "$root/$file" >"$output" 2>&1; then
|
||||
echo "$file FAILED"
|
||||
if [ -z "$VERBOSE" ]; then
|
||||
echo "output of test is as follows"
|
||||
echo "------------------------------"
|
||||
cat "$output"
|
||||
echo "------------------------------"
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
)
|
||||
done
|
||||
|
||||
echo -e '\nall tests succeeded!'
|
||||
|
Loading…
Reference in New Issue
Block a user