@@ -126,7 +126,11 @@ function bashunit::console_results::print_execution_time() {
126126 return
127127 fi
128128
129- local time=$( bashunit::clock::total_runtime_in_milliseconds | awk ' {printf "%.0f", $1}' )
129+ local time
130+ time=$( bashunit::clock::total_runtime_in_milliseconds)
131+ # Strip decimal portion (integer truncation, Bash 3.0 compatible)
132+ time=" ${time%% .* } "
133+ time=" ${time:- 0} "
130134
131135 if [[ " $time " -lt 1000 ]]; then
132136 printf " ${_BASHUNIT_COLOR_BOLD} %s${_BASHUNIT_COLOR_DEFAULT} \n" \
@@ -144,8 +148,10 @@ function bashunit::console_results::print_execution_time() {
144148 return
145149 fi
146150
151+ local integer_part=$(( time / 1000 ))
152+ local decimal_part=$(( (time % 1000 ) / 10 ))
147153 local formatted_seconds
148- formatted_seconds=$( awk " BEGIN { printf \" %.2f \" , $time / 1000} " )
154+ formatted_seconds=$( printf " %d.%02d " " $integer_part " " $decimal_part " )
149155
150156 printf " ${_BASHUNIT_COLOR_BOLD} %s${_BASHUNIT_COLOR_DEFAULT} \n" \
151157 " Time taken: ${formatted_seconds} s"
@@ -160,8 +166,10 @@ function bashunit::console_results::format_duration() {
160166 local seconds=$(( time_in_seconds % 60 ))
161167 echo " ${minutes} m ${seconds} s"
162168 elif [[ " $duration_ms " -ge 1000 ]]; then
169+ local integer_part=$(( duration_ms / 1000 ))
170+ local decimal_part=$(( (duration_ms % 1000 ) / 10 ))
163171 local formatted_seconds
164- formatted_seconds=$( awk " BEGIN { printf \" %.2f \" , $duration_ms / 1000} " )
172+ formatted_seconds=$( printf " %d.%02d " " $integer_part " " $decimal_part " )
165173 echo " ${formatted_seconds} s"
166174 else
167175 echo " ${duration_ms} ms"
@@ -234,8 +242,10 @@ function bashunit::console_results::print_successful_test() {
234242 local seconds=$(( time_in_seconds % 60 ))
235243 time_display=" ${minutes} m ${seconds} s"
236244 elif [[ " $duration " -ge 1000 ]]; then
245+ local integer_part=$(( duration / 1000 ))
246+ local decimal_part=$(( (duration % 1000 ) / 10 ))
237247 local formatted_seconds
238- formatted_seconds=$( awk " BEGIN { printf \" %.2f \" , $duration / 1000} " )
248+ formatted_seconds=$( printf " %d.%02d " " $integer_part " " $decimal_part " )
239249 time_display=" ${formatted_seconds} s"
240250 else
241251 time_display=" ${duration} ms"
0 commit comments