-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
056c392
commit e76dd7f
Showing
1 changed file
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
# shellcheck shell=bats | ||
|
||
load ../test_helper | ||
|
||
@test "lib preexec: __bp_require_not_readonly()" { | ||
run type -t __bp_require_not_readonly | ||
assert_failure | ||
|
||
load ../../lib/preexec.bash | ||
assert_success | ||
|
||
run type -t __bp_require_not_readonly | ||
assert_success | ||
|
||
export -r HISTCONTROL=blah:blah PROMPT_COMMAND="silly;rabbit" | ||
|
||
run __bp_require_not_readonly | ||
assert_success | ||
} | ||
|
||
@test "lib preexec: __bp_adjust_histcontrol()" { | ||
run type -t __bp_adjust_histcontrol | ||
assert_failure | ||
|
||
load ../../lib/preexec.bash | ||
assert_success | ||
|
||
run type -t __bp_adjust_histcontrol | ||
assert_success | ||
|
||
export HISTCONTROL=blah:blah | ||
|
||
run __bp_adjust_histcontrol | ||
assert_success | ||
} | ||
|
||
@test "vendor preexec: __bp_install_after_session_init() without existing" { | ||
test_prompt_string="" | ||
export PROMPT_COMMAND="$test_prompt_string" | ||
|
||
load ../../vendor/github.com/rcaloras/bash-preexec/bash-preexec.sh | ||
assert_success | ||
|
||
assert_equal "${PROMPT_COMMAND}" $'__bp_trap_string="$(trap -p DEBUG)"\ntrap - DEBUG\n__bp_install' | ||
} | ||
|
||
@test "vendor preexec: __bp_install_after_session_init() with existing" { | ||
test_prompt_string="nah" | ||
export PROMPT_COMMAND="$test_prompt_string" | ||
|
||
load ../../vendor/github.com/rcaloras/bash-preexec/bash-preexec.sh | ||
assert_success | ||
|
||
assert_equal "${PROMPT_COMMAND}" "$test_prompt_string"$'\n__bp_trap_string="$(trap -p DEBUG)"\ntrap - DEBUG\n__bp_install' | ||
} | ||
|
||
@test "vendor preexec: __bp_install_after_session_init() delayed" { | ||
test_prompt_string="nah" | ||
export PROMPT_COMMAND="$test_prompt_string" | ||
export __bp_delay_install="blarg" | ||
|
||
load ../../vendor/github.com/rcaloras/bash-preexec/bash-preexec.sh | ||
assert_success | ||
|
||
assert_equal "${PROMPT_COMMAND}" "$test_prompt_string" | ||
|
||
run __bp_install_after_session_init | ||
assert_success | ||
|
||
__bp_install_after_session_init | ||
assert_equal "${PROMPT_COMMAND}" "$test_prompt_string"$'\n__bp_trap_string="$(trap -p DEBUG)"\ntrap - DEBUG\n__bp_install' | ||
} | ||
|
||
@test "vendor preexec: __bp_install() without existing" { | ||
test_prompt_string="" | ||
export PROMPT_COMMAND="$test_prompt_string" | ||
|
||
load ../../vendor/github.com/rcaloras/bash-preexec/bash-preexec.sh | ||
assert_success | ||
|
||
run __bp_install | ||
assert_success | ||
|
||
__bp_install | ||
assert_equal "${PROMPT_COMMAND}" $'__bp_precmd_invoke_cmd\n__bp_interactive_mode' | ||
} | ||
|
||
@test "vendor preexec: __bp_install() with existing" { | ||
test_prompt_string="nah" | ||
export PROMPT_COMMAND="$test_prompt_string" | ||
|
||
load ../../vendor/github.com/rcaloras/bash-preexec/bash-preexec.sh | ||
assert_success | ||
|
||
run __bp_install | ||
assert_success | ||
|
||
__bp_install | ||
assert_equal "${PROMPT_COMMAND}" $'__bp_precmd_invoke_cmd\n'"$test_prompt_string"$'\n__bp_interactive_mode' | ||
} |