]> git.phdru.name Git - mimedecode.git/blob - test/test_all
Version 2.3.8
[mimedecode.git] / test / test_all
1 #! /bin/sh
2
3 cd "`dirname \"$0\"`" &&
4 MAILCAPS="`pwd`"/.mailcap &&
5 export MAILCAPS &&
6
7 rm -rf tmp &&
8 mkdir tmp || exit 1
9
10 RC=0
11
12 test1() {
13    infile="$1"
14    shift
15    expfile="$1"
16    shift
17
18    ../mimedecode.py -H test -f utf-8 "$@" input/"$infile" >tmp/"$expfile" || return 1
19    if cmp -s expected/"$expfile" tmp/"$expfile"; then
20       rm tmp/"$expfile" && return 0 || return 1
21    else
22       diff --text expected/"$expfile" tmp/"$expfile" >tmp/"$expfile".diff
23       return 1
24    fi
25 }
26
27 test_file() {
28    echo -n "$2 "
29    if test1 "$@"; then
30       echo "ok"
31    else
32       echo "fail"
33       RC=1
34    fi
35 }
36
37 for f in input/*.txt; do
38    n="`basename \"$f\"`"
39    test_file "$n" "$n"
40 done
41
42 test_file msg_15.txt msg_15-1.txt -b text/html
43 test_file msg_15.txt msg_15-2.txt -i text/html
44 test_file msg_22.txt msg_22-1.txt -r content-id
45 test_file msg_29.txt msg_29-1.txt -R Content-Type:title
46 test_file msg_18.txt msg_18-1.txt --remove-params=X-Foobar-Spoink-Defrobnit
47
48 if [ "$RC" -eq 0 ]; then
49    echo "All tests passed!"
50    rmdir tmp
51 fi
52
53 exit $RC