3 # $Id: runtests,v 1.8 2007-06-07 16:17:28 mike Exp $
8 $ENV{CLASSPATH} .= ":../../lib/cql-java.jar";
11 print STDERR "Usage: $0 <CQL-compiler> <XML-normaliser>\n";
14 my $compiler = $ARGV[0];
15 my $norman = $ARGV[1]; # name of XML normaliser program
16 my($ntests, $ncorrect) = (0, 0);
18 while (<sections/*>) {
21 next if /^CVS$/ || /^10$/;
22 print "testing section $_ - ", read_file("$sdir/name"), "\n";
24 while (<$sdir/*.cql>) {
26 s@sections/([0-9]+/.*)\.cql@$1@;
27 my $query = read_file($qfile);
29 $afile =~ s/\.cql$/.xcql/;
30 print " query $_ - $query ";
31 my $correct = read_file("$norman < $afile |");
32 my $tested = read_file("$compiler < $qfile | $norman |")
33 or print "\n *** test compiler exited non-zero\n";
35 if ($tested eq $correct) {
39 print "\n *** different XCQL output\n";
40 print "=== correct ===\n$correct";
41 print "=== tested ===\n$tested";
46 print sprintf("%d of %d passed: %d%%\n",
47 $ncorrect, $ntests, (100 * $ncorrect) / $ntests);
52 $name = "<$name" if $name !~ /\|$/;
53 my $fh = new IO::File("$name")
54 or die "can't read '$name': $!";
55 my $contents = join('', <$fh>);