@@ -34,7 +34,13 @@ SED="$(type -P sed)"
3434GREP=" $( type -P grep) "
3535RM=" $( type -P rm) "
3636SHUF=" $( type -P sort) -R"
37- TEMPFILE=" $( pwd) /$$ .tmp"
37+
38+ # Store the number of tests run in a file so that the value is available
39+ # from the parent process. This will become an issue if we start considering
40+ # parallel test execution in the future.
41+ TEST_COUNT_FILE=" $( mktemp) "
42+ # shellcheck disable=2064 # Use single quotes, expands now, not when signaled.
43+ trap " $RM -f \" $TEST_COUNT_FILE \" " EXIT
3844
3945fail () {
4046 local message=${1:- }
@@ -246,9 +252,9 @@ run_tests() {
246252 local tests_to_run=" $( set | " $GREP " -E ' ^test.* \(\)' | " $GREP " -E " $test_pattern " | " $SED " -e ' s: .*::' | maybe_shuffle) "
247253 fi
248254
249- local test_count=$( cat " ${TEMPFILE } " )
255+ local test_count=$( cat " ${TEST_COUNT_FILE } " )
250256 test_count=$(( test_count + $(count "$pending_tests ") + $(count "$tests_to_run ") + $(count "$skipped_tests ")) )
251- echo " ${test_count} " > " ${TEMPFILE } "
257+ echo " ${test_count} " > " ${TEST_COUNT_FILE } "
252258
253259 for pending_test in $pending_tests
254260 do
561567
562568# run tests received as parameters
563569failure=0
564- echo 0 > " ${TEMPFILE } "
570+ echo 0 > " ${TEST_COUNT_FILE } "
565571for test_file in " $@ "
566572do
567573 notify_suite_starting " $test_file "
@@ -587,10 +593,9 @@ done
587593
588594if (( failure))
589595then
590- notify_suites_failed " $( cat " ${TEMPFILE } " ) "
596+ notify_suites_failed " $( cat " ${TEST_COUNT_FILE } " ) "
591597else
592- notify_suites_succeded " $( cat " ${TEMPFILE } " ) "
598+ notify_suites_succeded " $( cat " ${TEST_COUNT_FILE } " ) "
593599fi
594600
595- unlink " $TEMPFILE "
596601exit $failure
0 commit comments