]> 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 0753ecb0f4d90f404c29c20b1bc5a93881758149..7835516713095321c28cf9dd98178a323f95689a 100755 (executable)
@@ -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:
@@ -37,10 +40,12 @@ Usage: sortm [+folder] [msgs] [switches]
   -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
@@ -68,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 >>
@@ -83,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 >>
@@ -104,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
@@ -138,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 >>
@@ -159,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 >>
@@ -180,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 >>
@@ -200,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 >>
@@ -220,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 >>
@@ -240,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 >>
@@ -261,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 >>
@@ -282,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>
@@ -313,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 >>
@@ -335,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 >>
@@ -357,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 >>
@@ -382,11 +402,12 @@ 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
@@ -394,7 +415,7 @@ EOF
 
 sed -e 's/Sep//' $MH_TEST_DIR/Mail/inbox/7 > $MH_TEST_DIR/Mail/inbox/14
 set +e
-sortm -check >"$actual" 2>&1
+run_prog sortm -check >"$actual" 2>&1
 set -e
 check "$expected" "$actual"
 
@@ -414,10 +435,11 @@ cat >"$expected" <<EOF
   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 >"$actual"
+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 >>
@@ -439,8 +461,9 @@ 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 >"$actual"
+scan -width 80 >"$actual"
 check "$expected" "$actual"
 
 
+finish_test
 exit ${failed:-0}