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://tidy.sourceforge.net/>
10#
11# CVS Info:
12#
13#    $Author: arnaud02 $
14#    $Date: 2006/01/04 10:27:12 $
15#    $Revision: 1.9 $
16#
17# set -x
18
19VERSION='$Id'
20
21echo Testing $1
22
23set +f
24
25TESTNO=$1
26EXPECTED=$2
27TIDY=../bin/tidyp
28INFILES=./input/in_${TESTNO}.*ml
29CFGFILE=./input/cfg_${TESTNO}.txt
30
31TIDYFILE=./tmp/out_${TESTNO}.html
32MSGFILE=./tmp/msg_${TESTNO}.txt
33
34unset HTML_TIDY
35
36shift
37shift
38
39# Remove any pre-exising test outputs
40for INFIL in $MSGFILE $TIDYFILE
41do
42  if [ -f $INFIL ]
43  then
44    rm $INFIL
45  fi
46done
47
48for INFILE in $INFILES
49do
50    if [ -r $INFILE ]
51    then
52      break
53    fi
54done
55
56# If no test specific config file, use default.
57if [ ! -f $CFGFILE ]
58then
59  CFGFILE=./input/cfg_default.txt
60fi
61
62# Make sure output directory exists.
63if [ ! -d ./tmp ]
64then
65  mkdir ./tmp
66fi
67
68$TIDY -f $MSGFILE -config $CFGFILE "$@" --tidy-mark no -o $TIDYFILE $INFILE
69STATUS=$?
70
71if [ $STATUS -ne $EXPECTED ]
72then
73  echo "== $TESTNO failed (Status received: $STATUS vs expected: $EXPECTED)"
74  cat $MSGFILE
75  exit 1
76fi
77
78exit 0
79
80