Various tweaks to improve test suite.
authormike <mike>
Wed, 20 Nov 2002 22:50:45 +0000 (22:50 +0000)
committermike <mike>
Wed, 20 Nov 2002 22:50:45 +0000 (22:50 +0000)
test/regression/Makefile
test/regression/README
test/regression/mkanswers
test/regression/mktests
test/regression/queries.raw

index b8a862c..3298539 100644 (file)
@@ -1,32 +1,31 @@
-# $Id: Makefile,v 1.5 2002-11-20 17:55:46 mike Exp $
+# $Id: Makefile,v 1.6 2002-11-20 22:50:45 mike Exp $
 
-XMLCANONICALISER = ./xmlpp.pl
-# Change this to "cat" if you want to check byte-for-byte identicality
+XMLCANONICALISER = cat
+# Change this to "./xmlpp.pl" if you want to check for equivalence
 
-test:
+test: sections/01/01.cql sections/01/01.xcql
        ./runtests CQLParser $(XMLCANONICALISER)
 
-test-adam: sections/01/01.xcql
+test-adam: sections/01/01.cql sections/01/01.xcql
        ./runtests ../../../srw/cql/cqlparse3 $(XMLCANONICALISER)
 
-test-rob: sections/01/01.xcql
+test-rob: sections/01/01.cql sections/01/01.xcql
        ./runtests ../../../rob/CQLParser.py $(XMLCANONICALISER)
 
-reference: sections/01/01.xcql
+sections/01/01.cql: mktests queries.raw
+       ./mktests queries.raw
 
-sections/01/01.xcql: sections
+sections/01/01.xcql: mkanswers
        ./mkanswers CQLParser
 # OR   ./mkanswers ../../srw/cql/cqlparse3
 # OR   ./mkanswers ../../rob/CQLParser.py
 # Depending on which parser you want to use as your reference
 
-sections: mktests queries.raw
-       rm -rf sections
-       ./mktests queries.raw
-
 clean:
        @echo "Nothing to do to 'make clean'"
 
-reference-clean:
-       rm -rf sections
+distclean:
+       find sections . -name '*.cql' -exec rm \{\} \;
 
+refclean:
+       find sections . -name '*.xcql' -exec rm \{\} \;
index 59aa84b..d7819d3 100644 (file)
@@ -1,4 +1,4 @@
-$Id: README,v 1.3 2002-11-20 01:15:15 mike Exp $
+$Id: README,v 1.4 2002-11-20 22:50:45 mike Exp $
 
 cql-java's regression-testing framework
 ---------------------------------------
@@ -12,31 +12,32 @@ cql-java's regression-testing framework
 "mkanswers" uses a trusted CQL compiler to generate corresponding XCQL.
     "01/01.xcql", "01/02.xcql" etc. are the compiled XCQL queries.
 
-All of the files described to this point are included in the
-distribution, with the "trusted" outpout produced by my own compiler,
-and used to for regression testing of new versions.  But you're
-welcome to "rm -r sections" and rebuild it to contain the trusted
-compiler output of your choice.
+Apart from the CQL files, all of the files described to this point are
+included in the distribution, with the "trusted" XCQL output produced
+by my own compiler, and used for regression testing of new versions.
+The CQL files are re-created from "queries.raw" as required.  But
+you're welcome to "make refclean" and rebuild it with mkanswers, to
+contain the trusted compiler output of your choice.
 
-"runtests" compares the output of a CQL compiler with existing XCQL
-files.  In general, use this to compare the results of your own build
-of cql-java with those of my build.  (I'll use it to test new
-versions, and people who've written other compilers can use it to test
-their code.)
+"runtests" compares the output of a nominated CQL compiler with
+existing XCQL files.  Most often, you'll use this to compare the
+results of your own build of cql-java with those of my build.  I'll
+use it to test new versions, and people who've written other compilers
+can use it to test their code.
 
 "Makefile" controls the building of all this.  You'll need to edit it
 if you want to use different compilers and suchlike from what's
 written into it, so it may be easier to run the tests by hand -- but
 it's a useful reference for the kinds of commands you might need,
-anyway.  In general, "make" will run the regression tests, and "make
-reference" will rebuild the reference results should you wish to do
-that.
+anyway.  In general, "make" will run the regression tests, creating
+whatever CQL and/or XCQL files it needs; if you do "make refclean"
+first, then the next "make" will rebuild the reference results.
 
 So, for example, if you think Rob Sanderson's parser, CQLParser.py, is
 reliable, and you want to test my parser, cql-java's CQLParser class,
 against its results, do this:
 
-       rm -rf sections
+       make refclean
        ./mktests queries.raw
        ./mkanswers CQLParser.py
        ./runtests CQLParser ./xmlpp.pl
@@ -49,3 +50,28 @@ use "cat" as the second argument.)  xmlpp.pl is a fine XML
 pretty-printer from DecisionSoft, found at
        http://software.decisionsoft.com/tools.html
 
+
+Appendix: queries that should fail
+----------------------------------
+
+The following queries are included in Rob's master list, in a final
+section called "Invalid searches [should error]".  They are all
+expected to fail in various ways.  I've taken them out of
+"queries.raw" because it's uninteresting, not to mention rather
+disturbing, to watch compilers fail.  More important, I think, to
+demonstrate correct behaviour for the known-to-work queries.
+
+>
+===
+cat or
+index any 
+index any/wrong term
+a prox/wrong b
+()
+(a
+index any fish)
+(cat any dog or ())
+title = ("illegal parentheses")
+"quoted" any "illegal quotes"
+> illegal="urn:missingQuery"
+"fish" and > illegal="urn:invalidPrefixLocation" "chips"
index fe5dd35..f027d50 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/perl -w
 
-# $Id: mkanswers,v 1.2 2002-11-03 17:02:48 mike Exp $
+# $Id: mkanswers,v 1.3 2002-11-20 22:50:45 mike Exp $
 
 use IO::File;
 use strict;
@@ -14,6 +14,7 @@ my $compiler = $ARGV[0];
 while (<sections/*>) {
     my $sdir = $_;
     s@sections/@@;
+    next if /^CVS$/;
     print "answering section $_ - ", read_file("$sdir/name"), "\n";
 
     while (<$sdir/*.cql>) {
@@ -22,7 +23,7 @@ while (<sections/*>) {
        my $query = read_file($qfile);
        my $afile = $qfile;
        $afile =~ s/\.cql$/.xcql/;
-       print "  query $_ - $query\n";
+       print "  wrote $_ - $query\n";
        my $fh = new IO::File("| $compiler > $afile")
            or die "can't run compiler '$compiler': $!";
        print $fh $query;
index 2f2c417..41a1500 100755 (executable)
@@ -1,11 +1,11 @@
 #!/usr/bin/perl -w
 
-# $Id: mktests,v 1.2 2002-11-03 17:02:48 mike Exp $
+# $Id: mktests,v 1.3 2002-11-20 22:50:45 mike Exp $
 
 use IO::File;
 use strict;
 
-mkdir "sections";
+maybe_mkdir("sections");
 my $section = 0;
 my $dir;
 my $query;
@@ -19,7 +19,7 @@ while (<>) {
        $section++;
        $query = 0;
        $dir = "sections/" . substr("0$section", -2);
-       mkdir $dir;
+       maybe_mkdir($dir);
        write_file("$dir/name", $_);
        print "created section $section ($dir) - $_\n";
        next;
@@ -31,7 +31,8 @@ while (<>) {
     $query++;
     my $filename = $dir . "/" . substr("0$query", -2) . ".cql";
     write_file($filename, $_);
-    print "  added query $query ($filename) - $_\n";
+    $filename =~ s@sections/(.*)\.cql@$1@;
+    print "  added $filename - $_\n";
 }
 
 sub write_file {
@@ -42,3 +43,14 @@ sub write_file {
     $fh->print($contents);
     $fh->close();
 }
+
+sub maybe_mkdir {
+    my($dir) = shift();
+    if (mkdir $dir) {
+       return;
+    }
+    if ($! =~ /exists/i) {
+       return;
+    }
+    die "can't create directory '$dir': $!";
+}
index d661557..1cbb74d 100644 (file)
@@ -82,19 +82,3 @@ any or all:stem and all exact any prox prox=fuzzy
 ""
 > any > any = exact any > any
 
-# Invalid searches [should error]
-
->
-===
-cat or
-index any 
-index any/wrong term
-a prox/wrong b
-()
-(a
-index any fish)
-(cat any dog or ())
-title = ("illegal parentheses")
-"quoted" any "illegal quotes"
-> illegal="urn:missingQuery"
-"fish" and > illegal="urn:invalidPrefixLocation" "chips"