Loathesome hacks to skip section 10 explicitly, since CVS keep
[cql-java-moved-to-github.git] / test / regression / runtests
1 #!/usr/bin/perl -w
2
3 # $Id: runtests,v 1.6 2002-11-20 23:10:17 mike Exp $
4
5 use IO::File;
6 use strict;
7
8 if (@ARGV != 2) {
9     print STDERR "Usage: $0 <CQL-compiler> <XML-normaliser>\n";
10     exit(1);
11 }
12 my $compiler = $ARGV[0];
13 my $norman = $ARGV[1];
14
15 while (<sections/*>) {
16     my $sdir = $_;
17     s@sections/@@;
18     next if /^CVS$/ || /^10$/;
19     print "testing section $_ - ", read_file("$sdir/name"), "\n";
20
21     while (<$sdir/*.cql>) {
22         my $qfile = $_;
23         s@sections/([0-9]+/.*)\.cql@$1@;
24         my $query = read_file($qfile);
25         my $afile = $qfile;
26         $afile =~ s/\.cql$/.xcql/;
27         print "  query $_ - $query  ";
28         my $correct = read_file("$norman < $afile |");
29         my $tested = read_file("$compiler < $qfile | $norman |")
30             or print "\n    *** test compiler exited non-zero\n";
31         if ($tested eq $correct) {
32             print "OK\n";
33         } else {
34             print "\n    *** different XCQL output\n";
35             print "=== correct ===\n$correct";
36             print "=== tested ===\n$tested";
37         }
38     }
39 }
40
41 sub read_file {
42     my($name) = @_;
43
44     $name = "<$name" if $name !~ /\|$/;
45     my $fh = new IO::File("$name")
46         or die "can't read '$name': $!";
47     my $contents = join('', <$fh>);
48     $fh->close();
49     return $contents;
50 }