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