]> git.phdru.name Git - mimedecode.git/blob - test/test_all
Allow * and exceptions for -p in the parameters lists
[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-1.txt -r content-id
48 test_file msg_29.txt msg_29-1.txt -R Content-Type:title
49 test_file msg_18.txt msg_18-1.txt --remove-params=X-Foobar-Spoink-Defrobnit
50 test_file msg_22.txt msg_22.txt -P -p Content-Type,Content-Disposition:name,filename
51 test_file msg_22.txt msg_22.txt -P -p \*:name,filename
52 test_file msg_22.txt msg_22.txt -P -p Content-Type,Content-Disposition:\*
53 test_file msg_22.txt msg_22.txt -P -p '*,-Content-Id:*,-x-mac-type'
54
55 if [ "$RC" -eq 0 ]; then
56    echo "All tests passed!"
57    rmdir tmp
58 fi
59
60 exit $RC