You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
isle/tests/entrypoint.sh

80 lines
1.6 KiB

set -e
# cd into script's directory
cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null
root=$(pwd)
REGEXS=()
while [[ $# -gt 0 ]]; do
case $1 in
-h|--help)
cat <<EOF
USAGE: [flags] [test regexs...]
FLAGS
--keep-tmp
--verbose (-v)
--help (-h)
EOF
exit 1
;;
-v|--verbose)
VERBOSE=1
shift
;;
--keep-tmp)
KEEP_TMP=1
shift
;;
*)
REGEXS+=("$1")
shift
;;
esac
done
TMPDIR="$(mktemp --tmpdir -d isle-tests.XXXXXX)"
if [ -z "$KEEP_TMP" ]; then trap 'rm -rf $TMPDIR' EXIT; fi
export TMPDIR
echo "tmp dir is $TMPDIR"
test_files=$(
find ./cases -type f -name '*.sh' \
| sed "s|^\./cases/||" \
| grep -v entrypoint.sh \
| sort -n
)
for r in "${REGEXS[@]}"; do
test_files="$(echo "$test_files" | grep "$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
(
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 ! $SHELL -e -x "$root/cases/$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
)
done
echo -e '\nall tests succeeded!'