#!/bin/sh ###################################################### # # Test mhlist # ###################################################### set -e if test -z "${MH_OBJ_DIR}"; then srcdir=`dirname $0`/../.. MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR fi . "$MH_OBJ_DIR/test/common.sh" setup_test check_exit '-eq 1' mhlist - expected=$MH_TEST_DIR/$$.expected actual=$MH_TEST_DIR/$$.actual start_test 'with no options and no current message' run_test 'mhlist' 'mhlist: no cur message' start_test 'with no options and current message' folder +inbox 5 > /dev/null cat > $expected < $actual 2>&1 check $expected $actual 'keep first' start_test '-noheaders' run_test 'mhlist 5 -noheaders' ' 5 text/plain 25' start_test '-headers' run_prog mhlist -noheaders -headers > $actual 2>&1 check $expected $actual 'keep first' start_test 'with folder and current message' run_prog mhlist +inbox > $actual 2>&1 check $expected $actual 'keep first' start_test 'with specified message' run_prog mhlist 5 > $actual 2>&1 check $expected $actual 'keep first' start_test '-file' run_prog mhlist -file "$MH_TEST_DIR/Mail/inbox/5" > $actual 2>&1 check $expected $actual start_test '-file -' cat > $expected < $actual 2>&1 check $expected $actual start_test 'message with no blank line separating the headers from the body.' # Shouldn't make a difference to the size of the body part. # Bug meant no-blank-line case was one bigger by including the `\n' # ending the last header. f=$MH_TEST_DIR/$$.blank cat >$f-yes <<\E foo: bar body1 body2 E sed '/^$/d' $f-yes >$f-no run_prog mhlist -file $f-yes >$actual-yes run_prog mhlist -file $f-no >$actual-no check $actual-yes $actual-no rm $f-yes $f-no start_test 'message number greater than highest' run_test 'mhlist 11' "mhlist: message 11 doesn't exist" start_test 'multiple messages' cat > $expected < $actual 2>&1 check $expected $actual # Write message with a text/plain subpart. msgfile=`mhpath new` cat > $msgfile < $MH_TEST_DIR/$$.tmp mv -f $MH_TEST_DIR/$$.tmp $msgfile run_test 'mhlist last -part 2 -noheader -check' \ ' 11 multipart/mixed 936 1 multipart/related 180 2 text/plain 36 mhlist: content integrity suspect (digest mismatch) -- continuing (content text/plain in message 11, part 2)' start_test '-nocheck, the default' run_test 'mhlist last -part 2 -noheader -check -nocheck' \ ' 11 multipart/mixed 936 1 multipart/related 180 2 text/plain 36' # # Set the cur sequence to 1 to test default behavior of changecur after # this test. # mark 1 -sequence cur -add -zero start_test '-verbose' run_test 'mhlist 11 -verbose -noheader' \ ' 11 multipart/mixed 936 boundary="----- =_aaaaaaaaaa0" 1 multipart/related 180 type="multipart/alternative" boundary="subpart__1.1" 1.1 text/plain 49 charset="iso-8859-1" 2 text/plain 36 charset="iso-8859-1" 3 text/plain 35 charset="iso-8859-1" name="test3" 4 text/plain 36 charset="iso-8859-1"' # start_test 'default changecur behavior' # run_test 'mark -sequence cur -list' 'cur: 11' # # Now test -nochangecur # mhlist -nochangecur 1 >/dev/null run_test 'mark -sequence cur -list' 'cur: 11' start_test 'MIME parser and m_getfld' cat > $expected < $msgfile < $actual 2>&1 check $expected $actual ## now check mhlist output msgfile=`mhpath new` msgnum=`basename $msgfile` cat > $msgfile < Subject: mhlist test Date: Thu, 29 Jan 2015 18:12:21 +0000 (GMT) Content-Type: multipart/mixed; boundary="BoundaryMixed" --BoundaryMixed Content-type: multipart/alternative; boundary="BoundaryAlternative1" --BoundaryAlternative1 Content-type: text/enriched; CHARSET=US-ASCII Content-transfer-encoding: 7bit This is supposedly enriched. --BoundaryAlternative1 Content-type: text/plain; charset=ISO-8859-1; format=flowed Content-transfer-encoding: 8bit This is the body text/plain part. --BoundaryAlternative1 Content-type: text/html; CHARSET=US-ASCII Content-transfer-encoding: 7bit
This is the text/html body part.
--BoundaryAlternative1-- --BoundaryMixed Content-type: multipart/alternative; boundary="BoundaryAlternative2" --BoundaryAlternative2 Content-type: audio/wav Content-transfer-encoding: 8bit pretend wav audio --BoundaryAlternative2 Content-type: audio/mp3 Content-transfer-encoding: 8bit pretend mp3 audio --BoundaryAlternative2 Content-type: audio/basic Content-transfer-encoding: 8bit pretend basic audio --BoundaryAlternative2-- --BoundaryMixed-- EOF # Write the expected output. cat > $expected < $actual 2>&1 check "$expected" "$actual" # Write the expected output. cat > $expected < $actual 2>&1 check "$expected" "$actual" # Write the expected output. cat > $expected < $actual 2>&1 check "$expected" "$actual" # Write the expected output. cat > $expected < $actual 2>&1 check "$expected" "$actual" # Write the expected output. cat > $expected < $actual 2>&1 check "$expected" "$actual" finish_test exit $failed