Fix some outdated Makefile rules.
[cql-java-moved-to-github.git] / test / regression / mkanswers
1 #!/usr/bin/perl -w
2
3 # $Id: mkanswers,v 1.2 2002-11-03 17:02:48 mike Exp $
4
5 use IO::File;
6 use strict;
7
8 if (@ARGV != 1) {
9     print STDERR "Usage: $0 <trusted-CQL-compiler>\n";
10     exit(1);
11 }
12 my $compiler = $ARGV[0];
13
14 while (<sections/*>) {
15     my $sdir = $_;
16     s@sections/@@;
17     print "answering section $_ - ", read_file("$sdir/name"), "\n";
18
19     while (<$sdir/*.cql>) {
20         my $qfile = $_;
21         s@sections/([0-9]+/.*)\.cql@$1@;
22         my $query = read_file($qfile);
23         my $afile = $qfile;
24         $afile =~ s/\.cql$/.xcql/;
25         print "  query $_ - $query\n";
26         my $fh = new IO::File("| $compiler > $afile")
27             or die "can't run compiler '$compiler': $!";
28         print $fh $query;
29         $fh->close();
30     }
31 }
32
33 sub read_file {
34     my($name) = @_;
35
36     my $fh = new IO::File("<$name")
37         or die "can't read '$name': $!";
38     my $contents = join('', <$fh>);
39     $fh->close();
40     return $contents;
41 }