#!/usr/bin/perl -w # $Id: runtests,v 1.3 2002-11-06 22:03:58 mike Exp $ use IO::File; use strict; if (@ARGV != 2) { print STDERR "Usage: $0 \n"; exit(1); } my $compiler = $ARGV[0]; my $norman = $ARGV[1]; while () { my $sdir = $_; s@sections/@@; print "testing section $_ - ", read_file("$sdir/name"), "\n"; while (<$sdir/*.cql>) { my $qfile = $_; s@sections/([0-9]+/.*)\.cql@$1@; my $query = read_file($qfile); my $afile = $qfile; $afile =~ s/\.cql$/.xcql/; print " query $_ - $query\n"; my $correct = read_file("$norman < $afile |"); my $tested = read_file("$compiler < $qfile | $norman |") or die "can't run test compiler '$compiler | $norman': $!"; if ($tested ne $correct) { print " *** different XCQL output\n"; print "=== correct ===\n$correct"; print "=== tested ===\n$tested"; } } } sub read_file { my($name) = @_; $name = "<$name" if $name !~ /\|$/; my $fh = new IO::File("$name") or die "can't read '$name': $!"; my $contents = join('', <$fh>); $fh->close(); return $contents; }