From dccceaf749bfa6771b3bb113911aaf7a4ae49a29 Mon Sep 17 00:00:00 2001 From: Ethan P Date: Tue, 30 Mar 2021 19:26:08 -0700 Subject: [PATCH] test: Add tests for batpipe --- .gitignore | 4 ++++ test/data/compressed.txt.gz | Bin 0 -> 23 bytes test/shim/batpipe.sh | 7 +++++++ test/suite/batpipe.sh | 26 ++++++++++++++++++++++++++ 4 files changed, 37 insertions(+) create mode 100644 test/data/compressed.txt.gz create mode 100644 test/shim/batpipe.sh create mode 100644 test/suite/batpipe.sh 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 0000000000000000000000000000000000000000..1cb7ef776e6bcf755ef1862d4c6aebf79acab963 GIT binary patch literal 23 ecmb2|=3vmio1DPF{Q3JcCI/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" +}