3 # $Id: runtests,v 1.12 2007-07-03 15:53:52 mike Exp $
8 $ENV{CLASSPATH} .= ":../../src/main/java";
9 $ENV{CLASSPATH} .= ":../../lib/cql-java.jar";
12 print STDERR "Usage: $0 <CQL-compiler> <XML-normaliser>\n";
15 my $compiler = $ARGV[0];
16 my $norman = $ARGV[1]; # name of XML normaliser program
17 my($ntests, $ncorrect) = (0, 0);
19 while (<sections/*>) {
23 print "testing section $_ - ", read_file("$sdir/name"), "\n";
25 while (<$sdir/*.cql>) {
27 s@sections/([0-9]+/.*)\.cql@$1@;
28 my $query = read_file($qfile);
30 $afile =~ s/\.cql$/.xcql/;
31 print " query $_ - $query ";
33 my $correct = read_file("$norman < $afile |");
34 my $tested = read_file("$compiler < $qfile | $norman |");
36 print "\n *** test compiler exited non-zero\n";
37 } elsif ($tested eq $correct) {
41 print "\n *** XCQL output differs from $afile\n";
42 print "=== tested ===\n$tested";
43 print "=== end ===\n";
48 print sprintf("%d of %d passed: %d%%\n",
49 $ncorrect, $ntests, (100 * $ncorrect) / $ntests);
54 $name = "<$name" if $name !~ /\|$/;
55 my $fh = new IO::File("$name")
56 or die "can't read '$name': $!";
57 my $contents = join('', <$fh>);