]> git.phdru.name Git - mimedecode.git/blob - test/test_all
Make option -i to work with multipart messages
[mimedecode.git] / test / test_all
1 #! /bin/sh
2
3 cd "`dirname \"$0\"`" &&
4 MAILCAPS="`pwd`"/.mailcap &&
5 export MAILCAPS &&
6
7 rm -rf save 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_01.txt msg_01-2.txt --set-header=X-Test:set --set-param=X-Test:test:set
58 test_file msg_02.txt msg_02.txt --set-param=X-Test:test:set
59 test_file msg_02.txt msg_02-1.txt --set-param=X-Mailer:test=set
60 test_file msg_02.txt msg_02-1.txt --set-param=X-Mailer:test:set
61 test_file msg_13.txt msg_13-1.txt -B '*/*'
62 test_file msg_13.txt msg_13.txt -t 'text/*' -b 'image/*' -B '*/*'
63 test_file msg_36.txt msg_36-1.txt -i multipart/alternative
64
65 # Test --save-*
66 test2() {
67    infile="$1"
68    shift
69    expfile="$1"
70    shift
71    savefile="$1"
72    shift
73    expsavefile="$1"
74    shift
75
76    test_file "$infile" "$expfile" -O save "$@"
77
78    if cmp -s expected-save/"$expsavefile" save/"$savefile"; then
79       rm save/"$savefile" && return 0 || return 1
80    else
81       return 1
82    fi
83 }
84
85 test_save() {
86    if test2 "$@"; then
87       echo "    save: ok"
88    else
89       echo "    save: fail"
90       RC=1
91    fi
92 }
93
94 test_save msg_07.txt msg_07.txt 1-dingusfish.gif msg_07-1.txt --save-headers image/gif
95 test_save msg_07.txt msg_07.txt 1-dingusfish.gif msg_07-2.txt --save-body image/gif
96 test_save msg_07.txt msg_07.txt 1-dingusfish.gif msg_07-3.txt --save-message image/gif
97 test_save msg_07-1.txt msg_07-1.txt 1-dingusfish.gif msg_07-4.txt --save-message image/gif
98
99 if [ "$RC" -eq 0 ]; then
100    echo "All tests passed!"
101    rmdir save tmp
102 fi
103
104 exit $RC