@@ -34,7 +34,13 @@ SED="$(type -P sed)"
34
34
GREP=" $( type -P grep) "
35
35
RM=" $( type -P rm) "
36
36
SHUF=" $( 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
38
44
39
45
fail () {
40
46
local message=${1:- }
@@ -246,9 +252,9 @@ run_tests() {
246
252
local tests_to_run=" $( set | " $GREP " -E ' ^test.* \(\)' | " $GREP " -E " $test_pattern " | " $SED " -e ' s: .*::' | maybe_shuffle) "
247
253
fi
248
254
249
- local test_count=$( cat " ${TEMPFILE } " )
255
+ local test_count=$( cat " ${TEST_COUNT_FILE } " )
250
256
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 } "
252
258
253
259
for pending_test in $pending_tests
254
260
do
561
567
562
568
# run tests received as parameters
563
569
failure=0
564
- echo 0 > " ${TEMPFILE } "
570
+ echo 0 > " ${TEST_COUNT_FILE } "
565
571
for test_file in " $@ "
566
572
do
567
573
notify_suite_starting " $test_file "
@@ -587,10 +593,9 @@ done
587
593
588
594
if (( failure))
589
595
then
590
- notify_suites_failed " $( cat " ${TEMPFILE } " ) "
596
+ notify_suites_failed " $( cat " ${TEST_COUNT_FILE } " ) "
591
597
else
592
- notify_suites_succeded " $( cat " ${TEMPFILE } " ) "
598
+ notify_suites_succeded " $( cat " ${TEST_COUNT_FILE } " ) "
593
599
fi
594
600
595
- unlink " $TEMPFILE "
596
601
exit $failure
0 commit comments