@@ -55,6 +55,11 @@ function testrunner::absolute_path() {
5555 printf " $( cd " $( dirname " $1 " ) " && pwd) /$( basename " $1 " ) "
5656}
5757
58+ function testrunner::pid() {
59+ # Portable subshell-aware PID
60+ exec bash -c ' echo $PPID'
61+ }
62+
5863declare test_output_dir=$( mktemp -d)
5964
6065function testrunner::run_test() {
@@ -162,6 +167,10 @@ function testrunner::run_tests() {
162167 testrunner::run_test teardown
163168 fi
164169
170+ # Clean up if test didn't do it
171+ testrunner::signal_children TERM
172+ testrunner::signal_children KILL
173+
165174 if [[ -z " $test_failure " ]]; then
166175 printf " \n" # Blank line in case the last test passed
167176 fi
@@ -236,7 +245,8 @@ function testrunner::print_test_output {
236245function testrunner::signal_children()
237246{
238247 local signal=${1:- TERM}
239- local pid=${2:- ${BASHPID:- $$ } }
248+ local subshell_pid=$( testrunner::pid)
249+ local pid=${2:- ${BASHPID:- ${subshell_pid:- $$ } } }
240250
241251 local child_pids=()
242252
@@ -316,7 +326,6 @@ for testsuite in "${testsuites[@]}"; do
316326 # Export results out of sub-shell
317327 printf " tests_total+=${tests_total} ; tests_failed+=${tests_failed} " >&3
318328
319- # Clean up if test didn't do it
320329 testrunner::signal_children TERM $$
321330 testrunner::signal_children KILL $$
322331 )
0 commit comments