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)"
echo "$version" | grep -q 'Release:'
echo "$version" | grep -q 'Platform:'
echo "$version" | grep -q 'Build Platform:'
isle version | grep -q 'Release:'
isle version | grep -q 'Platform:'
isle version | grep -q 'Build Platform:'

View File

@ -15,29 +15,41 @@ done
# cd into script's directory
cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null
root=$(pwd)
tmp="$(mktemp --tmpdir -d isle-tests.XXXXXX)"
trap 'rm -rf $tmp' EXIT
TMPDIR="$(mktemp --tmpdir -d isle-tests.XXXXXX)"
trap 'rm -rf $TMPDIR' EXIT
export TMPDIR="$tmp"
export 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 "running test $file"
echo -e "number of tests: $(echo "$test_files" | wc -l)\n"
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
echo "TEST FAILED"
echo "output of test is as follows"
echo "------------------------------"
cat "$tmp/$file.log"
echo "------------------------------"
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
exit 1
fi
done
echo -e '\ntests succeeded!'
echo -e '\nall tests succeeded!'