]> diplodocus.org Git - nmh/commitdiff
Fixed a couple of tests to not fail when there is no text browser.
authorDavid Levine <levinedl@acm.org>
Sat, 7 Jan 2017 22:38:27 +0000 (17:38 -0500)
committerDavid Levine <levinedl@acm.org>
Sat, 7 Jan 2017 22:38:27 +0000 (17:38 -0500)
test/mhfixmsg/test-mhfixmsg
test/mhshow/test-subpart

index ec384f6da18b7f7d98ad1ecaa4c8704045dc6d31..7fc95d3f1460062acdd15676b5f1ceacfbba467e 100755 (executable)
@@ -28,8 +28,7 @@ actual_err="$MH_TEST_DIR/test-mhfixmsg$$.actual_err"
 
 mhn_defaults="$MH_INST_DIR${nmhetcdir}/mhn.defaults"
 
 
 mhn_defaults="$MH_INST_DIR${nmhetcdir}/mhn.defaults"
 
-if grep mhfixmsg-format-text/html "${mhn_defaults}" \
-  >/dev/null; then
+if grep mhfixmsg-format-text/html "${mhn_defaults}" >/dev/null; then
   can_reformat_texthtml=1
   if grep 'mhfixmsg-format-text/html.*w3m' "${mhn_defaults}" \
     >/dev/null; then
   can_reformat_texthtml=1
   if grep 'mhfixmsg-format-text/html.*w3m' "${mhn_defaults}" \
     >/dev/null; then
@@ -1349,27 +1348,29 @@ run_test 'mhfixmsg last -outfile '"$actual" ''
 check "$expected" "$actual"
 
 
 check "$expected" "$actual"
 
 
-# check rmmproc
-start_test "rmmproc"
-cat >"$MH_TEST_DIR/Mail/rmmproc" <<'EOF'
+if [ $can_reformat_texthtml -eq 1 ]; then
+  # check rmmproc
+  start_test "rmmproc"
+  cat >"$MH_TEST_DIR/Mail/rmmproc" <<'EOF'
 mv "$1" "$1.backup"
 EOF
 mv "$1" "$1.backup"
 EOF
-chmod a+x "${MH_TEST_DIR}/Mail/rmmproc"
-echo "rmmproc: ${MH_TEST_DIR}/Mail/rmmproc" >>"$MH"
-cp "${MH_TEST_DIR}/Mail/inbox/16" "${MH_TEST_DIR}/Mail/inbox/16.original"
+  chmod a+x "${MH_TEST_DIR}/Mail/rmmproc"
+  echo "rmmproc: ${MH_TEST_DIR}/Mail/rmmproc" >>"$MH"
+  cp "${MH_TEST_DIR}/Mail/inbox/16" "${MH_TEST_DIR}/Mail/inbox/16.original"
 
 
-run_test 'mhfixmsg 16' ''
-check "${MH_TEST_DIR}/Mail/inbox/16.backup" \
-      "${MH_TEST_DIR}/Mail/inbox/16.original"
+  run_test 'mhfixmsg 16' ''
+  check "${MH_TEST_DIR}/Mail/inbox/16.backup" \
+        "${MH_TEST_DIR}/Mail/inbox/16.original"
 
 
 
 
-# check -normmproc
-start_test "-normmproc"
-cp "${MH_TEST_DIR}/Mail/inbox/21" "${MH_TEST_DIR}/Mail/inbox/22"
+  # check -normmproc
+  start_test "-normmproc"
+  cp "${MH_TEST_DIR}/Mail/inbox/21" "${MH_TEST_DIR}/Mail/inbox/22"
 
 
-run_test 'mhfixmsg 21 -normmproc'
-check "${MH_TEST_DIR}/Mail/inbox/22" \
-      "${MH_TEST_DIR}/Mail/inbox/,21" 'keep first'
+  run_test 'mhfixmsg 21 -normmproc'
+  check "${MH_TEST_DIR}/Mail/inbox/22" \
+        "${MH_TEST_DIR}/Mail/inbox/,21" 'keep first'
+fi
 
 
 # check -rmmproc
 
 
 # check -rmmproc
index 27fb907762e81d82844681ff4f2c34a8f6d2a7a4..2a799772cd840f4c994a61d273acb874fd340277 100755 (executable)
@@ -20,6 +20,24 @@ setup_test
 expected=$MH_TEST_DIR/$$.expected
 actual=$MH_TEST_DIR/$$.actual
 
 expected=$MH_TEST_DIR/$$.expected
 actual=$MH_TEST_DIR/$$.actual
 
+mhn_defaults="$MH_INST_DIR${nmhetcdir}/mhn.defaults"
+
+if grep mhfixmsg-format-text/html "${mhn_defaults}" >/dev/null; then
+  can_reformat_texthtml=1
+  if grep 'mhfixmsg-format-text/html.*w3m' "${mhn_defaults}" \
+    >/dev/null; then
+    #### w3m uses $HOME/.w3m/, and creates it if it doesn't exist.  To
+    #### support testing with non-writeable $HOME, and to not leave
+    #### relics from this test if it is writeable but doesn't already
+    #### have a .w3m, and to not depend on whatever is in that if it
+    #### does already exist, overwrite $HOME if using w3m.
+    HOME="$MHTMPDIR"; export HOME
+  fi
+else
+  echo "$0: skipping html checks because no text browser was found"
+  can_reformat_texthtml=0
+fi
+
 # Write message with a text/plain subpart.
 msgfile=`mhpath new`
 msgnum=`basename $msgfile`
 # Write message with a text/plain subpart.
 msgfile=`mhpath new`
 msgnum=`basename $msgfile`
@@ -57,6 +75,7 @@ This is the text/plain part.
 EOF
 
 # check it
 EOF
 
 # check it
+start_test 'text/plain part'
 run_prog mhshow -part 1.1 -form mhl.null $msgnum > $actual 2>&1
 check "$expected" "$actual" : part 1.1
 
 run_prog mhshow -part 1.1 -form mhl.null $msgnum > $actual 2>&1
 check "$expected" "$actual" : part 1.1
 
@@ -108,17 +127,20 @@ This is the final text/plain signature part.
 EOF
 
 # Write the expected output.
 EOF
 
 # Write the expected output.
-cat > $expected <<EOF
+if [ $can_reformat_texthtml -eq 1 ]; then
+  cat > $expected <<EOF
 [ Message inbox:11 ]
 [ part 1.1.1 - text/html -   111B  ]
 This is the text/html body part.
 EOF
 
 [ Message inbox:11 ]
 [ part 1.1.1 - text/html -   111B  ]
 This is the text/html body part.
 EOF
 
-# check it
-# The sed command removes blank lines and leading space that lynx inserts.
-run_prog mhshow -part 1.1.1 -form mhl.null $msgnum |
-    sed '/^$/D; s/^ *//;' > $actual 2>&1
-check "$expected" "$actual" : part 1.1.1
+  # check it
+  start_test 'text/html part'
+  # The sed command removes blank lines and leading space that lynx inserts.
+  run_prog mhshow -part 1.1.1 -form mhl.null $msgnum |
+      sed '/^$/D; s/^ *//;' > $actual 2>&1
+  check "$expected" "$actual" : part 1.1.1
+fi
 
 # Write the expected output.
 cat > $expected <<EOF
 
 # Write the expected output.
 cat > $expected <<EOF
@@ -128,6 +150,7 @@ This is the body text/plain part.
 EOF
 
 # check it
 EOF
 
 # check it
+start_test 'text/plain alternative part'
 run_prog mhshow -part 1.2 -form mhl.null $msgnum > $actual 2>&1
 check "$expected" "$actual" : part 1.2
 
 run_prog mhshow -part 1.2 -form mhl.null $msgnum > $actual 2>&1
 check "$expected" "$actual" : part 1.2
 
@@ -139,6 +162,7 @@ This is the body text/plain part.
 EOF
 
 # check it
 EOF
 
 # check it
+start_test 'conflicting text/plain, part 1 switches'
 run_prog mhshow -prefer text/plain -part 1 -form mhl.null $msgnum > $actual 2>&1
 check "$expected" "$actual" : part conflicting text/plain, part 1 switches
 
 run_prog mhshow -prefer text/plain -part 1 -form mhl.null $msgnum > $actual 2>&1
 check "$expected" "$actual" : part conflicting text/plain, part 1 switches
 
@@ -151,6 +175,7 @@ This is the final text/plain signature part.
 EOF
 
 # check it
 EOF
 
 # check it
+start_test 'final text/plain part'
 run_prog mhshow -part 2 -form mhl.null $msgnum > $actual 2>&1
 check "$expected" "$actual" : part 2
 
 run_prog mhshow -part 2 -form mhl.null $msgnum > $actual 2>&1
 check "$expected" "$actual" : part 2
 
@@ -165,6 +190,7 @@ This is the final text/plain signature part.
 EOF
 
 # check it
 EOF
 
 # check it
+start_test 'all text/plain parts'
 run_prog mhshow -type text/plain -form mhl.null $msgnum > $actual 2>&1
 check "$expected" "$actual" : type text/plain
 
 run_prog mhshow -type text/plain -form mhl.null $msgnum > $actual 2>&1
 check "$expected" "$actual" : type text/plain
 
@@ -178,7 +204,10 @@ _______________________________________________
 This is the final text/plain signature part.
 EOF
 
 This is the final text/plain signature part.
 EOF
 
+start_test 'prefer text/plain'
 run_prog mhshow -prefer text/plain -form mhl.null $msgnum > $actual 2>&1
 check "$expected" "$actual" : prefer text/plain
 
 run_prog mhshow -prefer text/plain -form mhl.null $msgnum > $actual 2>&1
 check "$expected" "$actual" : prefer text/plain
 
+
+finish_test
 exit $failed
 exit $failed