aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2021-01-24 02:02:01 -0300
committerEuAndreh <eu@euandre.org>2021-01-24 02:02:01 -0300
commit6f5e467c6bb3f0369e4220be20ab1461cd9334ce (patch)
tree58837e1134ea6366b9504514e13f01fd90cd3222
parentAdd test to for help flags (diff)
downloadremembering-6f5e467c6bb3f0369e4220be20ab1461cd9334ce.tar.gz
remembering-6f5e467c6bb3f0369e4220be20ab1461cd9334ce.tar.xz
Add tests/signals.sh
Diffstat (limited to '')
-rw-r--r--Makefile1
-rwxr-xr-xtests/signals.sh29
2 files changed, 30 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index 315b54e..b899716 100644
--- a/Makefile
+++ b/Makefile
@@ -28,6 +28,7 @@ uninstall:
check:
sh tests/cli-opts.sh
+ sh tests/signals.sh
if [ -d .git ]; then \
echo 'Assuming Git repository, running development checks.'; \
diff --git a/tests/signals.sh b/tests/signals.sh
new file mode 100755
index 0000000..ad7ed2d
--- /dev/null
+++ b/tests/signals.sh
@@ -0,0 +1,29 @@
+#!/bin/sh
+set -u
+
+. tests/lib.sh
+
+test_status_is_zero_when_command_is_successful() {
+ printf 'a\n' | sh remembering -pp1 -c 'head -n1' 1>/dev/null 2>/dev/null
+ STATUS=$?
+ assert_status 0
+
+ printf '' | sh remembering -pp2 -c 'exit 0' 1>/dev/null 2>/dev/null
+ STATUS=$?
+ assert_status 0
+
+ seq 9 | sh remembering -pp3 -c 'grep 7' 1>/dev/null 2>/dev/null
+ STATUS=$?
+ assert_status 0
+}
+
+test_status_is_forwarded_from_command() {
+ for status in $(seq 1 125); do
+ printf '' | sh remembering -pp4 -c "exit $status" 1>/dev/null 2>/dev/null
+ STATUS=$?
+ assert_status "$status"
+ done
+}
+
+test_status_is_zero_when_command_is_successful
+test_status_is_forwarded_from_command