From ec251f5102aca59d99e09d07d10906d99514f2b4 Mon Sep 17 00:00:00 2001 From: David Levine Date: Sun, 24 Jun 2012 22:26:27 -0500 Subject: [PATCH] Added test-sortm. Also clarified some details in the sortm man page. --- Makefile.am | 2 +- man/sortm.man | 15 +- test/folder/test-sortm | 366 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 375 insertions(+), 8 deletions(-) create mode 100755 test/folder/test-sortm diff --git a/Makefile.am b/Makefile.am index 3f34108..b49fc53 100644 --- a/Makefile.am +++ b/Makefile.am @@ -46,7 +46,7 @@ TESTS = test/ali/test-ali \ test/bad-input/test-header \ test/burst/test-burst \ test/comp/test-comp-format \ - test/folder/test-create \ + test/folder/test-create test/folder/test-sortm \ test/folder/test-total test/format/test-localmbox \ test/format/test-myname test/format/test-myhost \ test/format/test-mymbox \ diff --git a/man/sortm.man b/man/sortm.man index 283cf12..47dcee3 100644 --- a/man/sortm.man +++ b/man/sortm.man @@ -53,11 +53,11 @@ The .I field switch causes .B sortm -to sort messages -by the specified text field. If this field is \*(lqsubject\*(rq, any -leading "re:" is stripped off. In any case, all characters except +to sort messages by the specified text field. All characters except letters and numbers are stripped and the resulting strings are sorted -datefield\-major, textfield\-minor, using a case insensitive comparison. +datefield\-major, textfield\-minor, using a case insensitive +comparison. If this field is \*(lqsubject\*(rq, any leading "re:" is +stripped off. .PP With .B \-textfield @@ -66,7 +66,7 @@ if .B \-limit .I days is specified, messages -with similar textfields that are dated within `days' of each other +with the same textfields that are dated within `days' of each other appear together. Specifying .B \-nolimit makes the limit infinity. @@ -75,7 +75,8 @@ With .IR 0 , the sort is instead made textfield\-major, date\-minor. .PP -For example, to order a folder by date-major, subject-minor, use: +For example, to order a folder by date-major, grouping messages with +the same subject on the same date together, use: .PP .RS 5 sortm -textfield subject +folder @@ -114,7 +115,7 @@ folder(1) If a folder is given, it will become the current folder. If the current message is moved, .B sortm - will preserve its status as current. +will preserve its status as current. .SH HISTORY Timezones used to be ignored when comparing dates: they aren't any more. diff --git a/test/folder/test-sortm b/test/folder/test-sortm new file mode 100755 index 0000000..daee94b --- /dev/null +++ b/test/folder/test-sortm @@ -0,0 +1,366 @@ +#!/bin/sh +###################################################### +# +# Test sortm +# +###################################################### + +set -e + +if test -z "${MH_OBJ_DIR}"; then + srcdir=`dirname $0`/../.. + MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR +fi + +. "$MH_OBJ_DIR/test/common.sh" + +setup_test + +expected=$MH_TEST_DIR/$$.expected +actual=$MH_TEST_DIR/$$.actual + +cd $MH_TEST_DIR + +# check -help +cat >$expected <$actual 2>&1 +check $expected $actual + +# check -version +case `sortm -version` in + sortm\ --*) ;; + * ) echo "$0: sortm -v generated unexpected output" 1>&2 + failed=`expr ${failed:-0} + 1`;; +esac + +cat > $MH_TEST_DIR/Mail/inbox/11 < +To: Some User +Date: Fri, 29 Sep 2006 00:00:01 +Alt-Date: Thu, 1 Sep 2005 00:00:00 +Subject: Re: common subject + +This is message number 11 +EOF + +cat > $MH_TEST_DIR/Mail/inbox/12 < +To: Some User +Date: Thu, 28 Sep 2006 23:59:59 +Alt-Date: Sat, 30 Sep 2006 00:00:00 +Subject: common subject + +This is message number 12 +EOF + +# check with no options +cat >$expected <> + 2 09/29 Test1 Testing message 1<> + 3 09/29 Test2 Testing message 2<> + 4 09/29 Test3 Testing message 3<> + 5 09/29 Test4 Testing message 4<> + 6 09/29 Test5 Testing message 5<> + 7 09/29 Test6 Testing message 6<> + 8 09/29 Test7 Testing message 7<> + 9 09/29 Test8 Testing message 8<> + 10 09/29 Test9 Testing message 9<> + 11 09/29 Test10 Testing message 10<> + 12 09/29 Test11 Re: common subject<> +EOF + +sortm +scan > $actual +check $expected $actual + +# check +folder +cat >$expected <> + 2+ 09/29 Test1 Testing message 1<> + 3 09/29 Test2 Testing message 2<> + 4 09/29 Test3 Testing message 3<> + 5 09/29 Test4 Testing message 4<> + 6 09/29 Test5 Testing message 5<> + 7 09/29 Test6 Testing message 6<> + 8 09/29 Test7 Testing message 7<> + 9 09/29 Test8 Testing message 8<> + 10 09/29 Test9 Testing message 9<> + 11 09/29 Test10 Testing message 10<> + 12 09/29 Test11 Re: common subject<> +EOF + +refile first +inbox +folder -pack > /dev/null +sortm +inbox +scan > $actual +check $expected $actual + +# check -verbose +cat >$expected <> + 2+ 09/29 Test1 Testing message 1<> + 3 09/29 Test2 Testing message 2<> + 4 09/29 Test3 Testing message 3<> + 5 09/29 Test4 Testing message 4<> + 6 09/29 Test5 Testing message 5<> + 7 09/29 Test6 Testing message 6<> + 8 09/29 Test7 Testing message 7<> + 9 09/29 Test8 Testing message 8<> + 10 09/29 Test9 Testing message 9<> + 11 09/29 Test10 Testing message 10<> + 12 09/29 Test11 Re: common subject<> +EOF + +refile first +inbox +folder -pack > /dev/null +sortm -verbose >$actual +scan >> $actual +check $expected $actual + +# check -noverbose +cat >$expected <> + 2+ 09/29 Test1 Testing message 1<> + 3 09/29 Test2 Testing message 2<> + 4 09/29 Test3 Testing message 3<> + 5 09/29 Test4 Testing message 4<> + 6 09/29 Test5 Testing message 5<> + 7 09/29 Test6 Testing message 6<> + 8 09/29 Test7 Testing message 7<> + 9 09/29 Test8 Testing message 8<> + 10 09/29 Test9 Testing message 9<> + 11 09/29 Test10 Testing message 10<> + 12 09/29 Test11 Re: common subject<> +EOF + +refile first +inbox +folder -pack > /dev/null +sortm -verbose -noverbose >$actual +scan >> $actual +check $expected $actual + +# check msgs +cat >$expected <> + 2 09/29 Test2 Testing message 2<> + 3 09/29 Test3 Testing message 3<> + 4 09/29 Test4 Testing message 4<> + 5 09/29 Test5 Testing message 5<> + 6 09/29 Test6 Testing message 6<> + 7 09/29 Test7 Testing message 7<> + 8 09/29 Test8 Testing message 8<> + 9 09/29 Test9 Testing message 9<> + 10 09/29 Test10 Testing message 10<> + 11 09/29 Test11 Re: common subject<> + 12+ 09/29 Test1 Testing message 1<> +EOF + +refile first +inbox +folder -pack > /dev/null +sortm first last +scan > $actual +check $expected $actual + +# check -datefield +cat >$expected <> + 2 09/29 Test2 Testing message 2<> + 3 09/29 Test3 Testing message 3<> + 4 09/29 Test4 Testing message 4<> + 5 09/29 Test5 Testing message 5<> + 6 09/29 Test6 Testing message 6<> + 7 09/29 Test7 Testing message 7<> + 8 09/29 Test8 Testing message 8<> + 9 09/29 Test9 Testing message 9<> + 10 09/29 Test10 Testing message 10<> + 11 09/28 Test12 common subject<> + 12+ 09/29 Test1 Testing message 1<> +EOF + +sortm -datefield Alt-Date 1 11 +scan > $actual +check $expected $actual + +# check -textfield subject (datefield major, subjects grouped) +cat >$expected <> + 2 09/29 Test11 Re: common subject<> + 3 09/29 Test2 Testing message 2<> + 4 09/29 Test3 Testing message 3<> + 5 09/29 Test4 Testing message 4<> + 6 09/29 Test5 Testing message 5<> + 7 09/29 Test6 Testing message 6<> + 8 09/29 Test7 Testing message 7<> + 9 09/29 Test8 Testing message 8<> + 10 09/29 Test9 Testing message 9<> + 11 09/29 Test10 Testing message 10<> + 12+ 09/29 Test1 Testing message 1<> +EOF + +sortm -textfield subject +scan > $actual +check $expected $actual + +# check -nolimit +cat >$expected <> + 2 09/29 Test11 Re: common subject<> + 3 09/29 Test2 Testing message 2<> + 4 09/29 Test3 Testing message 3<> + 5 09/29 Test4 Testing message 4<> + 6 09/29 Test5 Testing message 5<> + 7 09/29 Test6 Testing message 6<> + 8 09/29 Test7 Testing message 7<> + 9 09/29 Test8 Testing message 8<> + 10 09/29 Test9 Testing message 9<> + 11 09/29 Test10 Testing message 10<> + 12+ 09/29 Test1 Testing message 1<> +EOF + +sortm -textfield subject -limit 0 -nolimit +scan > $actual +check $expected $actual + +# check -textfield subject -limit 0 (subject sort) +cat >$expected <> + 2 09/28 Test12 common subject<> + 3 09/29 Test1 Testing message 1<> + 4 09/29 Test10 Testing message 10<> + 5 09/29 Test2 Testing message 2<> + 6 09/29 Test3 Testing message 3<> + 7 09/29 Test4 Testing message 4<> + 8 09/29 Test5 Testing message 5<> + 9 09/29 Test6 Testing message 6<> + 10 09/29 Test7 Testing message 7<> + 11 09/29 Test8 Testing message 8<> + 12+ 09/29 Test9 Testing message 9<> +EOF + +refile 2-7 +inbox; refile 1 +inbox; folder -pa last >/dev/null +sortm -textfield subject -limit 0 +scan > $actual +check $expected $actual + +# check -textfield -limit 0 (text sort) +cat >$expected <> + 2 09/29 Test11 Re: common subject<> + 3 09/28 Test12 common subject<> + 4 09/29 Test1 Testing message 1<> + 5 09/29 Test2 Testing message 2<> + 6 09/29 Test3 Testing message 3<> + 7 09/29 Test4 Testing message 4<> + 8 09/29 Test5 Testing message 5<> + 9 09/29 Test6 Testing message 6<> + 10 09/29 Test7 Testing message 7<> + 11 09/29 Test8 Testing message 8<> + 12+ 09/29 Test9 Testing message 9<> +EOF + +refile 2-7 +inbox; refile 1 +inbox; folder -pa last >/dev/null +sortm -textfield from -limit 0 +scan > $actual +check $expected $actual + +# check -textfield with finite -limit that doesn't cover message 13 +cat > $MH_TEST_DIR/Mail/inbox/13 < +To: Some User +Date: Tue, 31 Oct 2006 23:59:59 +Subject: Re: common subject + +This is message number 13 +EOF + +cat >$expected <> + 2 09/29 Test11 Re: common subject<> + 3 09/29 Test5 Testing message 5<> + 4 09/29 Test6 Testing message 6<> + 5 09/29 Test7 Testing message 7<> + 6 09/29 Test8 Testing message 8<> + 7 09/29 Test9 Testing message 9<> + 8 09/29 Test1 Testing message 1<> + 9 09/29 Test2 Testing message 2<> + 10 09/29 Test3 Testing message 3<> + 11 09/29 Test4 Testing message 4<> + 12+ 09/29 Test10 Testing message 10<> + 13 10/31 Test13 Re: common subject<> +EOF + +refile 2-7 +inbox; refile 1 +inbox; folder -pa last >/dev/null +sortm -textfield subject -limit 10 +scan > $actual +check $expected $actual + +# check -textfield with finite -limit that does cover message 13 +cat >$expected <> + 2 09/29 Test11 Re: common subject<> + 3 10/31 Test13 Re: common subject<> + 4 09/29 Test1 Testing message 1<> + 5 09/29 Test2 Testing message 2<> + 6 09/29 Test3 Testing message 3<> + 7 09/29 Test4 Testing message 4<> + 8 09/29 Test10 Testing message 10<> + 9 09/29 Test5 Testing message 5<> + 10 09/29 Test6 Testing message 6<> + 11 09/29 Test7 Testing message 7<> + 12 09/29 Test8 Testing message 8<> + 13+ 09/29 Test9 Testing message 9<> +EOF + +refile 2-7 +inbox; refile 1 +inbox; folder -pa last >/dev/null +sortm -textfield subject -limit 60 +scan > $actual +check $expected $actual + +# check -notextfield +cat >$expected <> + 2 09/29 Test10 Testing message 10<> + 3 09/29 Test5 Testing message 5<> + 4 09/29 Test6 Testing message 6<> + 5 09/29 Test7 Testing message 7<> + 6 09/29 Test8 Testing message 8<> + 7 09/29 Test9 Testing message 9<> + 8 09/29 Test1 Testing message 1<> + 9 09/29 Test2 Testing message 2<> + 10 09/29 Test3 Testing message 3<> + 11 09/29 Test4 Testing message 4<> + 12 09/29 Test11 Re: common subject<> + 13+ 10/31 Test13 Re: common subject<> +EOF + +refile 2-7 +inbox; refile 1 +inbox; folder -pa last >/dev/null +sortm -textfield subject -limit 60 -notextfield +scan > $actual +check $expected $actual + +exit $failed -- 1.7.10.4