]> git.phdru.name Git - mimedecode.git/blobdiff - test/test_all
Run tests with python2 and python3
[mimedecode.git] / test / test_all
index 81b71eae7bafe16b1c12367b69e4a61512b4c517..b05f3834eb03f335c3b62e828a3576430f5526f7 100755 (executable)
@@ -4,35 +4,110 @@ cd "`dirname \"$0\"`" &&
 MAILCAPS="`pwd`"/.mailcap &&
 export MAILCAPS &&
 
-rm -rf tmp &&
+rm -rf save tmp &&
 mkdir tmp || exit 1
 
 RC=0
 
 test1() {
-   ../mimedecode.py -H test -f utf-8 input/"$1" >tmp/"$1" || return 1
-   if cmp -s expected/"$1" tmp/"$1"; then
-      rm tmp/"$1" && return 0 || return 1
+   infile="$1"
+   shift
+   expfile="$1"
+   shift
+
+   $PYTHON ../mimedecode.py -H test -f utf-8 "$@" input/"$infile" >tmp/"$expfile" || return 1
+   if cmp -s expected/"$expfile" tmp/"$expfile"; then
+      rm tmp/"$expfile" && return 0 || return 1
    else
-      diff --text expected/"$1" tmp/"$1" >tmp/"$1".diff
+      diff --text expected/"$expfile" tmp/"$expfile" >tmp/"$expfile".diff
       return 1
    fi
 }
 
-for f in input/*.txt; do
-   n="`basename \"$f\"`"
-   echo -n "$n "
-   if test1 "$n"; then
+test_file() {
+   echo -n "$2 "
+   if test1 "$@"; then
       echo "ok"
    else
       echo "fail"
       RC=1
    fi
+}
+
+for f in input/*.txt; do
+   n="`basename \"$f\"`"
+   test_file "$n" "$n"
 done
 
+test_file msg_03.txt msg_03-1.txt -D -d From,To,Subject
+test_file msg_03.txt msg_03-1.txt -d '*,-cc'
+test_file msg_03.txt msg_03-1.txt -d \*,From,To,Subject,-cc
+test_file msg_15.txt msg_15-1.txt -b text/html
+test_file msg_15.txt msg_15-2.txt -i text/html
+test_file msg_22.txt msg_22.txt -P -p Content-Type,Content-Disposition:name,filename
+test_file msg_22.txt msg_22.txt -P -p \*:name,filename
+test_file msg_22.txt msg_22.txt -P -p Content-Type,Content-Disposition:\*
+test_file msg_22.txt msg_22.txt -P -p '*,-Content-Id:*,-x-mac-type'
+test_file msg_22.txt msg_22-1.txt -r content-id
+test_file msg_16.txt msg_16-1.txt -r Received,List-Help,List-Post,List-Subscribe,List-Id,List-Unsubscribe,List-Archive
+test_file msg_16.txt msg_16-2.txt -r \*,-mime-version,-content-type
+test_file msg_29.txt msg_29-1.txt -R Content-Type:title
+test_file msg_18.txt msg_18-1.txt -R X-Foobar-Spoink-Defrobnit:\*
+test_file msg_01.txt msg_01-1.txt --set-header=X-Test:set
+test_file msg_01.txt msg_01-2.txt --set-header=X-Test:set --set-param=X-Test:test:set
+test_file msg_02.txt msg_02.txt --set-param=X-Test:test:set
+test_file msg_02.txt msg_02-1.txt --set-param=X-Mailer:test=set
+test_file msg_02.txt msg_02-1.txt --set-param=X-Mailer:test:set
+test_file msg_13.txt msg_13-1.txt -B '*/*'
+test_file msg_13.txt msg_13.txt -t 'text/*' -b 'image/*' -B '*/*'
+test_file msg_36.txt msg_36-1.txt -i multipart/alternative
+test_file msg_36.txt msg_36-2.txt -I multipart/alternative
+
+# Test --save-*
+test2() {
+   infile="$1"
+   shift
+   expfile="$1"
+   shift
+   savefile="$1"
+   shift
+   expsavefile="$1"
+   shift
+
+   test_file "$infile" "$expfile" -O save "$@"
+
+   if cmp -s expected-save/"$expsavefile" save/"$savefile"; then
+      rm save/"$savefile" && return 0 || return 1
+   else
+      return 1
+   fi
+}
+
+test_save() {
+   if test2 "$@"; then
+      echo "    save: ok"
+   else
+      echo "    save: fail"
+      RC=1
+   fi
+}
+
+test_save msg_07.txt msg_07.txt 1-dingusfish.gif msg_07-1.txt --save-headers image/gif
+test_save msg_07.txt msg_07.txt 1-dingusfish.gif msg_07-2.txt --save-body image/gif
+test_save msg_07.txt msg_07.txt 1-dingusfish.gif msg_07-3.txt --save-message image/gif
+test_save msg_07-1.txt msg_07-1.txt 1-dingusfish.gif msg_07-4.txt --save-message image/gif
+
+test_save msg_07.txt msg_07.txt 1.dig msg_07-5.txt --save-headers multipart/mixed
+test_save msg_07.txt msg_07.txt 1.dig msg_07-6.txt --save-body multipart/mixed
+test_save msg_07.txt msg_07.txt 1.dig msg_07-7.txt --save-message multipart/mixed
+
+echo
+
 if [ "$RC" -eq 0 ]; then
    echo "All tests passed!"
-   rmdir tmp
+   rmdir save tmp
+else
+   echo "ERRORS!"
 fi
 
 exit $RC