]> git.phdru.name Git - mimedecode.git/blob - test/test_all
Add option -r to remove headers
[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
46 if [ "$RC" -eq 0 ]; then
47    echo "All tests passed!"
48    rmdir tmp
49 fi
50
51 exit $RC