set -e while [[ $# -gt 0 ]]; do case $1 in -v|--verbose) VERBOSE=1 shift; ;; *) echo "USAGE: [-v|--verbose]" exit 1 ;; esac done # cd into script's directory cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null tmp="$(mktemp --tmpdir -d isle-tests.XXXXXX)" trap 'rm -rf $tmp' EXIT export TMPDIR="$tmp" echo "tmp dir is $TMPDIR" echo -e '\nrunning all tests...\n' for file in $(find . -type f -name '*.sh' | grep -v entrypoint.sh | sort -n); do echo "running test $file" [ -z "$VERBOSE" ] && output="$tmp/$file.log" || output=/dev/stdout if ! $SHELL -e -x "$file" >"$output" 2>&1; then echo "TEST FAILED" echo "output of test is as follows" echo "------------------------------" cat "$tmp/$file.log" echo "------------------------------" exit 1 fi done echo -e '\ntests succeeded!'