Commit 8720c392 authored by Julien Lopez's avatar Julien Lopez

First shot for a good test suite.

parent 73626b71
......@@ -94,7 +94,7 @@ cvs_snapshot_bin: clean
scp cduce-cvs-linux-static.tar.gz cduce@di.ens.fr:public_html/download
.PHONY: test
test:
test: all
$(MAKE) -C tests test
############ CGI DEMO ###################
......
......@@ -287,6 +287,7 @@ clean:
rm -f configure.log
rm -rf web/doc
rm -f META
$(MAKE) -C tests clean
distclean: clean
rm -f Makefile.conf
......
TESTDIR = schema
TESTDIR = schema ocaml
RM = rm -f
.PHONY: test
test:
for d in $(TESTDIR); do $(MAKE) -C $$d test; done
@for d in $(TESTDIR); do $(MAKE) -C $$d $@; done
extendedtest:
@for d in $(TESTDIR); do $(MAKE) -C $$d $@; done
clean:
$(RM) schema/regtest/test.cd schema/regtest/test.log
$(RM) schema/test.cd schema/test.log
$(MAKE) -C ocaml clean
......@@ -6,38 +6,42 @@ RM=rm -f
all: $(OUNIT_TESTS)
test: a eval cdnum
extendedtest: all
a:
$(CAML) -c $@/$@.mli
$(CDUCE) --compile $@/c.cd
$(CDUCE) --compile $@/$@.cd
$(CDO2ML) $@/c.cdo > $@/c.ml
$(CDO2ML) $@/$@.cdo > $@/$@.ml
ocamlfind $(CAML) -g -package cduce,oUnit -linkpkg -o $@/$@ $@/c.ml $@/$@.ml $@/$@test.ml
./$@/$@
@$(CAML) -c $@/$@.mli
@$(CDUCE) --compile $@/c.cd
@$(CDUCE) --compile $@/$@.cd
@$(CDO2ML) $@/c.cdo > $@/c.ml
@$(CDO2ML) $@/$@.cdo > $@/$@.ml
@ocamlfind $(CAML) -g -package cduce,oUnit -linkpkg -o $@/$@ $@/c.ml $@/$@.ml $@/$@test.ml
@./$@/$@
eval:
$(CAML) -c $@/$@.mli
$(CDUCE) --compile $@/$@.cd -I $(OCAML_TOPLEVEL_PATH)/../cduce
$(CDO2ML) $@/$@.cdo > $@/$@.ml
ocamlfind $(CAML) -I $@ -package cduce,oUnit -linkpkg -o $@/$@ $@/$@.ml $@/$@test.ml
./$@/$@
@$(CAML) -c $@/$@.mli
@$(CDUCE) --compile $@/$@.cd -I $(OCAML_TOPLEVEL_PATH)/../cduce
@$(CDO2ML) $@/$@.cdo > $@/$@.ml
@ocamlfind $(CAML) -I $@ -package cduce,oUnit -linkpkg -o $@/$@ $@/$@.ml $@/$@test.ml
@./$@/$@
cdnum:
$(CAML) -c $@/$@.mli
$(CDUCE) --compile $@/$@.cd -I `ocamlfind query num`
$(CDO2ML) $@/$@.cdo > $@/$@.ml
ocamlfind $(CAML) -I $@ -package cduce,num,oUnit -linkpkg -o $@/$@ $@/$@.ml $@/$@test.ml
./$@/$@
@$(CAML) -c $@/$@.mli
@$(CDUCE) --compile $@/$@.cd -I `ocamlfind query num`
@$(CDO2ML) $@/$@.cdo > $@/$@.ml
@ocamlfind $(CAML) -I $@ -package cduce,num,oUnit -linkpkg -o $@/$@ $@/$@.ml $@/$@test.ml
@./$@/$@
cdsdl:
$(CAML) -c -I `ocamlfind query sdl` $@/$@.mli
$(CDUCE) --compile -I `ocamlfind query sdl` $@/$@.cd
$(CDO2ML) -I `ocamlfind query sdl` $@/$@.cdo > $@/$@.ml
ocamlfind $(CAML) -package cduce,sdl,oUnit -linkpkg -o $@/$@ $@/$@.ml $@/$@test.ml
./$@/$@
@$(CAML) -c -I `ocamlfind query sdl` $@/$@.mli
@$(CDUCE) --compile -I `ocamlfind query sdl` $@/$@.cd
@$(CDO2ML) -I `ocamlfind query sdl` $@/$@.cdo > $@/$@.ml
@ocamlfind $(CAML) -package cduce,sdl,oUnit -linkpkg -o $@/$@ $@/$@.ml $@/$@test.ml
@./$@/$@
clean:
$(RM) oUnit-* a/c.ml a/c.cdo a/c.cmi a/c.cmo
for i in $(OUNIT_TESTS); do $(RM) `echo $$i/$$i $$i/$$i.ml $$i/$$i.c[dm][oxi] $$i/$${i}test.cm[io]`; done
.PHONY: a cdsdl cdmysql eval cdnum
.PHONY: a cdsdl cdmysql eval cdnum test extendedtest
.PHONY: regtest test
TESTS=library1.xsd library2.xsd library3.xsd mails.xsd po.xsd po2.xsd
.PHONY: regtest test extendedtest
regtest:
$(MAKE) -C regtest/ test
@$(MAKE) -C $@ test
test: regtest
-./test.pl test.cd test.log *.xsd
@echo -n "Tests on schema: "
@-./test.pl test.cd test.log $(TESTS)
@echo " passed."
extendedtest: regtest
@echo -n "Tests on schema: "
@-./test.pl test.cd test.log *.xsd
@echo " passed."
TESTDIR =
.PHONY: test
.PHONY: test extendedtest
test:
-cd ../; ./test.pl regtest/test.cd regtest/test.log regtest/*.xsd
for d in $(TESTDIR); do $(MAKE) -C $$d test; done
@echo -n "Tests on regtest: "
@-cd ../; ./test.pl regtest/test.cd regtest/test.log regtest/*.xsd
@echo " passed."
@for d in $(TESTDIR); do $(MAKE) -C $$d $@; done
extendedtest:
@echo -n "Tests on regtest: "
@-cd ../; ./test.pl regtest/test.cd regtest/test.log regtest/*.xsd
@echo " passed."
@for d in $(TESTDIR); do $(MAKE) -C $$d $@; done
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:attributeGroup name="nameAttributes">
<xsd:attribute use="required" name="name" type="xsd:string" />
<xsd:attribute use="required" name="surname" type="xsd:string" />
<xsd:attribute use="optional" name="nickname" type="xsd:string" />
</xsd:attributeGroup>
</xsd:schema>
......@@ -4,6 +4,8 @@ my $testfile = shift || die "testfile?";
my $logfile = shift || die "logfile?";
my $cduce = "../../cduce";
my $failed_tests = "";
my $nbr_tests = 0;
my $nbr_success = 0;
unlink $logfile if (-f $logfile);
sub get_root($) {
my ($f) = @_;
......@@ -20,7 +22,8 @@ sub get_root($) {
foreach my $s (@ARGV) {
if ($s =~ /(.*)\.xsd$/) {
my $msg = "Testing $s ...\n";
print $msg;
$nbr_tests += 1;
open (LOG, ">> $logfile");
print LOG "\n", "*" x 80, "\n", $msg, "*" x 80, "\n";
close LOG;
......@@ -77,10 +80,14 @@ EOF
print "E: test failed on $s\n";
$failed_tests .= " $s";
}
else {
$nbr_success += 1;
}
} else {
print "W: ignoring $s ...\n"
};
}
print "$nbr_success / $nbr_tests";
if ($failed_tests) {
print STDERR "One or more tests failed :-(\nFailed tests:$failed_tests\n";
print STDERR "See $logfile for details\n";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment