Have tests each create a separate tmpdir, and cd into it
This commit is contained in:
parent
48675ee095
commit
bc798acffa
@ -15,31 +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"
|
||||||
|
for file in $test_files; do
|
||||||
echo "$file"
|
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"
|
||||||
|
mkdir -p "$tmp"
|
||||||
|
|
||||||
|
if ! (cd "$tmp" && TMPDIR="$tmp" $SHELL -e -x "$root/$file" >"$output" 2>&1); then
|
||||||
echo "$file FAILED"
|
echo "$file FAILED"
|
||||||
if [ -z "$VERBOSE" ]; then
|
if [ -z "$VERBOSE" ]; then
|
||||||
echo "output of test is as follows"
|
echo "output of test is as follows"
|
||||||
echo "------------------------------"
|
echo "------------------------------"
|
||||||
cat "$tmp/$file.log"
|
cat "$TMPDIR/$file.log"
|
||||||
echo "------------------------------"
|
echo "------------------------------"
|
||||||
fi
|
fi
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
echo -e '\ntests succeeded!'
|
echo -e '\nall tests succeeded!'
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user