]> git.phdru.name Git - mimedecode.git/blob - test/test_all
41243847740715ac68f6e37f85fe8031fcf59253
[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    ../mimedecode.py -H test -f utf-8 input/"$1" >tmp/"$1" || return 1
14    if cmp -s expected/"$2" tmp/"$1"; then
15       rm tmp/"$1" && return 0 || return 1
16    else
17       diff --text expected/"$2" tmp/"$1" >tmp/"$1".diff
18       return 1
19    fi
20 }
21
22 test_file() {
23    echo -n "$2 "
24    if test1 "$1" "$2"; then
25       echo "ok"
26    else
27       echo "fail"
28       RC=1
29    fi
30 }
31
32 for f in input/*.txt; do
33    n="`basename \"$f\"`"
34    test_file "$n" "$n"
35 done
36
37 if [ "$RC" -eq 0 ]; then
38    echo "All tests passed!"
39    rmdir tmp
40 fi
41
42 exit $RC