More clean up, update readme
[cql-java-moved-to-github.git] / util / regression / README
1
2 If you just don't want to think about it
3 ----------------------------------------
4
5 Just use "make" to run regression tests.
6
7
8 CQL-Java's regression-testing framework
9 ---------------------------------------
10
11 "queries.raw" is the file of test queries as provided by Rob.
12 "mktests" parses the raw file into sections and individual queries
13 "sections" is the top-level directory created by that program.
14   "01", "02" etc. represent the sections within the raw file
15     "01/name", "02/name", etc. contain the names of the sections.
16     "01/01.cql", "01/02.cql" etc. are the CQL queries themselves.
17 "mkanswers" uses a trusted CQL compiler to generate corresponding XCQL.
18     "01/01.xcql", "01/02.xcql" etc. are the compiled XCQL queries.
19
20 Apart from the CQL files, all of the files described to this point are
21 included in the distribution, with the "trusted" XCQL output produced
22 by my own compiler, and used for regression testing of new versions.
23 The CQL files are re-created from "queries.raw" as required.  But
24 you're welcome to "make refclean" and rebuild it with mkanswers, to
25 contain the trusted compiler output of your choice.
26
27 "runtests" compares the output of a nominated CQL compiler with
28 existing XCQL files.  Most often, you'll use this to compare the
29 results of your own build of CQL-Java with those of my build.  I'll
30 use it to test new versions, and people who've written other compilers
31 can use it to test their code.  (The code of "runtests" and
32 "mkanswers" is worryingly similar: they should probably be the same
33 program invoked with different command-line arguments.)
34
35 "Makefile" controls the building of all this.  You'll need to edit it
36 if you want to use different compilers and suchlike from what's
37 written into it, so it may be easier to run the tests by hand -- but
38 it's a useful reference for the kinds of commands you might need,
39 anyway.  In general, "make" will run the regression tests, creating
40 whatever CQL and/or XCQL files it needs; if you do "make refclean"
41 first, then the next "make" will rebuild the reference results.
42
43 So, for example, if you think Rob Sanderson's parser, CQLParser.py, is
44 reliable, and you want to test my parser, CQL-Java's CQLParser class,
45 against its results, do this:
46
47         make refclean
48         ./mktests queries.raw
49         ./mkanswers CQLParser.py
50         ./runtests ../../bin/CQLParser ./xmlpp.pl
51
52 The second argument to ./runtests is the name of a program to use to
53 normalise XML, so that the trusted output and the output being tested
54 can be compared for equivalence rather than just for being
55 byte-identical.  (If you want to test for byte-identical XCQL, then
56 use "cat" as the second argument.)  xmlpp.pl is a fine XML
57 pretty-printer from DecisionSoft, found at
58         http://software.decisionsoft.com/tools.html
59
60 "showtest" can be used to run a single test showing more details of
61 what goes wrong, if anything.  You don't need it as part of the
62 regression test, but it's useful when debugging.
63
64 Finally, "runcanon" checks that each of the queries when compiled and
65 decompiled back to CQL (i.e. canonicalised) remains identical when
66 recompiled and redecompiled.
67
68
69 Appendix: queries that should fail
70 ----------------------------------
71
72 The following queries are included in Rob's master list, in a final
73 section called "Invalid searches [should error]".  They are all
74 expected to fail in various ways.  I've taken them out of
75 "queries.raw" because it's uninteresting, not to mention rather
76 disturbing, to watch compilers fail.  More important, I think, to
77 demonstrate correct behaviour for the known-to-work queries.
78
79 >
80 ===
81 cat or
82 index any 
83 index any/wrong term
84 a prox/wrong b
85 ()
86 (a
87 index any fish)
88 (cat any dog or ())
89 title = ("illegal parentheses")
90 "quoted" any "illegal quotes"
91 > illegal="urn:missingQuery"
92 "fish" and > illegal="urn:invalidPrefixLocation" "chips"