isle/tests/entrypoint.sh

56 lines
1.1 KiB
Bash
Raw Normal View History

2023-08-30 16:16:19 +00:00
set -e
2023-08-30 18:08:40 +00:00
while [[ $# -gt 0 ]]; do
case $1 in
-v|--verbose)
VERBOSE=1
shift;
;;
*)
echo "USAGE: [-v|--verbose]"
exit 1
;;
esac
done
2023-08-30 16:16:19 +00:00
# cd into script's directory
cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null
root=$(pwd)
2023-08-30 16:16:19 +00:00
TMPDIR="$(mktemp --tmpdir -d isle-tests.XXXXXX)"
trap 'rm -rf $TMPDIR' EXIT
2023-08-30 16:16:19 +00:00
export TMPDIR
2023-08-30 16:16:19 +00:00
echo "tmp dir is $TMPDIR"
test_files=$(
find . -type f -name '*.sh' \
| sed "s|^\./||" \
| grep -v entrypoint.sh \
| sort -n\
)
2023-08-30 16:16:19 +00:00
echo -e "number of tests: $(echo "$test_files" | wc -l)\n"
for file in $test_files; do
echo "$file"
2023-08-30 18:08:40 +00:00
[ -z "$VERBOSE" ] && output="$TMPDIR/$file.log" || output=/dev/stdout
2023-08-30 18:08:40 +00:00
tmp="$TMPDIR/$file.tmp"
mkdir -p "$tmp"
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 "------------------------------"
fi
2023-08-30 16:16:19 +00:00
exit 1
fi
done
echo -e '\nall tests succeeded!'
2023-08-30 16:16:19 +00:00