1
0
mirror of https://github.com/sstephenson/bats.git synced 2024-11-17 11:42:33 +01:00

Cache preprocessed source for child test runs

This commit is contained in:
Sam Stephenson 2012-04-08 22:08:30 -05:00
parent 2f192ebffa
commit ad4bc2e196

View File

@ -78,6 +78,7 @@ bats_perform_tests() {
"$0" "$BATS_TEST_FILENAME" "$test_name" "$test_number" || status=1 "$0" "$BATS_TEST_FILENAME" "$test_name" "$test_number" || status=1
test_number=$(($test_number + 1)) test_number=$(($test_number + 1))
done done
rm -f "$BATS_TEST_SOURCE"
exit "$status" exit "$status"
} }
@ -108,11 +109,21 @@ if [ -z "$TMPDIR" ]; then
else else
BATS_TMPDIR="${TMPDIR%/}" BATS_TMPDIR="${TMPDIR%/}"
fi fi
BATS_OUT="$BATS_TMPDIR/bats.$(date "+%Y%m%d%H%M%S").$$"
BATS_TMPNAME="$BATS_TMPDIR/bats.$$"
BATS_PARENT_TMPNAME="$BATS_TMPDIR/bats.$PPID"
BATS_OUT="${BATS_TMPNAME}.out"
exec 3<&1 exec 3<&1
eval "$(bats-preprocess < "$BATS_TEST_FILENAME")" if [ -r "${BATS_PARENT_TMPNAME}.src" ]; then
BATS_TEST_SOURCE="${BATS_PARENT_TMPNAME}.src"
else
BATS_TEST_SOURCE="${BATS_TMPNAME}.src"
bats-preprocess < "$BATS_TEST_FILENAME" > "$BATS_TEST_SOURCE"
fi
source "$BATS_TEST_SOURCE"
if [ "$#" -eq 0 ]; then if [ "$#" -eq 0 ]; then
bats_perform_tests "${BATS_TEST_NAMES[@]}" bats_perform_tests "${BATS_TEST_NAMES[@]}"