diff --git a/.gitignore b/.gitignore index 4e8f83d..d4d83d9 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,7 @@ .download bin man + +# Side-Effects +/test/data/.config/fish +/test/data/.local/share/fish diff --git a/test/data/compressed.txt.gz b/test/data/compressed.txt.gz new file mode 100644 index 0000000..1cb7ef7 Binary files /dev/null and b/test/data/compressed.txt.gz differ diff --git a/test/shim/batpipe.sh b/test/shim/batpipe.sh new file mode 100644 index 0000000..2c2b2b9 --- /dev/null +++ b/test/shim/batpipe.sh @@ -0,0 +1,7 @@ +batpipe() { + "$(batpipe_path)" "$@" || return $? +} + +batpipe_path() { + echo "${BIN_DIR}/batpipe${BIN_SUFFIX}" +} diff --git a/test/suite/batpipe.sh b/test/suite/batpipe.sh new file mode 100644 index 0000000..f16509f --- /dev/null +++ b/test/suite/batpipe.sh @@ -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" +}