]> diplodocus.org Git - nmh/blobdiff - test/post/test-sendfiles
Canonicalize MH_TEST_DIR in TESTS_ENVIRONMENT.
[nmh] / test / post / test-sendfiles
index 750c760838e27ec18d41f45adca217e5899385d6..64bf2696d2e9d44813311bf49844deca767862a2 100755 (executable)
@@ -17,20 +17,14 @@ fi
 setup_test
 
 expected=$MH_TEST_DIR/$$.expected
 setup_test
 
 expected=$MH_TEST_DIR/$$.expected
-expected_err=$MH_TEST_DIR/$$.expected_err
 actual=$MH_TEST_DIR/$$.actual
 actual=$MH_TEST_DIR/$$.actual
-actual_err=$MH_TEST_DIR/$$.actual_err
-localmbox=`$MH_LIB_DIR/ap -format "%(localmbox)" 0`
+localmbox=`$MH_LIBEXEC_DIR/ap -format "%(localmbox)" 0`
 #### Use this script itself for the test file.
 testfiledir="$srcdir/test/post"
 testfile=`basename $0`
 
 #### Use this script itself for the test file.
 testfiledir="$srcdir/test/post"
 testfile=`basename $0`
 
-(cd "$MH_TEST_DIR"  &&
-mkdir -p tmp  &&
-cat >"$expected_err" <<EOF
-$testfile
-EOF
-)
+(cd "$MH_TEST_DIR"  &&  mkdir -p tmp)
+
 #### Copy fakesendmail and the testfile because we cd to the
 #### test directory, because tar doesn't like absolute paths.
 cp "$srcdir/test/fakesendmail" "$testfiledir/$testfile" "$MH_TEST_DIR"
 #### Copy fakesendmail and the testfile because we cd to the
 #### test directory, because tar doesn't like absolute paths.
 cp "$srcdir/test/fakesendmail" "$testfiledir/$testfile" "$MH_TEST_DIR"
@@ -53,22 +47,21 @@ test_sendfiles ()
 
   if [ "$argstyle" = 'new' ]; then
     (cd "$MH_TEST_DIR"  &&
 
   if [ "$argstyle" = 'new' ]; then
     (cd "$MH_TEST_DIR"  &&
-     sendfiles "$@" -to recipient@example.com -subject "sendfiles test" \
-       "$testfile" >/dev/null 2>"$actual_err")
+     run_prog sendfiles "$@" -to recipient@example.com \
+       -subject "sendfiles test" "$testfile" >/dev/null 2>&1)
   elif [ "$argstyle" = 'old' ]; then
     (cd "$MH_TEST_DIR"  &&
   elif [ "$argstyle" = 'old' ]; then
     (cd "$MH_TEST_DIR"  &&
-     sendfiles "$@" recipient@example.com "sendfiles test" \
-       "$testfile" >/dev/null 2>"$actual_err")
+     run_prog sendfiles "$@" recipient@example.com "sendfiles test" \
+       "$testfile" >/dev/null 2>&1)
   fi
 
   fi
 
-  check "$expected_err" "$actual_err" 'keep first'
-
   # fakesendmail drops the message and any cc's into this mbox.
   mbox="$MH_TEST_DIR"/Mail/fakesendmail.mbox
   inc -silent -file "$mbox"
   rm -f "$mbox" "$mbox.map"
 
   # fakesendmail drops the message and any cc's into this mbox.
   mbox="$MH_TEST_DIR"/Mail/fakesendmail.mbox
   inc -silent -file "$mbox"
   rm -f "$mbox" "$mbox.map"
 
-  mhlist -verbose last | sed -e 's/ *$//' >"$actual"
+  mhlist -verbose last | sed -e 's/ *$//' -e 's/\(octet-stream\).*$/\1/' \
+    >"$actual"
   (cd $MH_TEST_DIR/tmp  &&
    contents=`mhstore -noauto last 2>&1 | \
              sed -e 's/storing message.*as file //'`  &&
   (cd $MH_TEST_DIR/tmp  &&
    contents=`mhstore -noauto last 2>&1 | \
              sed -e 's/storing message.*as file //'`  &&
@@ -88,7 +81,7 @@ Usage: sendfiles [switches] -to recipient -subject subject file1 [file2 ...]
   or
        sendfiles [switches] recipient subject file1 [file2 ...]
   switches are:
   or
        sendfiles [switches] recipient subject file1 [file2 ...]
   switches are:
-  -compress [bzip2 | compress | gzip | lzma | none | zip]
+  -compress [bzip2 | compress | gzip | lzma | none]
   -from <sender>
   -[delay] <delay> (expressed in seconds)
   -version
   -from <sender>
   -[delay] <delay> (expressed in seconds)
   -version
@@ -96,7 +89,7 @@ Usage: sendfiles [switches] -to recipient -subject subject file1 [file2 ...]
   Can use PERSON environment variable instead of -from switch.
 EOF
 
   Can use PERSON environment variable instead of -from switch.
 EOF
 
-sendfiles -help >"$actual" 2>&1
+run_prog sendfiles -help >"$actual" 2>&1
 check "$expected" "$actual"
 
 # check -version
 check "$expected" "$actual"
 
 # check -version
@@ -112,7 +105,7 @@ run_test 'sendfiles -nonexistent' "Usage: sendfiles [switches] -to recipient \
   or
        sendfiles [switches] recipient subject file1 [file2 ...]
   switches are:
   or
        sendfiles [switches] recipient subject file1 [file2 ...]
   switches are:
-  -compress [bzip2 | compress | gzip | lzma | none | zip]
+  -compress [bzip2 | compress | gzip | lzma | none]
   -from <sender>
   -[delay] <delay> (expressed in seconds)
   -version
   -from <sender>
   -[delay] <delay> (expressed in seconds)
   -version
@@ -127,7 +120,7 @@ Usage: sendfiles [switches] -to recipient \
   or
        sendfiles [switches] recipient subject file1 [file2 ...]
   switches are:
   or
        sendfiles [switches] recipient subject file1 [file2 ...]
   switches are:
-  -compress [bzip2 | compress | gzip | lzma | none | zip]
+  -compress [bzip2 | compress | gzip | lzma | none]
   -from <sender>
   -[delay] <delay> (expressed in seconds)
   -version
   -from <sender>
   -[delay] <delay> (expressed in seconds)
   -version
@@ -139,16 +132,16 @@ Usage: sendfiles [switches] -to recipient \
 # because it will vary with compression method and compressed file
 # size.
 [ "`findprog bzip2`" ]     &&  test_sendfiles 'bzip2 -cd' new -compress bzip2
 # because it will vary with compression method and compressed file
 # size.
 [ "`findprog bzip2`" ]     &&  test_sendfiles 'bzip2 -cd' new -compress bzip2
-[ "`findprog compress`" ]  &&  test_sendfiles uncompress new -compress compress
+[ "`findprog compress`" ]  &&  test_sendfiles 'uncompress -c' new \
+                                              -compress compress
 [ "`findprog gzip`" ]      &&  test_sendfiles 'gzip -cd' new -compress gzip
 [ "`findprog gzip`" ]      &&  test_sendfiles 'gzip -cd' new -gzip
 [ "`findprog lzma`" ]      &&  test_sendfiles 'lzma -cd' new -compress lzma
 [ "`findprog gzip`" ]      &&  test_sendfiles 'gzip -cd' new -compress gzip
 [ "`findprog gzip`" ]      &&  test_sendfiles 'gzip -cd' new -gzip
 [ "`findprog lzma`" ]      &&  test_sendfiles 'lzma -cd' new -compress lzma
-[ "`findprog zip`" ]       &&  test_sendfiles 'unzip -p' new -compress zip
 
 # check with no compression
 cat >"$expected" <<EOF
  msg part  type/subtype              size description
 
 # check with no compression
 cat >"$expected" <<EOF
  msg part  type/subtype              size description
-  11       application/octet-stream   10K
+  11       application/octet-stream
             type="tar"
             (extract with cat | tar xvpf -)
 EOF
             type="tar"
             (extract with cat | tar xvpf -)
 EOF
@@ -158,7 +151,7 @@ test_sendfiles cat new -compress none
 # check with no compression, -none
 cat >"$expected" <<EOF
  msg part  type/subtype              size description
 # check with no compression, -none
 cat >"$expected" <<EOF
  msg part  type/subtype              size description
-  11       application/octet-stream   10K
+  11       application/octet-stream
             type="tar"
             (extract with cat | tar xvpf -)
 EOF
             type="tar"
             (extract with cat | tar xvpf -)
 EOF
@@ -168,7 +161,7 @@ test_sendfiles cat new -none
 # check old argument style (without -to and -subject)
 cat >"$expected" <<EOF
  msg part  type/subtype              size description
 # check old argument style (without -to and -subject)
 cat >"$expected" <<EOF
  msg part  type/subtype              size description
-  11       application/octet-stream   10K
+  11       application/octet-stream
             type="tar"
             (extract with cat | tar xvpf -)
 EOF
             type="tar"
             (extract with cat | tar xvpf -)
 EOF
@@ -178,7 +171,7 @@ test_sendfiles cat old -compress none
 # check -from
 cat >"$expected" <<EOF
  msg part  type/subtype              size description
 # check -from
 cat >"$expected" <<EOF
  msg part  type/subtype              size description
-  11       application/octet-stream   10K
+  11       application/octet-stream
             type="tar"
             (extract with cat | tar xvpf -)
 EOF
             type="tar"
             (extract with cat | tar xvpf -)
 EOF
@@ -188,7 +181,7 @@ test_sendfiles cat new -compress none -from 'Sender <sender@example.com>'
 # check PERSON environment variable
 cat >"$expected" <<EOF
  msg part  type/subtype              size description
 # check PERSON environment variable
 cat >"$expected" <<EOF
  msg part  type/subtype              size description
-  11       application/octet-stream   10K
+  11       application/octet-stream
             type="tar"
             (extract with cat | tar xvpf -)
 EOF
             type="tar"
             (extract with cat | tar xvpf -)
 EOF
@@ -198,7 +191,7 @@ PERSON='Sender <sender@example.com>' test_sendfiles cat new -compress none
 # check -delay, though for a small file it doesn't do anything
 cat >"$expected" <<EOF
  msg part  type/subtype              size description
 # check -delay, though for a small file it doesn't do anything
 cat >"$expected" <<EOF
  msg part  type/subtype              size description
-  11       application/octet-stream   10K
+  11       application/octet-stream
             type="tar"
             (extract with cat | tar xvpf -)
 EOF
             type="tar"
             (extract with cat | tar xvpf -)
 EOF
@@ -208,15 +201,14 @@ test_sendfiles cat new -compress none -delay 5
 # check old style -delay, though for a small file it doesn't do anything
 cat >"$expected" <<EOF
  msg part  type/subtype              size description
 # check old style -delay, though for a small file it doesn't do anything
 cat >"$expected" <<EOF
  msg part  type/subtype              size description
-  11       application/octet-stream   10K
+  11       application/octet-stream
             type="tar"
             (extract with cat | tar xvpf -)
 EOF
 
 test_sendfiles cat new -compress none -5
 
             type="tar"
             (extract with cat | tar xvpf -)
 EOF
 
 test_sendfiles cat new -compress none -5
 
-rm -fr "$MH_TEST_DIR/fakesendmail" "$MH_TEST_DIR/$testfile" \
-       "$expected_err" "$MH_TEST_DIR/tmp"
+rm -fr "$MH_TEST_DIR/fakesendmail" "$MH_TEST_DIR/$testfile" "$MH_TEST_DIR/tmp"
 
 
 exit ${failed:-0}
 
 
 exit ${failed:-0}