From a4390a1c51b3a709d6aeefeba2fdd6fa8d525012 Mon Sep 17 00:00:00 2001 From: David Levine Date: Sun, 7 Oct 2012 10:18:54 -0500 Subject: [PATCH] Updates to test/common.sh.in: 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 | 2 +- test/common.sh.in | 30 ++++++++++++++++++++++++------ test/mhbuild/test-utf8-body | 2 +- test/post/test-mts | 2 +- test/rcv/test-rcvdist | 2 +- test/refile/test-refile | 8 ++------ 6 files changed, 30 insertions(+), 16 deletions(-) diff --git a/man/anno.man b/man/anno.man index f97efa5..541329a 100644 --- a/man/anno.man +++ b/man/anno.man @@ -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, -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 diff --git a/test/common.sh.in b/test/common.sh.in index be97b1a..bd33d25 100644 --- a/test/common.sh.in +++ b/test/common.sh.in @@ -54,20 +54,19 @@ test_skip () # portable implementation of 'which' utility findprog() { - FOUND= 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 - 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 - IFS="$IFS_SAVE" } require_prog () @@ -96,6 +95,20 @@ progress_done () 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 @@ -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. - 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 diff --git a/test/mhbuild/test-utf8-body b/test/mhbuild/test-utf8-body index 1d7ffa1..2998da4 100755 --- a/test/mhbuild/test-utf8-body +++ b/test/mhbuild/test-utf8-body @@ -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" -printf "%s\n" "sendmail: ${srcdir}/test/fakesendmail" >>"$mts_fakesendmail" +printf "sendmail: ${srcdir}/test/fakesendmail\n" >>"$mts_fakesendmail" MHMTSCONF="$mts_fakesendmail" # argument: expected output diff --git a/test/post/test-mts b/test/post/test-mts index 18250b1..88f68c5 100755 --- a/test/post/test-mts +++ b/test/post/test-mts @@ -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" -printf "%s\n" "sendmail: ${srcdir}/test/fakesendmail" >>"$mts_fakesendmail" +printf "sendmail: ${srcdir}/test/fakesendmail\n" >>"$mts_fakesendmail" MHMTSCONF="$mts_fakesendmail" # $1: -mts switch selection diff --git a/test/rcv/test-rcvdist b/test/rcv/test-rcvdist index 33b566d..e49b390 100755 --- a/test/rcv/test-rcvdist +++ b/test/rcv/test-rcvdist @@ -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" -printf "%s\n" "sendmail: ${srcdir}/test/fakesendmail" >>"$mts_fakesendmail" +printf "sendmail: ${srcdir}/test/fakesendmail\n" >>"$mts_fakesendmail" MHMTSCONF="$mts_fakesendmail" # arguments: rcvdist switches diff --git a/test/refile/test-refile b/test/refile/test-refile index 0d9303c..62f086d 100755 --- a/test/refile/test-refile +++ b/test/refile/test-refile @@ -115,10 +115,8 @@ other+ has 1 message (1- 1). 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' \ @@ -136,8 +134,6 @@ else 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' '' -- 1.7.10.4