For the mhstore -clobber test, cd to the Mail subdirectory so that
[mmh] / test / mhstore / test-mhstore
index 52b92f7..3dde1ca 100755 (executable)
@@ -66,7 +66,7 @@ EOF
 check $expected 6.txt
 
 # Write message with a text/plain subpart.
-msgfile=$(mhpath new)
+msgfile=`mhpath new`
 cat > $msgfile <<EOF
 To: recipient@example.com
 From: sender@example.com
@@ -80,7 +80,7 @@ Content-Type: multipart/related;
     boundary="subpart__1.1"
 
 --subpart__1.1
-Content-Type: text/plain; charset="us-ascii"
+Content-Type: text/plain; charset="iso-8859-1"
 Content-Disposition: attachment; filename="test1.txt"
 
 This is the first text/plain part, in a subpart.
@@ -88,7 +88,7 @@ This is the first text/plain part, in a subpart.
 --subpart__1.1--
 
 ------- =_aaaaaaaaaa0
-Content-Type: text/plain; charset="us-ascii"
+Content-Type: text/plain; charset="iso-8859-1"
 Content-Disposition: attachment; filename="test2.txt"
 Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
 Content-Transfer-Encoding: quoted-printable
@@ -96,13 +96,13 @@ Content-Transfer-Encoding: quoted-printable
 This is the second text/plain part.
 
 ------- =_aaaaaaaaaa0
-Content-Type: text/plain; charset="us-ascii"
+Content-Type: text/plain; charset="iso-8859-1"
 Content-Disposition: attachment; filename="test3.txt"
 
 This is the third text/plain part.
 
 ------- =_aaaaaaaaaa0
-Content-Type: text/plain; charset="us-ascii"; name="test4.txt"
+Content-Type: text/plain; charset="iso-8859-1"; name="test4.txt"
 Content-Disposition: attachment; filename="test4.txt"
 Content-Transfer-Encoding: base64
 
@@ -192,7 +192,7 @@ run_test 'mhstore last -part 2 -check -nocheck' \
 check $expected 11.2.txt
 
 # check reassembly of message/partial messages (RFC 1521, 7.3.2)
-msgfile=$(mhpath new)
+msgfile=`mhpath new`
 cat > $msgfile <<EOF
 To: recipient@example.com
 From: sender@example.com
@@ -200,12 +200,12 @@ Subject: mhlist test
 MIME-Version: 1.0
 Content-Type: message/partial; id="test-mhstore message/partial test"; number=1
 
-Content-Type: text/plain; charset="us-ascii"
+Content-Type: text/plain; charset="iso-8859-1"
 
 This is part one of three.
 EOF
 
-msgfile=$(mhpath new)
+msgfile=`mhpath new`
 cat > $msgfile <<EOF
 To: recipient@example.com
 From: sender@example.com
@@ -216,7 +216,7 @@ Content-Type: message/partial; id="test-mhstore message/partial test"; number=2
 This is part two of three.
 EOF
 
-msgfile=$(mhpath new)
+msgfile=`mhpath new`
 cat > $msgfile <<EOF
 To: recipient@example.com
 From: sender@example.com
@@ -239,5 +239,80 @@ EOF
 run_test 'mhstore last' 'storing message 15 as file 15.txt'
 check $expected 15.txt
 
+# cd into Mail directory because it gets cleaned up by the exit trap.
+cd Mail
+
+# check -clobber always
+folder +inbox 7 > /dev/null
+touch 7.txt
+cat > $expected <<EOF
+This is message number 7
+EOF
+run_test 'mhstore' 'storing message 7 as file 7.txt'
+check $expected 7.txt 'keep first'
+run_test 'mhstore -clobber ask -clobber always' \
+         'storing message 7 as file 7.txt'
+check $expected 7.txt 'keep first'
+
+# check -clobber auto
+touch 7.txt
+run_test 'mhstore -clobber auto' 'storing message 7 as file 7-1.txt'
+check $expected 7-1.txt 'keep first'
+touch 7-1.txt
+run_test 'mhstore -clobber auto' 'storing message 7 as file 7-2.txt'
+check $expected 7-2.txt 'keep first'
+
+# check -clobber suffix
+run_test 'mhstore -clobber suffix' 'storing message 7 as file 7.txt.1'
+check $expected 7.txt.1 'keep first'
+touch 7.txt.1
+run_test 'mhstore -clobber suffix' 'storing message 7 as file 7.txt.2'
+check $expected 7.txt.2 'keep first'
+
+# Don't check -clobber ask because it requires connection to a
+# terminal, and this test won't always be run with one.
+
+# check -clobber never.  Its exit status is the number of files not overwritten.
+run_test 'mhstore -clobber never' \
+         "mhstore: will not overwrite `pwd`/7.txt with -clobber never"
+set +e
+mhstore -clobber never >/dev/null 2>&1
+run_test "echo $?" 1
+set -e
+
+cd ..
+
+# check with relative nmh-storage profile component
+storagedir=storagedir
+dir="$MH_TEST_DIR/Mail/inbox/$storagedir"
+mkdir "$dir"
+echo "nmh-storage: $storagedir" >> $MH
+cat > $expected <<EOF
+This is the fourth text/plain part.
+EOF
+run_test 'mhstore 11 -part 4' \
+"storing message 11 part 4 as file $storagedir/11.4.txt"
+check $expected "$dir/11.4.txt" 'keep first'
+
+# check with relative nmh-storage profile component and -auto
+run_test 'mhstore 11 -part 4 -auto' \
+"storing message 11 part 4 as file $storagedir/test4.txt"
+check $expected "$dir/test4.txt" 'keep first'
+
+# check with absolute nmh-storage profile component
+absstoragedir="$MH_TEST_DIR/$storagedir"
+mkdir "$absstoragedir"
+sed "s%\(nmh-storage: \)storagedir%\1$absstoragedir%" $MH > $MH.new
+mv -f $MH.new $MH
+run_test 'mhstore 11 -part 4' \
+"storing message 11 part 4 as file $storagedir/11.4.txt"
+check $expected "$absstoragedir/11.4.txt" 'keep first'
+
+# check with absolute nmh-storage profile component and -auto
+run_test 'mhstore 11 -part 4 -auto' \
+"storing message 11 part 4 as file $storagedir/test4.txt"
+check $expected "$absstoragedir/test4.txt"
+rmdir "$absstoragedir"
+
 
 exit $failed