Skip to content

Commit

Permalink
t: add check_test
Browse files Browse the repository at this point in the history
  • Loading branch information
Duncaen committed Mar 31, 2017
1 parent 08ea549 commit b960d5e
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 18 deletions.
6 changes: 3 additions & 3 deletions t/2000-mpick.t
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ Greetings
!

check 'search subject' 'mlist inbox | mpick /wow | grep -q inbox/cur/9:2,'
check 'search addr' 'mlist inbox | mpick [email protected] | 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 [email protected] | 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'

)
10 changes: 5 additions & 5 deletions t/3000-magrep.t
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion t/4000-msed.t
Original file line number Diff line number Diff line change
Expand Up @@ -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$"'
Expand Down
6 changes: 3 additions & 3 deletions t/7000-mseq.t
Original file line number Diff line number Diff line change
Expand Up @@ -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'

)
12 changes: 6 additions & 6 deletions t/8000-mflag.t
Original file line number Diff line number Diff line change
Expand Up @@ -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'

)
11 changes: 11 additions & 0 deletions t/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b960d5e

Please sign in to comment.