lib/command_duration: tests & whitespace
parent
1c2fc2837f
commit
866e5be86b
|
|
@ -8,43 +8,34 @@ function local_setup_file() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "plugins cmd-returned-notify: notify after elapsed time" {
|
@test "plugins cmd-returned-notify: notify after elapsed time" {
|
||||||
export NOTIFY_IF_COMMAND_RETURNS_AFTER=0
|
export NOTIFY_IF_COMMAND_RETURNS_AFTER=0
|
||||||
export COMMAND_DURATION_START_SECONDS="${EPOCHREALTIME:-$SECONDS}"
|
export COMMAND_DURATION_START_SECONDS="${EPOCHREALTIME:-$SECONDS}"
|
||||||
sleep 1
|
sleep 1
|
||||||
run precmd_return_notification
|
run precmd_return_notification
|
||||||
assert_success
|
assert_success
|
||||||
assert_output $'\a'
|
assert_output $'\a'
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "plugins cmd-returned-notify: do not notify before elapsed time" {
|
@test "plugins cmd-returned-notify: do not notify before elapsed time" {
|
||||||
export NOTIFY_IF_COMMAND_RETURNS_AFTER=10
|
export NOTIFY_IF_COMMAND_RETURNS_AFTER=10
|
||||||
export COMMAND_DURATION_START_SECONDS="${EPOCHREALTIME:-$SECONDS}"
|
export COMMAND_DURATION_START_SECONDS="${EPOCHREALTIME:-$SECONDS}"
|
||||||
sleep 1
|
sleep 1
|
||||||
run precmd_return_notification
|
run precmd_return_notification
|
||||||
assert_success
|
assert_success
|
||||||
assert_output $''
|
assert_output $''
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "plugins cmd-returned-notify: preexec no output" {
|
@test "lib command_duration: preexec no output" {
|
||||||
export COMMAND_DURATION_START_SECONDS=
|
export COMMAND_DURATION_START_SECONDS=
|
||||||
run _command_duration_pre_exec
|
run _command_duration_pre_exec
|
||||||
assert_success
|
assert_success
|
||||||
assert_output ""
|
assert_output ""
|
||||||
}
|
}
|
||||||
|
@test "lib command_duration: preexec set COMMAND_DURATION_START_SECONDS" {
|
||||||
@test "plugins cmd-returned-notify: preexec no output env set" {
|
export COMMAND_DURATION_START_SECONDS=
|
||||||
skip "wut"
|
assert_equal "${COMMAND_DURATION_START_SECONDS}" ""
|
||||||
export COMMAND_DURATION_START_SECONDS="${EPOCHREALTIME:-$SECONDS}"
|
NOW="${EPOCHREALTIME:-$SECONDS}"
|
||||||
run _command_duration_pre_exec
|
_command_duration_pre_exec
|
||||||
assert_failure
|
# We need to make sure to account for nanoseconds...
|
||||||
assert_output ""
|
assert_equal "${COMMAND_DURATION_START_SECONDS%.*}" "${NOW%.*}"
|
||||||
}
|
|
||||||
|
|
||||||
@test "plugins cmd-returned-notify: preexec set COMMAND_DURATION_START_SECONDS" {
|
|
||||||
export COMMAND_DURATION_START_SECONDS=
|
|
||||||
assert_equal "${COMMAND_DURATION_START_SECONDS}" ""
|
|
||||||
NOW="${EPOCHREALTIME:-$SECONDS}"
|
|
||||||
_command_duration_pre_exec
|
|
||||||
# We need to make sure to account for nanoseconds...
|
|
||||||
assert_equal "${COMMAND_DURATION_START_SECONDS%.*}" "${NOW%.*}"
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ function common_setup_file() {
|
||||||
function setup_libs() {
|
function setup_libs() {
|
||||||
local lib
|
local lib
|
||||||
# Use a loop to allow convenient short-circuiting for some test files
|
# Use a loop to allow convenient short-circuiting for some test files
|
||||||
for lib in "log" "utilities" "helpers" "search" "preexec" "colors"; do
|
for lib in "log" "utilities" "helpers" "search" "preexec" "colors" "command_duration"; do
|
||||||
load "${BASH_IT?}/lib/${lib}.bash" || return
|
load "${BASH_IT?}/lib/${lib}.bash" || return
|
||||||
# shellcheck disable=SC2015 # short-circuit if we've reached the requested library
|
# shellcheck disable=SC2015 # short-circuit if we've reached the requested library
|
||||||
[[ "${lib}" == "${1:-}" ]] && return 0 || true
|
[[ "${lib}" == "${1:-}" ]] && return 0 || true
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue