mirror of
https://github.com/eth-p/bat-extras.git
synced 2025-03-03 16:01:15 +01:00
test: Add tests for batpipe
This commit is contained in:
parent
5f5a5e87a9
commit
dccceaf749
4
.gitignore
vendored
4
.gitignore
vendored
@ -11,3 +11,7 @@
|
|||||||
.download
|
.download
|
||||||
bin
|
bin
|
||||||
man
|
man
|
||||||
|
|
||||||
|
# Side-Effects
|
||||||
|
/test/data/.config/fish
|
||||||
|
/test/data/.local/share/fish
|
||||||
|
BIN
test/data/compressed.txt.gz
Normal file
BIN
test/data/compressed.txt.gz
Normal file
Binary file not shown.
7
test/shim/batpipe.sh
Normal file
7
test/shim/batpipe.sh
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
batpipe() {
|
||||||
|
"$(batpipe_path)" "$@" || return $?
|
||||||
|
}
|
||||||
|
|
||||||
|
batpipe_path() {
|
||||||
|
echo "${BIN_DIR}/batpipe${BIN_SUFFIX}"
|
||||||
|
}
|
26
test/suite/batpipe.sh
Normal file
26
test/suite/batpipe.sh
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
setup() {
|
||||||
|
use_shim 'batpipe'
|
||||||
|
}
|
||||||
|
|
||||||
|
test:detected_bash_shell() {
|
||||||
|
description "Test it can detect a bash shell."
|
||||||
|
command -v "bash" &>/dev/null || skip "Test requires bash shell."
|
||||||
|
|
||||||
|
output="$(SHELL="bash" bash --login -c "{ \"$(batpipe_path)\"; }")" # This hack prevents bash from exec()'ing itself.
|
||||||
|
grep '^LESSOPEN=' <<< "$output" >/dev/null || fail "Detected the wrong shell for bash."
|
||||||
|
}
|
||||||
|
|
||||||
|
test:detected_fish_shell() {
|
||||||
|
description "Test it can detect a bash shell."
|
||||||
|
command -v "fish" &>/dev/null || skip "Test requires fish shell."
|
||||||
|
|
||||||
|
output="$(SHELL="fish" fish --login -c "$(batpipe_path)")"
|
||||||
|
grep '^set -x' <<< "$output" >/dev/null || fail "Detected the wrong shell for fish."
|
||||||
|
}
|
||||||
|
|
||||||
|
test:viewer_gzip() {
|
||||||
|
description "Test it can view .gz files."
|
||||||
|
command -v "gunzip" &>/dev/null || skip "Test requires gunzip."
|
||||||
|
|
||||||
|
assert_equal "$(batpipe compressed.txt.gz)" "OK"
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user