aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDuncaen <mail@duncano.de>2017-03-31 16:10:43 +0200
committerDuncaen <mail@duncano.de>2017-03-31 16:10:47 +0200
commitb960d5e3cc1abd1849ef6c0019f16ab7dd77e52a (patch)
tree3215ac0466314d28619bd005908a678d4699d480
parent08ea54953ffdac34e60b2d93b0777324413f737d (diff)
downloadmblaze-b960d5e3cc1abd1849ef6c0019f16ab7dd77e52a.tar.gz
t: add check_test
-rwxr-xr-xt/2000-mpick.t6
-rw-r--r--t/3000-magrep.t10
-rw-r--r--t/4000-msed.t2
-rw-r--r--t/7000-mseq.t6
-rw-r--r--t/8000-mflag.t12
-rw-r--r--t/lib.sh11
6 files changed, 29 insertions, 18 deletions
diff --git a/t/2000-mpick.t b/t/2000-mpick.t
index 90dacb8..26735d0 100755
--- a/t/2000-mpick.t
+++ b/t/2000-mpick.t
@@ -61,8 +61,8 @@ Greetings
!
check 'search subject' 'mlist inbox | mpick /wow | grep -q inbox/cur/9:2,'
-check 'search addr' 'mlist inbox | mpick peter@example.org | wc -l | grep -qx 2'
-check 'search name' 'mlist inbox | mpick "Peter Example" | wc -l | grep -qx 2'
-check 'search spam' 'mlist inbox | mpick -t "trashed && subject =~ \"pdf\"" | wc -l | grep -qx 1'
+check_test 'search addr' -eq 2 'mlist inbox | mpick peter@example.org | wc -l'
+check_test 'search name' -eq 2 'mlist inbox | mpick "Peter Example" | wc -l'
+check_test 'search spam' -eq 1 'mlist inbox | mpick -t "trashed && subject =~ \"pdf\"" | wc -l'
)
diff --git a/t/3000-magrep.t b/t/3000-magrep.t
index 4113f50..d25a97b 100644
--- a/t/3000-magrep.t
+++ b/t/3000-magrep.t
@@ -46,11 +46,11 @@ inbox/cur/3:2,
export MAILSEQ=seq
-check 'subject' 'magrep subject:nice | wc -l | grep -qx 1'
-check 'ignorecase' 'magrep -i subject:NICE | wc -l | grep -qx 1'
-check 'invert' 'magrep -v subject:nice | wc -l | grep -qx 2'
-check 'max matches' 'magrep -m 2 from:Piet | wc -l | grep -qx 2'
-check 'long subject' 'magrep subject:aliqua | wc -l | grep -qx 1'
+check_test 'subject' -eq 1 'magrep subject:nice | wc -l'
+check_test 'ignorecase' -eq 1 'magrep -i subject:NICE | wc -l'
+check_test 'invert' -eq 2 'magrep -v subject:nice | wc -l'
+check_test 'max matches' -eq 2 'magrep -m 2 from:Piet | wc -l'
+check_test 'long subject' -eq 1 'magrep subject:aliqua | wc -l'
echo 'inbox/cur/1:2,: subject: wow nice subject' >expect
check_same 'print' 'magrep -p subject:nice' 'cat expect'
diff --git a/t/4000-msed.t b/t/4000-msed.t
index d4c8ff6..2efe900 100644
--- a/t/4000-msed.t
+++ b/t/4000-msed.t
@@ -27,7 +27,7 @@ export MAILSEQ=seq
check 'append new' 'msed "/foobar/a/value/" 1 | grep "Foobar: value"'
check 'append existing' 'msed "/subject/a/world/" 1 | grep -v "world"'
-check 'append multiple' 'msed "/foo/a/catch/;/bar/a/catch/" 1 | grep -c catch | grep -qx 2'
+check_test 'append multiple' -eq 2 'msed "/foo/a/catch/;/bar/a/catch/" 1 | grep -c catch'
check 'change' 'msed "/subject/c/world/" 1 | grep "Subject: world"'
check 'delete' 'msed "/message-id/d" 1 | grep -v "Message-Id"'
check 'substitute' 'msed "/subject/s/\(Hello\)/\1 World/" 1 | grep "^Subject: Hello World$"'
diff --git a/t/7000-mseq.t b/t/7000-mseq.t
index 77eb596..6a3a5c5 100644
--- a/t/7000-mseq.t
+++ b/t/7000-mseq.t
@@ -27,9 +27,9 @@ check 'set current' 'mseq -C 1 && mseq . | grep "inbox/cur/1:2,"'
check 'set next' 'mseq -C + && mseq . | grep "inbox/cur/2:2,"'
check 'set prev' 'mseq -C - && mseq . | grep "inbox/cur/1:2,"'
check 'last' 'mseq "$" | grep "inbox/cur/10:2,"'
-check 'whole thread' 'mseq 6= | wc -l | grep -qx 4'
-check 'subthread' 'mseq 7_ | wc -l | grep -qx 2'
+check_test 'whole thread' -eq 4 'mseq 6= | wc -l'
+check_test 'subthread' -eq 2 'mseq 7_ | wc -l'
check 'parent' 'mseq 6^ | grep "inbox/cur/5_1:2,"'
-check 'range' 'mseq 1:3 | wc -l | grep -qx 3'
+check_test 'range' -eq 3 'mseq 1:3 | wc -l'
)
diff --git a/t/8000-mflag.t b/t/8000-mflag.t
index 38ab639..166f741 100644
--- a/t/8000-mflag.t
+++ b/t/8000-mflag.t
@@ -20,16 +20,16 @@ ln -sf inbox/cur/1:2, cur
export MAILSEQ=seq MAILCUR=cur
check 'mark seen' 'mflag -S 1 && [ -e "inbox/cur/1:2,S" ]'
-check 'fix seq' 'mseq -f | mseq -S | wc -l | grep -qx 2'
+check_test 'fix seq' -eq 2 'mseq -f | mseq -S | wc -l'
check 'mark replied' 'mflag -R 1 && [ -e "inbox/cur/1:2,RS" ]'
-check 'fix seq' 'mseq -f | mseq -S | wc -l | grep -qx 2'
+check_test 'fix seq' -eq 2 'mseq -f | mseq -S | wc -l'
check 'unmark replied' 'mflag -r 1 && [ -e "inbox/cur/1:2,S" ]'
-check 'fix seq' 'mseq -f | mseq -S | wc -l | grep -qx 2'
+check_test 'fix seq' -eq 2 'mseq -f | mseq -S | wc -l'
check 'mark flagged' 'mflag -F 1 && [ -e "inbox/cur/1:2,FS" ]'
-check 'fix seq' 'mseq -f | mseq -S | wc -l | grep -qx 2'
+check_test 'fix seq' -eq 2 'mseq -f | mseq -S | wc -l'
check 'unmark flagged' 'mflag -f 1 && [ -e "inbox/cur/1:2,S" ]'
-check 'fix seq' 'mseq -f | mseq -S | wc -l | grep -qx 2'
+check_test 'fix seq' -eq 2 'mseq -f | mseq -S | wc -l'
check 'unmark seen' 'mflag -s 1 && [ -e "inbox/cur/1:2," ]'
-check 'fix seq' 'mseq -f | mseq -S | wc -l | grep -qx 2'
+check_test 'fix seq' -eq 2 'mseq -f | mseq -S | wc -l'
)
diff --git a/t/lib.sh b/t/lib.sh
index 81c2dd1..567250b 100644
--- a/t/lib.sh
+++ b/t/lib.sh
@@ -14,6 +14,17 @@ check() {
true
}
+check_test() {
+ msg=$1; op=$2; test=$3; shift 3
+ if [ "$(eval "$@" 2>/dev/null)" "$op" "$test" ]; then
+ printf 'ok - %s\n' "$msg"
+ else
+ printf 'not ok - %s\n' "$msg"
+ false
+ fi
+ true
+}
+
check_same() {
msg=$1
shift