]> git.phdru.name Git - mimedecode.git/blob - test/test_all
Add option --set-param=header:param=value
[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_03.txt msg_03-1.txt -D -d From,To,Subject
43 test_file msg_03.txt msg_03-1.txt -d '*,-cc'
44 test_file msg_03.txt msg_03-1.txt -d \*,From,To,Subject,-cc
45 test_file msg_15.txt msg_15-1.txt -b text/html
46 test_file msg_15.txt msg_15-2.txt -i text/html
47 test_file msg_22.txt msg_22.txt -P -p Content-Type,Content-Disposition:name,filename
48 test_file msg_22.txt msg_22.txt -P -p \*:name,filename
49 test_file msg_22.txt msg_22.txt -P -p Content-Type,Content-Disposition:\*
50 test_file msg_22.txt msg_22.txt -P -p '*,-Content-Id:*,-x-mac-type'
51 test_file msg_22.txt msg_22-1.txt -r content-id
52 test_file msg_16.txt msg_16-1.txt -r Received,List-Help,List-Post,List-Subscribe,List-Id,List-Unsubscribe,List-Archive
53 test_file msg_16.txt msg_16-2.txt -r \*,-mime-version,-content-type
54 test_file msg_29.txt msg_29-1.txt -R Content-Type:title
55 test_file msg_18.txt msg_18-1.txt -R X-Foobar-Spoink-Defrobnit:\*
56 test_file msg_01.txt msg_01-1.txt --set-header=X-Test:set
57 test_file msg_02.txt msg_02-1.txt --set-param=X-Mailer:test=set
58 test_file msg_02.txt msg_02-1.txt --set-param=X-Mailer:test:set
59
60 if [ "$RC" -eq 0 ]; then
61    echo "All tests passed!"
62    rmdir tmp
63 fi
64
65 exit $RC