mirror of
https://github.com/eth-p/bat-extras.git
synced 2025-01-31 09:29:14 +01:00
Add test for pager lib
This commit is contained in:
parent
285ac66303
commit
08acea3bf4
73
test/tests/lib.pager.sh
Normal file
73
test/tests/lib.pager.sh
Normal file
@ -0,0 +1,73 @@
|
||||
pager_info() {
|
||||
source "${DIR_LIB}/pager.sh"
|
||||
printf "\n"
|
||||
printf "PAGER=%q\n" "$PAGER"
|
||||
printf "BAT_PAGER=%q\n" "$BAT_PAGER"
|
||||
|
||||
printf "SCRIPT_PAGER_CMD=("
|
||||
if [[ "${#SCRIPT_PAGER_CMD[@]}" -gt 0 ]]; then
|
||||
printf "%q" "${SCRIPT_PAGER_CMD[0]}"
|
||||
if [[ "${#SCRIPT_PAGER_CMD[@]}" -gt 1 ]]; then
|
||||
printf " %q" "${SCRIPT_PAGER_CMD[@]:1}"
|
||||
fi
|
||||
fi
|
||||
printf ")\n"
|
||||
|
||||
printf "SCRIPT_PAGER_ARGS=("
|
||||
if [[ "${#SCRIPT_PAGER_ARGS[@]}" -gt 0 ]]; then
|
||||
printf "%q" "${SCRIPT_PAGER_ARGS[0]}"
|
||||
if [[ "${#SCRIPT_PAGER_ARGS[@]}" -gt 1 ]]; then
|
||||
printf " %q" "${SCRIPT_PAGER_ARGS[@]:1}"
|
||||
fi
|
||||
fi
|
||||
printf ")\n"
|
||||
}
|
||||
|
||||
pager_test() {
|
||||
if [[ "$1" = "TTY" ]]; then
|
||||
script -q /dev/null bash "${BASH_SOURCE[0]}" --execute
|
||||
elif [[ "$1" = "FILE" ]]; then
|
||||
bash "${BASH_SOURCE[0]}" --execute | cat
|
||||
fi
|
||||
}
|
||||
|
||||
if [[ "$1" = "--execute" ]]; then
|
||||
pager_info
|
||||
exit
|
||||
fi
|
||||
|
||||
# First test.
|
||||
unset PAGER
|
||||
unset BAT_PAGER
|
||||
pager_test TTY
|
||||
|
||||
# Second test.
|
||||
unset PAGER
|
||||
export BAT_PAGER='less'
|
||||
pager_test TTY
|
||||
|
||||
# Third test.
|
||||
unset PAGER
|
||||
export BAT_PAGER='less -R -F'
|
||||
pager_test TTY
|
||||
|
||||
# Forth test.
|
||||
export PAGER='less'
|
||||
unset BAT_PAGER
|
||||
pager_test TTY
|
||||
|
||||
# Fifth test.
|
||||
export PAGER='less -R -F'
|
||||
unset BAT_PAGER
|
||||
pager_test TTY
|
||||
|
||||
# Sixth test.
|
||||
export PAGER='less -R -F'
|
||||
export BAT_PAGER='more'
|
||||
pager_test TTY
|
||||
|
||||
# Final test.
|
||||
export PAGER='less -R -F'
|
||||
export BAT_PAGER='more'
|
||||
pager_test FILE
|
||||
|
35
test/tests/lib.pager.snapshot
Normal file
35
test/tests/lib.pager.snapshot
Normal file
@ -0,0 +1,35 @@
|
||||
|
||||
PAGER=''
|
||||
BAT_PAGER=''
|
||||
SCRIPT_PAGER_CMD=('')
|
||||
SCRIPT_PAGER_ARGS=()
|
||||
|
||||
PAGER=''
|
||||
BAT_PAGER=less
|
||||
SCRIPT_PAGER_CMD=(less)
|
||||
SCRIPT_PAGER_ARGS=()
|
||||
|
||||
PAGER=''
|
||||
BAT_PAGER=less\ -R\ -F
|
||||
SCRIPT_PAGER_CMD=(less -R -F)
|
||||
SCRIPT_PAGER_ARGS=()
|
||||
|
||||
PAGER=less
|
||||
BAT_PAGER=''
|
||||
SCRIPT_PAGER_CMD=(less)
|
||||
SCRIPT_PAGER_ARGS=(-R)
|
||||
|
||||
PAGER=less\ -R\ -F
|
||||
BAT_PAGER=''
|
||||
SCRIPT_PAGER_CMD=(less\ -R\ -F)
|
||||
SCRIPT_PAGER_ARGS=()
|
||||
|
||||
PAGER=less\ -R\ -F
|
||||
BAT_PAGER=more
|
||||
SCRIPT_PAGER_CMD=(more)
|
||||
SCRIPT_PAGER_ARGS=()
|
||||
|
||||
PAGER=less\ -R\ -F
|
||||
BAT_PAGER=more
|
||||
SCRIPT_PAGER_CMD=()
|
||||
SCRIPT_PAGER_ARGS=()
|
Loading…
Reference in New Issue
Block a user