test.sh 7.66 KB
Newer Older
1 2
#!/bin/sh

3 4
# Variables

5 6
# Path from caller to script. TODO: Some tests won't work if the script is
# called from another place than the root directory of the project.
7 8
ROOT=`dirname $0`

9 10 11 12
# false: normal test suite (default), true: extended test suite. Do not modify
# this variable directly. To run the extended test suite, use the "-e" option.
# The extended test suite contains the normal test suite plus broken tests to
# fix and tests on features that are not supported by CDuce (yet).
13 14
EXTENDED="false"

15 16
# Error code: 0 success; 1 failure.
RET=0
17

18 19
CDUCE="$ROOT/../cduce"

20 21
# Parse options

22
while test $# -ne 0; do
23 24
    if test $1 = "-e" || test $1 = "--extended"; then EXTENDED="true"; fi;
    shift;
25 26
done

27 28 29 30 31 32 33 34 35
# Test stdlib

STDLIBDIR=$ROOT/stdlib

echo -n "Tests on stdlib: "
$CDUCE $ROOT/stdlib/list/listtest.cd 2> /dev/null
test $? -ne 0 && RET=1
echo " passed."

36 37
# Test schema

38 39 40 41 42 43 44 45
SCHEMADIR=$ROOT/schema
SCHEMATESTS="$SCHEMADIR/library1.xsd $SCHEMADIR/library2.xsd\
 $SCHEMADIR/library3.xsd $SCHEMADIR/mails.xsd $SCHEMADIR/po.xsd\
 $SCHEMADIR/po2.xsd"
SCHEMASCRIPT=$SCHEMADIR/test.pl
SCHEMACDFILE=$SCHEMADIR/test.cd
SCHEMALOGFILE=$SCHEMADIR/test.log

46 47 48 49 50 51
echo -n "Tests on schema: "
if test $EXTENDED = "false"; then
    $SCHEMASCRIPT $SCHEMACDFILE $SCHEMALOGFILE $SCHEMATESTS
else
    $SCHEMASCRIPT $SCHEMACDFILE $SCHEMALOGFILE $SCHEMADIR/*.xsd
fi
52
test $? -ne 0 && RET=1
53 54
echo " passed."

55 56
# Test regtest

57 58 59 60 61
REGDIR=$ROOT/schema/regtest
REGSCRIPT=$SCHEMADIR/test.pl
REGCDFILE=$REGDIR/test.cd
REGLOGFILE=$REGDIR/test.log

62 63
echo -n "Tests on regtest: "
$REGSCRIPT $REGCDFILE $REGLOGFILE $REGDIR/*.xsd
64
test $? -ne 0 && RET=1
65 66
echo " passed."

67
# Test xsltmark
68

69 70 71 72 73
SUCCESS=0
TOTAL=0
XSLTLOG=$ROOT/xsltmark/log
GOODTESTS="$ROOT/xsltmark/identity.cd"
EXTENDEDTESTS="$ROOT/xsltmark/xslbench2.cd $ROOT/xsltmark/xslbench4.cd"
74

75
echo -n "Tests on xsltmark: "
76

77
echo > $XSLTLOG
78

79
if test $EXTENDED = "true"; then GOODTESTS="$GOODTESTS $EXTENDEDTESTS"; fi
80

81 82 83
for i in db100.xml db10.xml; do
    TOTAL=$(($TOTAL+1))
    echo "==============dbonerow.cd --arg $i===============" >> $XSLTLOG;
84
    $CDUCE $ROOT/xsltmark/dbonerow.cd --arg $ROOT/xsltmark/testcases/$i > /dev/null 2>> $XSLTLOG;
85 86
    if test $? -eq 0; then SUCCESS=$(($SUCCESS+1)); fi
done
87

88 89 90
for i in $GOODTESTS; do
    TOTAL=$(($TOTAL+1))
    echo "==============`echo $i | rev | cut -d "/" -f -1 | rev`===============" >> $XSLTLOG;
91
    $CDUCE $i > /dev/null 2>> $XSLTLOG;
92 93 94 95
    if test $? -eq 0; then SUCCESS=$(($SUCCESS+1)); fi
done

echo "$SUCCESS / $TOTAL passed."
96
test $SUCCESS -ne $TOTAL && RET=1
97

98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
# Test cql

SUCCESS=0
TOTAL=0
CQLLOG=$ROOT/cql/log
GOODTESTS="$ROOT/cql/TREE/* $ROOT/cql/XMP/*"
EXTENDEDTESTS="$ROOT/cql/R/* $ROOT/cql/SEQ/*"

echo -n "Tests on cql: "

echo > $CQLLOG

if test $EXTENDED = "true"; then GOODTESTS="$GOODTESTS $EXTENDEDTESTS"; fi

for i in $GOODTESTS; do
    TOTAL=$(($TOTAL+1))
    echo "==============`echo $i | rev | cut -d "/" -f -1 | rev`===============" >> $CQLLOG;
115
    $CDUCE $i > /dev/null 2>> $CQLLOG;
116 117 118 119 120 121
    if test $? -eq 0; then SUCCESS=$(($SUCCESS+1)); fi
done

echo "$SUCCESS / $TOTAL passed."
test $SUCCESS -ne $TOTAL && RET=1

122 123 124 125
# Test misc

echo -n "Tests on misc: "

126 127
SUCCESS=0
TOTAL=0
128 129
MISCLOG=$ROOT/misc/log
GOODTESTS="$ROOT/misc/addrbook.cd $ROOT/misc/biblio.cd\
130 131 132
 $ROOT/misc/fixml4.3v20020920.cd $ROOT/misc/funs.cd $ROOT/misc/IFX130.cd\
 $ROOT/misc/integers.cd $ROOT/misc/lazy.cd $ROOT/misc/mc.cd\
 $ROOT/misc/memento.cd $ROOT/misc/notes.cd $ROOT/misc/ns.cd\
133 134 135
 $ROOT/misc/overloading.cd $ROOT/misc/overloading2.cd $ROOT/misc/patterns.cd\
 $ROOT/misc/security.cd $ROOT/misc/str.cd $ROOT/misc/stress_opt_arg.cd\
 $ROOT/misc/stress_opt_seq.cd $ROOT/misc/vouill.cd $ROOT/misc/web.cd\
136
 $ROOT/misc/wp.cd $ROOT/misc/xtrans.cd $ROOT/misc/ref.cd $ROOT/misc/xhtml.cd\
137
 $ROOT/misc/polysyntax.cd $ROOT/misc/polyfuns.cd"
Julien Lopez's avatar
Julien Lopez committed
138
BADTESTS="$ROOT/misc/bugs_prod.cd $ROOT/misc/eval_concat.cd"
Julien Lopez's avatar
Julien Lopez committed
139
EXTENDEDTESTS="$ROOT/misc/html2latex.cd"
140 141 142

echo > $MISCLOG

143 144
if test $EXTENDED = "true"; then GOODTESTS="$GOODTESTS $EXTENDEDTESTS"; fi

145
for i in $GOODTESTS; do
146
    TOTAL=$(($TOTAL+1))
147
    echo "==============`echo $i | rev | cut -d "/" -f -1 | rev`===============" >> $MISCLOG;
148
    $CDUCE $i > /dev/null 2>> $MISCLOG;
149
    if test $? -eq 0; then SUCCESS=$(($SUCCESS+1)); fi
150 151 152
done

for i in $BADTESTS; do
153
    TOTAL=$(($TOTAL+1))
154
    echo "==============`echo $i | rev | cut -d "/" -f -1 | rev`===============" >> $MISCLOG;
155
    $CDUCE $i > /dev/null 2>> $MISCLOG;
156
    if test $? -ne 0; then SUCCESS=$(($SUCCESS+1)); fi
157 158
done

159
echo "$SUCCESS / $TOTAL passed."
160
test $SUCCESS -ne $TOTAL && RET=1
161

162
# Test ocamlinterface
163

164
OCAMLDIR=$ROOT/ocaml
165
MAKECONF=$ROOT/../Makefile.conf
166

167
WITHOCAML=false
168
test -f $MAKECONF && WITHOCAML=`cat $MAKECONF | grep "ML_INTERFACE=" | cut -d '=' -f 2`
169

170
if test $WITHOCAML = "true"; then
171

172 173
    echo "Tests on ocamlinterface: "
    ocamlc -I $OCAMLDIR/misc -c $OCAMLDIR/misc/misc.mli
174 175 176 177
    $CDUCE -I $OCAMLDIR/misc --compile $OCAMLDIR/misc/consts.cd
    $CDUCE -I $OCAMLDIR/misc --compile $OCAMLDIR/misc/misc.cd
    $CDUCE -I $OCAMLDIR/misc --mlstub $OCAMLDIR/misc/consts.cdo > $OCAMLDIR/misc/consts.ml
    $CDUCE -I $OCAMLDIR/misc --mlstub $OCAMLDIR/misc/misc.cdo > $OCAMLDIR/misc/misc.ml
178
    ocamlfind ocamlc -I $OCAMLDIR/misc -g -package expat,pxp,curl,camlp4.lib,oUnit,num,netstring,pcre,ulex,oUnit -linkpkg -I lib lib/cduce_lib.cma -o $OCAMLDIR/misc/misc $OCAMLDIR/misc/consts.ml $OCAMLDIR/misc/misc.ml $OCAMLDIR/misc/misctest.ml
179 180
    $OCAMLDIR/misc/misc 2> /dev/null
    test $? -ne 0 && RET=1
181

182
    ocamlc -I $OCAMLDIR/eval -c $OCAMLDIR/eval/eval.mli
183 184
    $CDUCE -I $OCAMLDIR/eval --compile $OCAMLDIR/eval/eval.cd -I $ROOT/../lib
    $CDUCE -I $OCAMLDIR/eval --mlstub $OCAMLDIR/eval/eval.cdo > $OCAMLDIR/eval/eval.ml
185
    ocamlfind ocamlc -I $OCAMLDIR/eval -package expat,pxp,curl,camlp4.lib,oUnit,num,netstring,pcre,ulex,oUnit -linkpkg -I lib lib/cduce_lib.cma -o $OCAMLDIR/eval/eval $OCAMLDIR/eval/eval.ml $OCAMLDIR/eval/evaltest.ml
186
    $OCAMLDIR/eval/eval
187
    test $? -ne 0 && RET=1
188

189
    ocamlc -I $OCAMLDIR/cdnum -c $OCAMLDIR/cdnum/cdnum.mli
190 191
    $CDUCE -I $OCAMLDIR/cdnum --compile $OCAMLDIR/cdnum/cdnum.cd -I `ocamlfind query num`
    $CDUCE -I $OCAMLDIR/cdnum --mlstub $OCAMLDIR/cdnum/cdnum.cdo > $OCAMLDIR/cdnum/cdnum.ml
192
    ocamlfind ocamlc -I $OCAMLDIR/cdnum -package expat,pxp,curl,camlp4.lib,oUnit,num,netstring,pcre,ulex,num,oUnit -linkpkg -I lib lib/cduce_lib.cma -o $OCAMLDIR/cdnum/cdnum $OCAMLDIR/cdnum/cdnum.ml $OCAMLDIR/cdnum/cdnumtest.ml
193
    $OCAMLDIR/cdnum/cdnum
194
    test $? -ne 0 && RET=1
195 196 197

    if test $EXTENDED = "true"; then
	ocamlc -I $OCAMLDIR/cdsdl -c -I `ocamlfind query sdl` $OCAMLDIR/cdsdl/cdsdl.mli
198 199
	$CDUCE -I $OCAMLDIR/cdsdl --compile -I `ocamlfind query sdl` $OCAMLDIR/cdsdl/cdsdl.cd
	$CDUCE -I $OCAMLDIR/cdsdl --mlstub -I `ocamlfind query sdl` $OCAMLDIR/cdsdl/cdsdl.cdo > $OCAMLDIR/cdsdl/cdsdl.ml
200
	ocamlfind ocamlc -I $OCAMLDIR/cdsdl -package expat,pxp,curl,camlp4.lib,oUnit,num,netstring,pcre,ulex,sdl,oUnit -linkpkg -I lib lib/cduce_lib.cma -o $OCAMLDIR/cdsdl/cdsdl $OCAMLDIR/cdsdl/cdsdl.ml $OCAMLDIR/cdsdl/cdsdltest.ml
201 202 203 204
	$OCAMLDIR/cdsdl/cdsdl
	test $? -ne 0 && RET=1

	ocamlc -I $OCAMLDIR/latypes -c $OCAMLDIR/latypes/latypes.mli
205 206
	$CDUCE -I $OCAMLDIR/latypes --compile $OCAMLDIR/latypes/latypes.cd
	$CDUCE -I $OCAMLDIR/latypes --mlstub $OCAMLDIR/latypes/latypes.cdo > $OCAMLDIR/latypes/latypes2.ml
207
	ocamlfind ocamlc -I $OCAMLDIR/latypes -package expat,pxp,curl,camlp4.lib,oUnit,num,netstring,pcre,ulex,num,oUnit -linkpkg -I lib lib/cduce_lib.cma -o $OCAMLDIR/latypes/latypes $OCAMLDIR/latypes/latypes.ml $OCAMLDIR/latypes/latypes2.ml $OCAMLDIR/latypes/latypestest.ml
208 209 210 211 212 213 214 215 216
	$OCAMLDIR/latypes/latypes
	test $? -ne 0 && RET=1
    fi

else
    echo -n "Warning: The interface with OCaml isn't tested as it has not been"
    echo -n " built. Check the \`mliface' option in the configure for more"
    echo " information."
fi # endif $WITHOCAML = "true"
217 218

exit $RET