Updates to test/common.sh.in:
authorDavid Levine <levinedl@acm.org>
Sun, 7 Oct 2012 15:18:54 +0000 (10:18 -0500)
committerDavid Levine <levinedl@acm.org>
Sun, 7 Oct 2012 15:18:54 +0000 (10:18 -0500)
1) Added function check_for_hard_links.  Moved this code out of
   test-refile so that other tests can use it.
2) Added mmdfldir and mmdflfil settings to the mts.conf for tests, to
   support test-msgchk.

man/anno.man
test/common.sh.in
test/mhbuild/test-utf8-body
test/post/test-mts
test/rcv/test-rcvdist
test/refile/test-refile

index f97efa5..541329a 100644 (file)
@@ -85,7 +85,7 @@ is invoked,
 will prompt the user for the name of field for the annotation.
 .PP
 The field specified must be a valid 2822-style message field name,
 will prompt the user for the name of field for the annotation.
 .PP
 The field specified must be a valid 2822-style message field name,
-which means that it may only consist of alphanumerics and dashes,
+which means that it may only consist of alphanumerics and dashes.
 The body specified is arbitrary text.
 .PP
 Normally
 The body specified is arbitrary text.
 .PP
 Normally
index be97b1a..bd33d25 100644 (file)
@@ -54,20 +54,19 @@ test_skip ()
 # portable implementation of 'which' utility
 findprog()
 {
 # portable implementation of 'which' utility
 findprog()
 {
-  FOUND=
   PROG="$1"
   PROG="$1"
-  IFS_SAVE="$IFS"
+  #### Don't need to save current IFS because this function is run in
+  #### a subshell.
   IFS=:
   for D in $PATH; do
     if [ -z "$D" ]; then
       D=.
     fi
   IFS=:
   for D in $PATH; do
     if [ -z "$D" ]; then
       D=.
     fi
-    if [ -f "$D/$PROG" ] && [ -x "$D/$PROG" ]; then
-      printf '%s\n' "$D/$PROG"
+    if [ -f "$D/$PROG"  -a  -x "$D/$PROG" ]; then
+      printf "$D/$PROG"
       break
     fi
   done
       break
     fi
   done
-  IFS="$IFS_SAVE"
 }
 
 require_prog ()
 }
 
 require_prog ()
@@ -96,6 +95,20 @@ progress_done ()
   printf "100%%\n"
 }
 
   printf "100%%\n"
 }
 
+check_for_hard_links () {
+  set +e
+
+  printf '' > "${MH_TEST_DIR}/$$-1"
+  if link "${MH_TEST_DIR}/$$-1" "${MH_TEST_DIR}/$$-2" 2>/dev/null; then
+    hard_links_supported=1
+  else
+    hard_links_supported=0
+  fi
+  rm -f "${MH_TEST_DIR}/$$-1" "${MH_TEST_DIR}/$$-2"
+
+  set -e
+}
+
 #### check() requires two arguments, each the name of a file to be
 #### diff'ed.
 #### If the same, the second file is removed.  And the first file is
 #### check() requires two arguments, each the name of a file to be
 #### diff'ed.
 #### If the same, the second file is removed.  And the first file is
@@ -152,7 +165,12 @@ setup_test ()
     #### Don't test with sendmail because it would really send the
     #### mail.  If configured to use sendmail, change to smtp instead
     #### so that we use fakesmtp.
     #### Don't test with sendmail because it would really send the
     #### mail.  If configured to use sendmail, change to smtp instead
     #### so that we use fakesmtp.
-    sed -e 's/mts: *.*/mts: smtp/' "${MHMTSCONF}" >"${MHMTSCONF}.new"
+    #### And set up the maildrop in the test directory so tests don't
+    #### use the user's real maildrop.
+    sed -e 's/mts: *.*/mts: smtp/' \
+        -e "s%mmdfldir: *.*%mmdfldir: ${MH_TEST_DIR}/Mail%" \
+        -e 's%mmdflfil: *.*%mmdflfil: maildrop%' \
+        "${MHMTSCONF}" >"${MHMTSCONF}.new"
     mv -f "${MHMTSCONF}.new" "${MHMTSCONF}"
   fi
 
     mv -f "${MHMTSCONF}.new" "${MHMTSCONF}"
   fi
 
index 1d7ffa1..2998da4 100755 (executable)
@@ -21,7 +21,7 @@ testname="${MH_TEST_DIR}/$$"
 #### Rely on sendmail/pipe below to override default mts.
 mts_fakesendmail="${MHMTSCONF}-fakesendmail"
 cp "${MHMTSCONF}" "$mts_fakesendmail"
 #### Rely on sendmail/pipe below to override default mts.
 mts_fakesendmail="${MHMTSCONF}-fakesendmail"
 cp "${MHMTSCONF}" "$mts_fakesendmail"
-printf "%s\n" "sendmail: ${srcdir}/test/fakesendmail" >>"$mts_fakesendmail"
+printf "sendmail: ${srcdir}/test/fakesendmail\n" >>"$mts_fakesendmail"
 MHMTSCONF="$mts_fakesendmail"
 
 # argument: expected output
 MHMTSCONF="$mts_fakesendmail"
 
 # argument: expected output
index 18250b1..88f68c5 100755 (executable)
@@ -47,7 +47,7 @@ test_post "${testname}.actual" "${testname}.expected" "-mts smtp"
 #### Rely on sendmail/smtp or sendmail/pipe below to override default mts.
 mts_fakesendmail="${MHMTSCONF}-fakesendmail"
 cp "${MHMTSCONF}" "$mts_fakesendmail"
 #### Rely on sendmail/smtp or sendmail/pipe below to override default mts.
 mts_fakesendmail="${MHMTSCONF}-fakesendmail"
 cp "${MHMTSCONF}" "$mts_fakesendmail"
-printf "%s\n" "sendmail: ${srcdir}/test/fakesendmail" >>"$mts_fakesendmail"
+printf "sendmail: ${srcdir}/test/fakesendmail\n" >>"$mts_fakesendmail"
 MHMTSCONF="$mts_fakesendmail"
 
 # $1: -mts switch selection
 MHMTSCONF="$mts_fakesendmail"
 
 # $1: -mts switch selection
index 33b566d..e49b390 100755 (executable)
@@ -53,7 +53,7 @@ run_test "$rcvdist" \
 #### Use sendmail/pipe below to override default mts.
 mts_fakesendmail="${MHMTSCONF}-fakesendmail"
 sed -e 's/^mts:.*/mts: sendmail\/pipe/' "${MHMTSCONF}" > "$mts_fakesendmail"
 #### Use sendmail/pipe below to override default mts.
 mts_fakesendmail="${MHMTSCONF}-fakesendmail"
 sed -e 's/^mts:.*/mts: sendmail\/pipe/' "${MHMTSCONF}" > "$mts_fakesendmail"
-printf "%s\n" "sendmail: ${srcdir}/test/fakesendmail" >>"$mts_fakesendmail"
+printf "sendmail: ${srcdir}/test/fakesendmail\n" >>"$mts_fakesendmail"
 MHMTSCONF="$mts_fakesendmail"
 
 # arguments: rcvdist switches
 MHMTSCONF="$mts_fakesendmail"
 
 # arguments: rcvdist switches
index 0d9303c..62f086d 100755 (executable)
@@ -115,10 +115,8 @@ other+ has  1 message   (1- 1).
 
 TOTAL = 11 messages in 2 folders.'
 
 
 TOTAL = 11 messages in 2 folders.'
 
-printf '' > $$.txt
-set +e
-if link $$.txt $$-2.txt 2>/dev/null; then
-  # Hard links are supported.
+check_for_hard_links
+if [ $hard_links_supported -eq 1 ]; then
   # check -link
   run_test 'refile 7 -src +inbox +other -link' ''
   run_test 'folders -noheader' \
   # check -link
   run_test 'refile 7 -src +inbox +other -link' ''
   run_test 'folders -noheader' \
@@ -136,8 +134,6 @@ else
   cp -p Mail/inbox/7 Mail/other/2
   folder -f +inbox 7 >/dev/null
 fi
   cp -p Mail/inbox/7 Mail/other/2
   folder -f +inbox 7 >/dev/null
 fi
-set -e
-rm -f $$.txt $$-2.txt
 
 # check -nolink
 run_test 'refile 7 +other -link -nolink' ''
 
 # check -nolink
 run_test 'refile 7 +other -link -nolink' ''