bug: Use en_US when fetching EPOCHREALTIME

Isolates fetching of EPOCHREALTIME to a function which sets LC_ALL=en_US.UTF-8.
This ensures that the value is in decimal format, regardless of runtime locale.

bug: Hide duration when no command executed
This commit is contained in:
David Farrell
2022-10-26 15:23:11 -07:00
parent 1c9cfd056b
commit 7c7e4f90ec
3 changed files with 23 additions and 7 deletions

View File

@@ -9,7 +9,7 @@ function local_setup_file() {
@test "plugins cmd-returned-notify: notify after elapsed time" {
export NOTIFY_IF_COMMAND_RETURNS_AFTER=0
export COMMAND_DURATION_START_SECONDS="${EPOCHREALTIME:-$SECONDS}"
export COMMAND_DURATION_START_SECONDS="$(_shell_duration_en)"
sleep 1
run precmd_return_notification
assert_success
@@ -18,7 +18,7 @@ function local_setup_file() {
@test "plugins cmd-returned-notify: do not notify before elapsed time" {
export NOTIFY_IF_COMMAND_RETURNS_AFTER=10
export COMMAND_DURATION_START_SECONDS="${EPOCHREALTIME:-$SECONDS}"
export COMMAND_DURATION_START_SECONDS="$(_shell_duration_en)"
sleep 1
run precmd_return_notification
assert_success
@@ -34,7 +34,7 @@ function local_setup_file() {
@test "lib command_duration: preexec set COMMAND_DURATION_START_SECONDS" {
export COMMAND_DURATION_START_SECONDS=
assert_equal "${COMMAND_DURATION_START_SECONDS}" ""
NOW="${EPOCHREALTIME:-$SECONDS}"
NOW="$(_shell_duration_en)"
_command_duration_pre_exec
# We need to make sure to account for nanoseconds...
assert_equal "${COMMAND_DURATION_START_SECONDS%.*}" "${NOW%.*}"