Compare commits

...

2 Commits

Author SHA1 Message Date
Brian Picciano
bc798acffa Have tests each create a separate tmpdir, and cd into it 2023-08-31 22:07:36 +02:00
Brian Picciano
48675ee095 Fix output of error logs in verbose testing 2023-08-31 21:46:56 +02:00
2 changed files with 29 additions and 18 deletions

View File

@ -1,4 +1,3 @@
version="$(isle version)" isle version | grep -q 'Release:'
echo "$version" | grep -q 'Release:' isle version | grep -q 'Platform:'
echo "$version" | grep -q 'Platform:' isle version | grep -q 'Build Platform:'
echo "$version" | grep -q 'Build Platform:'

View File

@ -15,29 +15,41 @@ done
# cd into script's directory # cd into script's directory
cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null
root=$(pwd)
tmp="$(mktemp --tmpdir -d isle-tests.XXXXXX)" TMPDIR="$(mktemp --tmpdir -d isle-tests.XXXXXX)"
trap 'rm -rf $tmp' EXIT trap 'rm -rf $TMPDIR' EXIT
export TMPDIR="$tmp" export TMPDIR
echo "tmp dir is $TMPDIR" echo "tmp dir is $TMPDIR"
echo -e '\nrunning all tests...\n' test_files=$(
find . -type f -name '*.sh' \
| sed "s|^\./||" \
| grep -v entrypoint.sh \
| sort -n\
)
for file in $(find . -type f -name '*.sh' | grep -v entrypoint.sh | sort -n); do echo -e "number of tests: $(echo "$test_files" | wc -l)\n"
echo "running test $file" for file in $test_files; do
echo "$file"
[ -z "$VERBOSE" ] && output="$tmp/$file.log" || output=/dev/stdout [ -z "$VERBOSE" ] && output="$TMPDIR/$file.log" || output=/dev/stdout
if ! $SHELL -e -x "$file" >"$output" 2>&1; then tmp="$TMPDIR/$file.tmp"
echo "TEST FAILED" mkdir -p "$tmp"
echo "output of test is as follows"
echo "------------------------------" if ! (cd "$tmp" && TMPDIR="$tmp" $SHELL -e -x "$root/$file" >"$output" 2>&1); then
cat "$tmp/$file.log" echo "$file FAILED"
echo "------------------------------" if [ -z "$VERBOSE" ]; then
echo "output of test is as follows"
echo "------------------------------"
cat "$TMPDIR/$file.log"
echo "------------------------------"
fi
exit 1 exit 1
fi fi
done done
echo -e '\ntests succeeded!' echo -e '\nall tests succeeded!'