]> git.phdru.name Git - mimedecode.git/blobdiff - test/test_all
Add a test for option -i
[mimedecode.git] / test / test_all
index 19b8323630b0f12b734eb233419f1ada3b89bb84..3de6ec74fb0daf91ff740250d7d3a1c261693640 100755 (executable)
@@ -9,18 +9,41 @@ mkdir tmp || exit 1
 
 RC=0
 
-for f in input/*.txt; do
-   f="`basename \"$f\"`"
-   ../mimedecode.py -H test -f utf-8 input/"$f" >tmp/"$f"
-   if cmp -s expected/"$f" tmp/"$f"; then
-      rm tmp/"$f"
+test1() {
+   infile="$1"
+   shift
+   expfile="$1"
+   shift
+
+   ../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/"$expfile" tmp/"$expfile" >tmp/"$expfile".diff
+      return 1
+   fi
+}
+
+test_file() {
+   echo -n "$2 "
+   if test1 "$@"; then
+      echo "ok"
    else
+      echo "fail"
       RC=1
-      diff --text expected/"$f" tmp/"$f" >tmp/"$f".diff
    fi
+}
+
+for f in input/*.txt; do
+   n="`basename \"$f\"`"
+   test_file "$n" "$n"
 done
 
+test_file msg_15.txt msg_15-1.txt -b text/html
+test_file msg_15.txt msg_15-2.txt -i text/html
+
 if [ "$RC" -eq 0 ]; then
+   echo "All tests passed!"
    rmdir tmp
 fi