run-markup-tests.sh revision 9c19905b0ef8f9549216e622b5c42d0d810fab31
1#! /bin/sh
2
3fail ()
4{
5  echo "Test failed: $*"
6  exit 1
7}
8
9echo_v ()
10{
11  if [ "$verbose" = "1" ]; then
12    echo "$*"
13  fi
14}
15
16error_out=/dev/null
17if [ "$1" = "-v" ]; then
18  verbose=1
19  error_out=/dev/stderr
20fi
21for I in ${srcdir:-.}/markups/fail-*.gmarkup; do
22  echo_v "Parsing $I, should fail"
23  ./markup-test $I > /dev/null 2> $error_out && fail "failed to generate error on $I"
24  if test "$?" != "1"; then
25    fail "unexpected error on $I"
26  fi  
27done
28
29I=1
30while test $I -lt 100 ; do
31  F=${srcdir:-.}/markups/valid-$I.gmarkup
32  if [ -f $F ] ; then
33    echo_v "Parsing $F, should succeed"
34    ./markup-test $F > actual 2> $error_out || fail "failed on $F"
35    diff -u ${srcdir:-.}/markups/expected-$I actual || fail "unexpected output on $F"
36    rm actual
37  fi
38  I=`expr $I + 1`
39done
40
41echo_v "All tests passed."
42