about summary refs log tree commit diff
path: root/t/errors.t
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2017-11-01 17:43:44 +0100
committerLeah Neukirchen <leah@vuxu.org>2017-11-01 17:43:44 +0100
commit2afc62578a26989713acebe085bbdcb8616069d6 (patch)
tree208d1f2aafd6e8f9070509df987f31a7c1357cb1 /t/errors.t
parent478beee7c496dee2b21cfa22c7d984e376954f7b (diff)
downloadxe-2afc62578a26989713acebe085bbdcb8616069d6.tar.gz
xe-2afc62578a26989713acebe085bbdcb8616069d6.tar.xz
xe-2afc62578a26989713acebe085bbdcb8616069d6.zip
convert test suite to tap3 and split into multiple files
Diffstat (limited to 't/errors.t')
-rwxr-xr-xt/errors.t104
1 files changed, 104 insertions, 0 deletions
diff --git a/t/errors.t b/t/errors.t
new file mode 100755
index 0000000..c2ecd5e
--- /dev/null
+++ b/t/errors.t
@@ -0,0 +1,104 @@
+#!/bin/sh
+export "PATH=.:$PATH"
+
+printf '1..13\n'
+printf '# error handling\n'
+
+tap3 'exit code on success' <<'EOF'
+xe
+>>>= 0
+EOF
+
+tap3 'exit code on other error' <<'EOF'
+true | xe -j NaN
+>>>= 1
+EOF
+
+tap3 'exit code on when command fails with 1-125' <<'EOF'
+xe -s 'exit 42'
+<<<
+a
+>>>= 123
+EOF
+
+tap3 'exit code on when command fails with 255' <<'EOF'
+xe -s 'exit 255'
+<<<
+a
+>>>= 124
+EOF
+
+tap3 'exit code when process was killed' <<'EOF'
+xe perl -e 'kill "KILL", $$'
+<<<
+a
+>>>= 125
+EOF
+
+# possible false positive result when exec returns ENOENT instead of ENOTDIR here
+tap3 'exit code when command cannot be run' <<'EOF'
+xe /dev/null/calc.exe
+<<<
+a
+>>>= 126
+EOF
+
+tap3 'exit code when command was not found' <<'EOF'
+xe /bin/calc.exe
+<<<
+a
+>>>= 127
+EOF
+
+tap3 'exit code on empty input when run with -R' <<'EOF'
+xe -R echo a
+>>>= 122
+EOF
+
+tap3 'doesn'\''t stop on errors by default' <<'EOF'
+xe -s 'if [ b = $1 ]; then false; else echo $1; fi'
+<<<
+a
+b
+c
+>>>
+a
+c
+>>>= 123
+EOF
+
+tap3 'stops on first error with -F' <<'EOF'
+xe -F -s 'if [ b = $1 ]; then false; else echo $1; fi'
+<<<
+a
+b
+c
+>>>
+a
+>>>= 123
+EOF
+
+tap3 'should close stdin when arguments were read from it' <<'EOF'
+xe -s 'sed q'
+<<<
+a
+b
+c
+>>>
+EOF
+
+tap3 'should not close stdin when arguments were read from command line' <<'EOF'
+yes | xe -a -s "sed q" -- 1 2 3
+>>>
+y
+y
+y
+EOF
+
+tap3 'should not close stdin when arguments were read from file' <<'EOF'
+yes | xe -f NEWS.md -s 'sed q' 2>&1 | sed 3q
+>>>
+y
+y
+y
+EOF