Skip to content

Commit b040474

Browse files
committed
eval-tester, bash.bash: attempt time delta fix
on CI eval-tester time deltas are always huge, maybe this will fix it
1 parent bdc1a47 commit b040474

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

commands/eval-tester

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ function eval_tester() (
242242
printf '%s' "$?" >"$semaphore_tty_status"
243243
)
244244
# capture
245-
local command_string time actual_exit_status actual_stdout actual_stderr actual_tty
245+
local command_string time_before time_after time_ actual_exit_status actual_stdout actual_stderr actual_tty
246246
args+=(
247247
--trailing-newlines="$option_trailing_newlines"
248248
--redirect-status={actual_exit_status}
@@ -259,10 +259,11 @@ function eval_tester() (
259259
fi
260260
command_string="$(echo-escape-command -- "${option_cmd[@]}")"
261261
echo-style --h2="$title" --newline --element+bold="$command_string"
262-
time="$(__get_epoch_time)"
262+
time_before="$(__get_epoch_time)"
263263
# __eval_helper --quiet="$option_quiet" --wrap <-- if this is done, element rendering, quite mode, and time duration can all be moved to eval-helper
264264
__do "${args[@]}" -- "${option_cmd[@]}"
265-
time="$(echo-math -- "$(__get_epoch_time) - $time")"
265+
time_after="$(__get_epoch_time)"
266+
time_delta="$(echo-math -- "$time_after - $time_before")"
266267
if [[ $BASH_CLOSURE_OF_FILE_DESCRIPTOR_CLOSES_THE_STDIN_OF_ITS_PROCESS_SUBSTITUTION == 'no' ]]; then
267268
__to --target="$TERMINAL_OUTPUT_TARGET" -- $'\004'
268269
fi
@@ -300,10 +301,10 @@ function eval_tester() (
300301

301302
# pass or fail
302303
if [[ $FAIL == 'yes' ]]; then
303-
echo-style --e2="$title" ' ' --code="in $time seconds" $'\n'
304+
echo-style --e2="$title" ' ' --code="in $time_delta seconds" $'\n'
304305
return 221 # ECUSTOM 221 Tests failed
305306
else
306-
echo-style --g2="$title" ' ' --code="in $time seconds" $'\n'
307+
echo-style --g2="$title" ' ' --code="in $time_delta seconds" $'\n'
307308
fi
308309
)
309310

sources/bash.bash

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -618,9 +618,9 @@ else
618618
function __get_epoch_time {
619619
local time size
620620
time="$(date +%s.%N)" || return
621-
if [[ $time == *000 ]]; then
621+
if [[ $time == *.*0 ]]; then
622622
size="${#time}"
623-
printf '%s' "${time:0:size-3}" || return # trim last 3 digits, as they are just zeroes
623+
printf '%s' "${time:0:size-1}" || return # trim trailing decimal zeroes
624624
else
625625
printf '%s' "$time" || return
626626
fi

0 commit comments

Comments
 (0)