Adding test for MARC->MARCXML conversions with 3 weird records
[yaz-moved-to-github.git] / test / tstcql.sh
1 #!/bin/sh
2 # $Id: tstcql.sh,v 1.3 2004-10-01 11:43:43 adam Exp $
3 srcdir=${srcdir:-.}
4 oIFS="$IFS"
5 IFS='
6 '
7 secno=0
8 testno=0
9 comment=0
10 ecode=0
11 test -f ${srcdir}/cqlsample || exit 1
12 test -d cql || mkdir cql
13 for f in `cat ${srcdir}/cqlsample`; do
14         if echo $f | grep '^#' >/dev/null; then
15                 comment=1
16         else
17                 if test "$comment" = "1"; then
18                         secno=`expr $secno + 1`
19                         testno=0
20                 fi
21                 comment=0
22                 testno=`expr $testno + 1`
23                 OUT1=${srcdir}/cql/$secno.$testno.out
24                 ERR1=${srcdir}/cql/$secno.$testno.err
25                 OUT2=cql/$secno.$testno.out.tmp
26                 ERR2=cql/$secno.$testno.err.tmp
27                 DIFF=cql/$secno.$testno.diff
28                 ../util/cql2xcql "$f" >$OUT2 2>$ERR2
29                 if test -f $OUT1 -a -f $ERR1; then
30                         if diff $OUT1 $OUT2 >$DIFF; then
31                                 rm $DIFF
32                         else
33                                 echo "diff out $secno $testno $f"
34                                 cat $DIFF
35                                 ecode=1 
36                         fi
37                         if diff $ERR1 $ERR2 >$DIFF; then
38                                 rm $DIFF
39                         else
40                                 echo "diff err $secno $testno $f"
41                                 cat $DIFF
42                                 ecode=1
43                         fi
44                 else
45                         echo "making test $secno $testno $f"
46                         mv $OUT2 $OUT1
47                         mv $ERR2 $ERR1
48                         ecode=1
49                 fi      
50         fi              
51 done
52 IFS="$oIFS"
53 exit $ecode