OSDN Git Service

Initial commit
[wordring-tm/wordring-tm.git] / third_party / tidy-html5-master / test / testone.sh
1 #! /bin/sh
2
3 #
4 # testone.sh - execute a single testcase
5 #
6 # (c) 1998-2006 (W3C) MIT, ERCIM, Keio University
7 # See tidy.c for the copyright notice.
8 #
9 # <URL:http://www.html-tidy.org/>
10 #
11 # set -x
12 BN=`basename $0`
13 VERSION='$Id'
14
15 echo Testing $1
16
17 set +f
18
19 TESTNO=$1
20 EXPECTED=$2
21 #TIDY=../bin/tidy
22 TIDY=../build/cmake/tidy5
23 if [ ! -f "$TIDY" ]; then
24         echo "$BN: Can NOT locate binary '$TIDY'!"
25         echo "$BN: Fix me with the correct location of the binary to run."
26         exit 1
27 fi
28 INFILES=./input/in_${TESTNO}.*ml
29 CFGFILE=./input/cfg_${TESTNO}.txt
30
31 TIDYFILE=./tmp/out_${TESTNO}.html
32 MSGFILE=./tmp/msg_${TESTNO}.txt
33
34 unset HTML_TIDY
35
36 shift
37 shift
38
39 # Remove any pre-exising test outputs
40 for INFIL in $MSGFILE $TIDYFILE
41 do
42   if [ -f $INFIL ]
43   then
44     rm $INFIL
45   fi
46 done
47
48 for INFILE in $INFILES
49 do
50     if [ -r $INFILE ]
51     then
52       break
53     fi
54 done
55
56 # If no test specific config file, use default.
57 if [ ! -f $CFGFILE ]
58 then
59   CFGFILE=./input/cfg_default.txt
60 fi
61
62 # Make sure output directory exists.
63 if [ ! -d ./tmp ]
64 then
65   mkdir ./tmp
66 fi
67
68 echo "Doing: './$TIDY -f $MSGFILE -config $CFGFILE "$@" --tidy-mark no -o $TIDYFILE $INFILE'" >> tempall.txt
69 ./$TIDY -f $MSGFILE -config $CFGFILE "$@" --tidy-mark no -o $TIDYFILE $INFILE
70 STATUS=$?
71
72 if [ $STATUS -ne $EXPECTED ]
73 then
74   echo "== $TESTNO failed (Status received: $STATUS vs expected: $EXPECTED)" 
75   cat $MSGFILE
76   echo "== $TESTNO failed (Status received: $STATUS vs expected: $EXPECTED)" >> tempall.txt
77   cat $MSGFILE >> tempall.txt
78   exit 1
79 fi
80
81 exit 0
82