]> diplodocus.org Git - nmh/blobdiff - test/folder/test-sortm
Tell make that uip/mhical.c depends on sbr/icalparse.h
[nmh] / test / folder / test-sortm
index 0e331544abce8bc2615d4832b2f98e42ee7c0941..7835516713095321c28cf9dd98178a323f95689a 100755 (executable)
@@ -7,7 +7,7 @@
 
 set -e
 
-if test -z "${MH_OBJ_DIR}"; then
+if test -z "$MH_OBJ_DIR"; then
     srcdir=`dirname $0`/../..
     MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
 fi
@@ -16,12 +16,15 @@ fi
 
 setup_test
 
+check_exit '-eq 1' sortm -
+
 expected=$MH_TEST_DIR/$$.expected
 actual=$MH_TEST_DIR/$$.actual
 
 cd $MH_TEST_DIR
 
 # check -help
+start_test "-help"
 cat >"$expected" <<EOF
 Usage: sortm [+folder] [msgs] [switches]
   switches are:
@@ -32,14 +35,17 @@ Usage: sortm [+folder] [msgs] [switches]
   -nolimit
   -[no]verbose
   -[no]all
+  -[no]check
   -version
   -help
 EOF
 
-sortm -help >"$actual" 2>&1
+#### Skip nmh intro text.
+run_prog sortm -help 2>&1 | sed '/^$/,$d' >"$actual"
 check "$expected" "$actual"
 
 # check -version
+start_test "-version"
 case `sortm -version` in
   sortm\ --*) ;;
   *       ) echo "$0: sortm -v generated unexpected output" 1>&2
@@ -67,6 +73,7 @@ This is message number 12
 EOF
 
 # check with no options
+start_test "with no options"
 cat >"$expected" <<EOF
    1  09/28 Test12             common subject<<This is message number 12 >>
    2  09/29 Test1              Testing message 1<<This is message number 1 >>
@@ -82,11 +89,12 @@ cat >"$expected" <<EOF
   12  09/29 Test11             Re: common subject<<This is message number 11 >>
 EOF
 
-sortm
-scan >"$actual"
+run_prog sortm
+scan -width 80 >"$actual"
 check "$expected" "$actual"
 
 # check +folder
+start_test "+folder"
 cat >"$expected" <<EOF
    1  09/28 Test12             common subject<<This is message number 12 >>
    2+ 09/29 Test1              Testing message 1<<This is message number 1 >>
@@ -103,11 +111,12 @@ cat >"$expected" <<EOF
 EOF
 
 refile first +inbox; folder -pack >/dev/null
-sortm +inbox
-scan >"$actual"
+run_prog sortm +inbox
+scan -width 80 >"$actual"
 check "$expected" "$actual"
 
 # check -verbose
+start_test "-verbose"
 cat >"$expected" <<EOF
 sorting by datefield date
 renaming message chain from 12 to 1
@@ -137,11 +146,12 @@ message 1 becomes message 2
 EOF
 
 refile first +inbox; folder -pack >/dev/null
-sortm -verbose >"$actual"
-scan >>"$actual"
+run_prog sortm -verbose >"$actual"
+scan -width 80 >>"$actual"
 check "$expected" "$actual"
 
 # check -noverbose
+start_test "-noverbose"
 cat >"$expected" <<EOF
    1  09/28 Test12             common subject<<This is message number 12 >>
    2+ 09/29 Test1              Testing message 1<<This is message number 1 >>
@@ -158,11 +168,12 @@ cat >"$expected" <<EOF
 EOF
 
 refile first +inbox; folder -pack >/dev/null
-sortm -verbose -noverbose >"$actual"
-scan >>"$actual"
+run_prog sortm -verbose -noverbose >"$actual"
+scan -width 80 >>"$actual"
 check "$expected" "$actual"
 
 # check msgs
+start_test "msgs"
 cat >"$expected" <<EOF
    1  09/28 Test12             common subject<<This is message number 12 >>
    2  09/29 Test2              Testing message 2<<This is message number 2 >>
@@ -179,11 +190,12 @@ cat >"$expected" <<EOF
 EOF
 
 refile first +inbox; folder -pack >/dev/null
-sortm first last
-scan >"$actual"
+run_prog sortm first last
+scan -width 80 >"$actual"
 check "$expected" "$actual"
 
 # check -datefield
+start_test "-datefield"
 cat >"$expected" <<EOF
    1  09/29 Test11             Re: common subject<<This is message number 11 >>
    2  09/29 Test2              Testing message 2<<This is message number 2 >>
@@ -199,11 +211,12 @@ cat >"$expected" <<EOF
   12+ 09/29 Test1              Testing message 1<<This is message number 1 >>
 EOF
 
-sortm -datefield Alt-Date 1 11
-scan >"$actual"
+run_prog sortm -datefield Alt-Date 1 11
+scan -width 80 >"$actual"
 check "$expected" "$actual"
 
 # check -textfield subject (datefield major, subjects grouped)
+start_test "-textfield subject (datefield major, subjects grouped)"
 cat >"$expected" <<EOF
    1  09/28 Test12             common subject<<This is message number 12 >>
    2  09/29 Test11             Re: common subject<<This is message number 11 >>
@@ -219,11 +232,12 @@ cat >"$expected" <<EOF
   12+ 09/29 Test1              Testing message 1<<This is message number 1 >>
 EOF
 
-sortm -textfield subject
-scan >"$actual"
+run_prog sortm -textfield subject
+scan -width 80 >"$actual"
 check "$expected" "$actual"
 
 # check -nolimit
+start_test "-nolimit"
 cat >"$expected" <<EOF
    1  09/28 Test12             common subject<<This is message number 12 >>
    2  09/29 Test11             Re: common subject<<This is message number 11 >>
@@ -239,11 +253,12 @@ cat >"$expected" <<EOF
   12+ 09/29 Test1              Testing message 1<<This is message number 1 >>
 EOF
 
-sortm -textfield subject -limit 0 -nolimit
-scan >"$actual"
+run_prog sortm -textfield subject -limit 0 -nolimit
+scan -width 80 >"$actual"
 check "$expected" "$actual"
 
 # check -textfield subject -limit 0 (subject sort)
+start_test "-textfield subject -limit 0 (subject sort)"
 cat >"$expected" <<EOF
    1  09/29 Test11             Re: common subject<<This is message number 11 >>
    2  09/28 Test12             common subject<<This is message number 12 >>
@@ -260,11 +275,12 @@ cat >"$expected" <<EOF
 EOF
 
 refile 2-7 +inbox; refile 1 +inbox; folder -pack last >/dev/null
-sortm -textfield subject -limit 0
-scan >"$actual"
+run_prog sortm -textfield subject -limit 0
+scan -width 80 >"$actual"
 check "$expected" "$actual"
 
 # check -textfield -limit 0 (text sort)
+start_test "-textfield -limit 0 (text sort)"
 cat >"$expected" <<EOF
    1  09/29 Test10             Testing message 10<<This is message number 10 >>
    2  09/29 Test11             Re: common subject<<This is message number 11 >>
@@ -281,11 +297,12 @@ cat >"$expected" <<EOF
 EOF
 
 refile 2-7 +inbox; refile 1 +inbox; folder -pack last >/dev/null
-sortm -textfield from -limit 0
-scan >"$actual"
+run_prog sortm -textfield from -limit 0
+scan -width 80 >"$actual"
 check "$expected" "$actual"
 
 # check -textfield with finite -limit that doesn't cover message 13
+start_test "-textfield with finite -limit that doesn't cover message 13"
 cat >$MH_TEST_DIR/Mail/inbox/13 <<EOF || exit 1
 From: Test13 <test13@example.com>
 To: Some User <user@example.com>
@@ -312,11 +329,12 @@ cat >"$expected" <<EOF
 EOF
 
 refile 2-7 +inbox; refile 1 +inbox; folder -pack last >/dev/null
-sortm -textfield subject -limit 10
-scan >"$actual"
+run_prog sortm -textfield subject -limit 10
+scan -width 80 >"$actual"
 check "$expected" "$actual"
 
 # check -textfield with finite -limit that does cover message 13
+start_test "-textfield with finite -limit that does cover message 13"
 cat >"$expected" <<EOF
    1  09/28 Test12             common subject<<This is message number 12 >>
    2  09/29 Test11             Re: common subject<<This is message number 11 >>
@@ -334,11 +352,12 @@ cat >"$expected" <<EOF
 EOF
 
 refile 2-7 +inbox; refile 1 +inbox; folder -pack last >/dev/null
-sortm -textfield subject -limit 60
-scan >"$actual"
+run_prog sortm -textfield subject -limit 60
+scan -width 80 >"$actual"
 check "$expected" "$actual"
 
 # check -notextfield
+start_test "-notextfield"
 cat >"$expected" <<EOF
    1  09/28 Test12             common subject<<This is message number 12 >>
    2  09/29 Test10             Testing message 10<<This is message number 10 >>
@@ -356,14 +375,16 @@ cat >"$expected" <<EOF
 EOF
 
 refile 2-7 +inbox; refile 1 +inbox; folder -pack last >/dev/null
-sortm -textfield subject -limit 60 -notextfield
-scan >"$actual"
+run_prog sortm -textfield subject -limit 60 -notextfield
+scan -width 80 >"$actual"
 check "$expected" "$actual"
 
 # check -noall
+start_test "-noall"
 run_test 'sortm -noall' 'sortm: must specify messages to sort with -noall'
 
 # check -all
+start_test "-all"
 cat >"$expected" <<EOF
    1  09/28 Test12             common subject<<This is message number 12 >>
    2+ 09/29 Test10             Testing message 10<<This is message number 10 >>
@@ -381,9 +402,68 @@ cat >"$expected" <<EOF
 EOF
 
 refile first +inbox; folder -pack >/dev/null
-sortm -noall -all
-scan >"$actual"
+run_prog sortm -noall -all
+scan -width 80 >"$actual"
+check "$expected" "$actual"
+
+# check -check
+start_test "-check"
+cat >"$expected" <<EOF
+sortm: can't parse date field in message 14, will use file modification time
+sortm: errors found, no messages sorted
+EOF
+
+sed -e 's/Sep//' $MH_TEST_DIR/Mail/inbox/7 > $MH_TEST_DIR/Mail/inbox/14
+set +e
+run_prog sortm -check >"$actual" 2>&1
+set -e
+check "$expected" "$actual"
+
+cat >"$expected" <<EOF
+   1  09/28 Test12             common subject<<This is message number 12 >>
+   2+ 09/29 Test10             Testing message 10<<This is message number 10 >>
+   3  09/29 Test5              Testing message 5<<This is message number 5 >>
+   4  09/29 Test6              Testing message 6<<This is message number 6 >>
+   5  09/29 Test7              Testing message 7<<This is message number 7 >>
+   6  09/29 Test8              Testing message 8<<This is message number 8 >>
+   7  09/29 Test9              Testing message 9<<This is message number 9 >>
+   8  09/29 Test1              Testing message 1<<This is message number 1 >>
+   9  09/29 Test2              Testing message 2<<This is message number 2 >>
+  10  09/29 Test3              Testing message 3<<This is message number 3 >>
+  11  09/29 Test4              Testing message 4<<This is message number 4 >>
+  12  09/29 Test11             Re: common subject<<This is message number 11 >>
+  13  10/31 Test13             Re: common subject<<This is message number 13 >>
+  14  01/00 Test9              Testing message 9<<This is message number 9 >>
+EOF
+scan -width 80 >"$actual"
+check "$expected" "$actual"
+
+# check -nocheck
+start_test "-nocheck"
+cat >"$expected" <<EOF
+   1  09/28 Test12             common subject<<This is message number 12 >>
+   2+ 09/29 Test10             Testing message 10<<This is message number 10 >>
+   3  09/29 Test5              Testing message 5<<This is message number 5 >>
+   4  09/29 Test6              Testing message 6<<This is message number 6 >>
+   5  09/29 Test7              Testing message 7<<This is message number 7 >>
+   6  09/29 Test8              Testing message 8<<This is message number 8 >>
+   7  09/29 Test9              Testing message 9<<This is message number 9 >>
+   8  09/29 Test1              Testing message 1<<This is message number 1 >>
+   9  09/29 Test2              Testing message 2<<This is message number 2 >>
+  10  09/29 Test3              Testing message 3<<This is message number 3 >>
+  11  09/29 Test4              Testing message 4<<This is message number 4 >>
+  12  09/29 Test11             Re: common subject<<This is message number 11 >>
+  13  10/31 Test13             Re: common subject<<This is message number 13 >>
+  14  01/00 Test9              Testing message 9<<This is message number 9 >>
+EOF
+
+sed -e 's/Sep//' $MH_TEST_DIR/Mail/inbox/7 > $MH_TEST_DIR/Mail/inbox/14
+run_test 'sortm -check -nocheck' \
+         "sortm: can't parse date field in message 14, will use file \
+modification time"
+scan -width 80 >"$actual"
 check "$expected" "$actual"
 
 
+finish_test
 exit ${failed:-0}