From: mike Date: Sun, 3 Nov 2002 16:53:04 +0000 (+0000) Subject: Move the top-level "test" directory into "test/regression" X-Git-Tag: v1.5~243 X-Git-Url: http://jsfdemo.indexdata.com/?a=commitdiff_plain;ds=inline;h=98525ac4901f29de25923032c550d1e7faf2066f;p=cql-java-moved-to-github.git Move the top-level "test" directory into "test/regression" --- diff --git a/test/.cvsignore b/test/.cvsignore deleted file mode 100644 index 38c8706..0000000 --- a/test/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -sections diff --git a/test/Makefile b/test/Makefile deleted file mode 100644 index 530b2cd..0000000 --- a/test/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -# $Id: Makefile,v 1.3 2002-11-03 16:49:38 mike Exp $ - -sections/01/01.xcql: sections - ./mkanswers CQLParser -# OR ./mkanswers ../../srw/cql/cqlparse3 -# OR ./mkanswers ../../rob/CQLParser.py - -sections: mktests queries.raw - rm -rf sections - ./mktests queries.raw - -adam-tests: sections/01/01.xcql - ./runtests ../../srw/cql/cqlparse3 - -rob-tests: sections/01/01.xcql - ./runtests ../../rob/CQLParser.py - -clean: - find sections -name '*.xcql' -print | xargs rm -f - -distclean: - rm -rf sections - diff --git a/test/README b/test/README deleted file mode 100644 index 614a2ca..0000000 --- a/test/README +++ /dev/null @@ -1,36 +0,0 @@ -$Id: README,v 1.3 2002-11-03 16:49:38 mike Exp $ - -"queries.raw" is the file of test queries as provided by Rob. -"mktests" parses the raw file into sections and individual queries -"sections" is the top-level directory created by that program. - "01", "02" etc. represent the sections within the raw file - "01/name", "02/name", etc. contain the names of the sections. - "01/01.cql", "01/02.cql" etc. are the CQL queries themselves. -"mkanswers" uses a trusted CQL compiler to generate corresponding XCQL. - "01/01.xcql", "01/02.xcql" etc. are the compiled XCQL queries. -"runtests" compares the output of a CQL compiler with existing XCQL files. - -"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. - -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 - ./mktests queries.raw - ./mkanswers CQLParser.py - ./runtests CQLParser sgmlnorm - -(Except that sgmlnorm is useless -- gotta find something better.) - -Also: there's a nasty hack here called "showtest" which, when run like -``./showtest 07/03'', will show you the ways in which my output -differs from Adam's. I'll probably delete it soon. - -Also: there's a subdirectory "random" which tests in a completely -different way. That ought to be a sister directory with this one, and -will be when I move the rest of this stuff down a level. diff --git a/test/mkanswers b/test/mkanswers deleted file mode 100755 index 3475181..0000000 --- a/test/mkanswers +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/perl -w - -use IO::File; -use strict; - -if (@ARGV != 1) { - print STDERR "Usage: $0 \n"; - exit(1); -} -my $compiler = $ARGV[0]; - -while () { - my $sdir = $_; - s@sections/@@; - print "answering 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 $fh = new IO::File("| $compiler > $afile") - or die "can't run compiler '$compiler': $!"; - print $fh $query; - $fh->close(); - } -} - -sub read_file { - my($name) = @_; - - my $fh = new IO::File("<$name") - or die "can't read '$name': $!"; - my $contents = join('', <$fh>); - $fh->close(); - return $contents; -} diff --git a/test/mktests b/test/mktests deleted file mode 100755 index 523bb0f..0000000 --- a/test/mktests +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/perl -w - -use IO::File; -use strict; - -mkdir "sections"; -my $section = 0; -my $dir; -my $query; - -while (<>) { - chomp(); - s/[ \t]+$//; - next if /^$/; - - if (s/^#[ \t]*//) { - $section++; - $query = 0; - $dir = "sections/" . substr("0$section", -2); - mkdir $dir; - write_file("$dir/name", $_); - print "created section $section ($dir) - $_\n"; - next; - } - - die "query before first section header" - if !defined $dir; - - $query++; - my $filename = $dir . "/" . substr("0$query", -2) . ".cql"; - write_file($filename, $_); - print " added query $query ($filename) - $_\n"; -} - -sub write_file { - my($name, $contents) = @_; - - my $fh = new IO::File(">$name") - or die "can't create '$name': $!"; - $fh->print($contents); - $fh->close(); -} diff --git a/test/queries.raw b/test/queries.raw deleted file mode 100644 index fd42750..0000000 --- a/test/queries.raw +++ /dev/null @@ -1,86 +0,0 @@ -# Simple - -cat -"cat" -comp.os.linux -xml:element -"" -"=" -"prox/word/>=/5" -("cat") -((dog)) - -# index relation term - -title = "fish" -title exact fish -title any fish -title all fish -title > 9 -title >= 23 -dc.title any "fish chips" -dc.title any/stem fish -dc.fish all/stem/fuzzy "fish chips" -(title any frog) -((dc.title any/stem "frog pond")) - -# Simple Boolean - -cat or dog -cat and fish -cat not frog -(cat not frog) -"cat" not "fish food" -xml and "prox/word/" -a or b and c not d - -# I/R/T plus Boolean - -bath.author any fish and dc.title all "cat dog" -(title any/stem "fish dog" or "and") - -# Prox - -cat prox hat -cat prox/word/=/3/ordered hat -cat prox///3 hat -"fish food" prox/sentence "and" -title all "chips frog" prox/word//5 "any" -(dc.author exact "jones" prox///5 title >= "smith") -((cat prox hat)) - -# Special characters -(cat^) -"cat" -"^cat says \"fish\"" -"cat*fish" -cat?dog -(("^cat*fishdog\"horse?")) - -# Nesting Parens - -(((cat or dog) or horse) and frog) -(cat and dog) or (horse and frog) -(cat and (horse or frog)) and chips - -# Lame searches - -"any" or "all:stem" and "all" exact "any" prox/word "prox"="fuzzy" -((((((((("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 ()) -fred and any -((fred or all)) -sorry = (mike) diff --git a/test/regression/.cvsignore b/test/regression/.cvsignore new file mode 100644 index 0000000..38c8706 --- /dev/null +++ b/test/regression/.cvsignore @@ -0,0 +1 @@ +sections diff --git a/test/regression/Makefile b/test/regression/Makefile new file mode 100644 index 0000000..5831c9e --- /dev/null +++ b/test/regression/Makefile @@ -0,0 +1,23 @@ +# $Id: Makefile,v 1.1 2002-11-03 16:53:04 mike Exp $ + +sections/01/01.xcql: sections + ./mkanswers CQLParser +# OR ./mkanswers ../../srw/cql/cqlparse3 +# OR ./mkanswers ../../rob/CQLParser.py + +sections: mktests queries.raw + rm -rf sections + ./mktests queries.raw + +adam-tests: sections/01/01.xcql + ./runtests ../../srw/cql/cqlparse3 + +rob-tests: sections/01/01.xcql + ./runtests ../../rob/CQLParser.py + +clean: + find sections -name '*.xcql' -print | xargs rm -f + +distclean: + rm -rf sections + diff --git a/test/regression/README b/test/regression/README new file mode 100644 index 0000000..83d384e --- /dev/null +++ b/test/regression/README @@ -0,0 +1,32 @@ +$Id: README,v 1.1 2002-11-03 16:53:04 mike Exp $ + +"queries.raw" is the file of test queries as provided by Rob. +"mktests" parses the raw file into sections and individual queries +"sections" is the top-level directory created by that program. + "01", "02" etc. represent the sections within the raw file + "01/name", "02/name", etc. contain the names of the sections. + "01/01.cql", "01/02.cql" etc. are the CQL queries themselves. +"mkanswers" uses a trusted CQL compiler to generate corresponding XCQL. + "01/01.xcql", "01/02.xcql" etc. are the compiled XCQL queries. +"runtests" compares the output of a CQL compiler with existing XCQL files. + +"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. + +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 + ./mktests queries.raw + ./mkanswers CQLParser.py + ./runtests CQLParser sgmlnorm + +(Except that sgmlnorm is useless -- gotta find something better.) + +Also: there's a nasty hack here called "showtest" which, when run like +``./showtest 07/03'', will show you the ways in which my output +differs from Adam's. I'll probably delete it soon. diff --git a/test/regression/mkanswers b/test/regression/mkanswers new file mode 100755 index 0000000..3475181 --- /dev/null +++ b/test/regression/mkanswers @@ -0,0 +1,39 @@ +#!/usr/bin/perl -w + +use IO::File; +use strict; + +if (@ARGV != 1) { + print STDERR "Usage: $0 \n"; + exit(1); +} +my $compiler = $ARGV[0]; + +while () { + my $sdir = $_; + s@sections/@@; + print "answering 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 $fh = new IO::File("| $compiler > $afile") + or die "can't run compiler '$compiler': $!"; + print $fh $query; + $fh->close(); + } +} + +sub read_file { + my($name) = @_; + + my $fh = new IO::File("<$name") + or die "can't read '$name': $!"; + my $contents = join('', <$fh>); + $fh->close(); + return $contents; +} diff --git a/test/regression/mktests b/test/regression/mktests new file mode 100755 index 0000000..523bb0f --- /dev/null +++ b/test/regression/mktests @@ -0,0 +1,42 @@ +#!/usr/bin/perl -w + +use IO::File; +use strict; + +mkdir "sections"; +my $section = 0; +my $dir; +my $query; + +while (<>) { + chomp(); + s/[ \t]+$//; + next if /^$/; + + if (s/^#[ \t]*//) { + $section++; + $query = 0; + $dir = "sections/" . substr("0$section", -2); + mkdir $dir; + write_file("$dir/name", $_); + print "created section $section ($dir) - $_\n"; + next; + } + + die "query before first section header" + if !defined $dir; + + $query++; + my $filename = $dir . "/" . substr("0$query", -2) . ".cql"; + write_file($filename, $_); + print " added query $query ($filename) - $_\n"; +} + +sub write_file { + my($name, $contents) = @_; + + my $fh = new IO::File(">$name") + or die "can't create '$name': $!"; + $fh->print($contents); + $fh->close(); +} diff --git a/test/regression/queries.raw b/test/regression/queries.raw new file mode 100644 index 0000000..fd42750 --- /dev/null +++ b/test/regression/queries.raw @@ -0,0 +1,86 @@ +# Simple + +cat +"cat" +comp.os.linux +xml:element +"" +"=" +"prox/word/>=/5" +("cat") +((dog)) + +# index relation term + +title = "fish" +title exact fish +title any fish +title all fish +title > 9 +title >= 23 +dc.title any "fish chips" +dc.title any/stem fish +dc.fish all/stem/fuzzy "fish chips" +(title any frog) +((dc.title any/stem "frog pond")) + +# Simple Boolean + +cat or dog +cat and fish +cat not frog +(cat not frog) +"cat" not "fish food" +xml and "prox/word/" +a or b and c not d + +# I/R/T plus Boolean + +bath.author any fish and dc.title all "cat dog" +(title any/stem "fish dog" or "and") + +# Prox + +cat prox hat +cat prox/word/=/3/ordered hat +cat prox///3 hat +"fish food" prox/sentence "and" +title all "chips frog" prox/word//5 "any" +(dc.author exact "jones" prox///5 title >= "smith") +((cat prox hat)) + +# Special characters +(cat^) +"cat" +"^cat says \"fish\"" +"cat*fish" +cat?dog +(("^cat*fishdog\"horse?")) + +# Nesting Parens + +(((cat or dog) or horse) and frog) +(cat and dog) or (horse and frog) +(cat and (horse or frog)) and chips + +# Lame searches + +"any" or "all:stem" and "all" exact "any" prox/word "prox"="fuzzy" +((((((((("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 ()) +fred and any +((fred or all)) +sorry = (mike) diff --git a/test/regression/runtests b/test/regression/runtests new file mode 100755 index 0000000..977de06 --- /dev/null +++ b/test/regression/runtests @@ -0,0 +1,42 @@ +#!/usr/bin/perl -w + +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': $!"; + print " *** different XCQL output\n" + if $tested ne $correct; + } +} + +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; +} diff --git a/test/regression/showtest b/test/regression/showtest new file mode 100755 index 0000000..15e57b5 --- /dev/null +++ b/test/regression/showtest @@ -0,0 +1,14 @@ +#!/bin/sh + +if [ $# != 1 ]; then + echo "Usage: $0 " >&2 + echo " e.g. $0 01/02" >&2 + exit 1 +fi + +### Warning: nasty hard-coded choices +( echo "=== Adam ===" + ../../srw/cql/cqlparse3 < sections/$1.cql ) > /tmp/adam +( echo "=== Mike ===" + ../bin/CQLParser < sections/$1.cql ) > /tmp/mike +sdiff -w 80 /tmp/adam /tmp/mike diff --git a/test/runtests b/test/runtests deleted file mode 100755 index 977de06..0000000 --- a/test/runtests +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/perl -w - -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': $!"; - print " *** different XCQL output\n" - if $tested ne $correct; - } -} - -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; -} diff --git a/test/showtest b/test/showtest deleted file mode 100755 index 15e57b5..0000000 --- a/test/showtest +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -if [ $# != 1 ]; then - echo "Usage: $0 " >&2 - echo " e.g. $0 01/02" >&2 - exit 1 -fi - -### Warning: nasty hard-coded choices -( echo "=== Adam ===" - ../../srw/cql/cqlparse3 < sections/$1.cql ) > /tmp/adam -( echo "=== Mike ===" - ../bin/CQLParser < sections/$1.cql ) > /tmp/mike -sdiff -w 80 /tmp/adam /tmp/mike