|
|
|
@ -1,15 +1,26 @@ |
|
|
|
|
set -e |
|
|
|
|
|
|
|
|
|
REGEXS=() |
|
|
|
|
|
|
|
|
|
while [[ $# -gt 0 ]]; do |
|
|
|
|
case $1 in |
|
|
|
|
-v|--verbose) |
|
|
|
|
VERBOSE=1 |
|
|
|
|
shift; |
|
|
|
|
shift |
|
|
|
|
;; |
|
|
|
|
*) |
|
|
|
|
echo "USAGE: [-v|--verbose]" |
|
|
|
|
-h|--help) |
|
|
|
|
cat <<EOF |
|
|
|
|
USAGE: [flags] [test regexs...] |
|
|
|
|
FLAGS |
|
|
|
|
--verbose (-v) |
|
|
|
|
--help (-h) |
|
|
|
|
EOF |
|
|
|
|
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" |
|
|
|
|
|
|
|
|
|
mkdir -p "$TMPDIR" "$XDG_RUNTIME_DIR" "$XDG_DATA_HOME" |
|
|
|
|
cd "$TMPDIR" |
|
|
|
|
|
|
|
|
|
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 "------------------------------" |
|
|
|
|
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!' |
|
|
|
|