#!/usr/bin/perl -w
+# $Id: runtests,v 1.12 2007-07-03 15:53:52 mike Exp $
+
use IO::File;
use strict;
+$ENV{CLASSPATH} .= ":../../src/main/java";
+$ENV{CLASSPATH} .= ":../../lib/cql-java.jar";
+
if (@ARGV != 2) {
print STDERR "Usage: $0 <CQL-compiler> <XML-normaliser>\n";
exit(1);
}
my $compiler = $ARGV[0];
-my $norman = $ARGV[1];
+my $norman = $ARGV[1]; # name of XML normaliser program
+my($ntests, $ncorrect) = (0, 0);
while (<sections/*>) {
my $sdir = $_;
s@sections/@@;
+ next if /^CVS$/;
print "testing section $_ - ", read_file("$sdir/name"), "\n";
while (<$sdir/*.cql>) {
my $query = read_file($qfile);
my $afile = $qfile;
$afile =~ s/\.cql$/.xcql/;
- print " query $_ - $query\n";
+ print " query $_ - $query ";
+ $ntests++;
my $correct = read_file("$norman < $afile |");
- my $tested = read_file("$compiler < $qfile | $norman |")
- or die "can't run test compiler '$compiler | $norman': $!";
- print " *** different XCQL output\n"
- if $tested ne $correct;
+ my $tested = read_file("$compiler < $qfile | $norman |");
+ if (!$tested) {
+ print "\n *** test compiler exited non-zero\n";
+ } elsif ($tested eq $correct) {
+ print "OK\n";
+ $ncorrect++;
+ } else {
+ print "\n *** XCQL output differs from $afile\n";
+ print "=== tested ===\n$tested";
+ print "=== end ===\n";
+ }
}
}
+print sprintf("%d of %d passed: %d%%\n",
+ $ncorrect, $ntests, (100 * $ncorrect) / $ntests);
+
sub read_file {
my($name) = @_;