Merge lp:~zorba-coders/zorba/bug-992304-compile-only into lp:zorba

Proposed by Chris Hillery
Status: Merged
Approved by: Chris Hillery
Approved revision: 10811
Merged at revision: 11146
Proposed branch: lp:~zorba-coders/zorba/bug-992304-compile-only
Merge into: lp:zorba
Diff against target: 2885 lines (+12/-2758)
14 files modified
ChangeLog (+2/-0)
bin/test/mymod.xq (+1/-1)
src/compiler/api/compiler_api.cpp (+9/-8)
test/fots_driver/FOTSZorbaManifest.xml (+0/-66)
test/fots_driver/README.TXT (+0/-49)
test/fots_driver/cli.xq (+0/-197)
test/fots_driver/environment.xq (+0/-561)
test/fots_driver/errors.xq (+0/-36)
test/fots_driver/evaluate.xq (+0/-565)
test/fots_driver/fots-driver.xq (+0/-752)
test/fots_driver/reporting.xq (+0/-250)
test/fots_driver/tools/dependencies.xq (+0/-27)
test/fots_driver/tools/process.xq (+0/-127)
test/fots_driver/util.xq (+0/-119)
To merge this branch: bzr merge lp:~zorba-coders/zorba/bug-992304-compile-only
Reviewer Review Type Date Requested Status
Matthias Brantner Approve
Chris Hillery Approve
Review via email: mp+104194@code.launchpad.net

Commit message

Don't check the URI passed to FakeLibraryModuleURLResolver - just resolve it.

To post a comment you must log in.
Revision history for this message
Chris Hillery (ceejatec) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job bug-992304-compile-only-2012-05-01T01-25-03.331Z is finished. The final status was:

All tests succeeded!

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1, Needs Fixing < 1, Pending < 1. Got: 1 Approve.

Revision history for this message
Matthias Brantner (matthias-brantner) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Attempt to merge into lp:zorba failed due to conflicts:

text conflict in ChangeLog

10811. By Chris Hillery

Merge from trunk.

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job bug-992304-compile-only-2012-12-14T07-34-01.086Z is finished. The final status was:

All tests succeeded!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ChangeLog'
2--- ChangeLog 2012-12-12 08:11:40 +0000
3+++ ChangeLog 2012-12-14 07:31:21 +0000
4@@ -37,6 +37,8 @@
5 * Fixed bug #1021492 (while computeing the "sources" of a prolog var, skip
6 any var-setting exprs that appear in non-used (and non-optimized) functions).
7 * Fixed bug #1070551 (zerr:ZOSE0003 stream read failure)
8+ * Fixed bug #992304 (Compiling library modules could load data from
9+ wrong source)
10
11
12 version 2.7
13
14=== modified file 'bin/test/mymod.xq'
15--- bin/test/mymod.xq 2012-09-19 21:16:15 +0000
16+++ bin/test/mymod.xq 2012-12-14 07:31:21 +0000
17@@ -14,7 +14,7 @@
18 : limitations under the License.
19 :)
20
21-module namespace foo = "http://www.zorba-xquery.com/foo";
22+module namespace foo = "http://www.28msec.com/foo";
23
24 declare function foo:test() {
25 if (fn:true())
26
27=== modified file 'src/compiler/api/compiler_api.cpp'
28--- src/compiler/api/compiler_api.cpp 2012-12-06 22:49:35 +0000
29+++ src/compiler/api/compiler_api.cpp 2012-12-14 07:31:21 +0000
30@@ -398,11 +398,9 @@
31 {
32 public:
33 FakeLibraryModuleURLResolver(
34- zstring const& aLibraryModuleNamespace,
35 zstring const& aLibraryModuleFilename,
36 std::istream& aStream)
37 :
38- theLibraryModuleNamespace(aLibraryModuleNamespace),
39 theLibraryModuleFilename(aLibraryModuleFilename),
40 theStream(aStream)
41 {}
42@@ -414,10 +412,14 @@
43 const zstring& aUrl,
44 const internal::EntityData* aEntityData)
45 {
46- if (aUrl != theLibraryModuleNamespace)
47- {
48- return NULL;
49- }
50+ // Since we know this URL resolver will only be used when compiling the
51+ // stub query, and the only URI that query will contain is the one we're
52+ // interested in, then we don't actually need to check the URL at all -
53+ // just return the stream. This is a good thing, because due to URI
54+ // mapping, aUrl will probably be different than the one we're expecting.
55+ // If we returned NULL here, Zorba's built-in URL Resolvers would attempt
56+ // to load the resource from somewhere else, and that may result in the
57+ // wrong information being compiled. See bug 992304.
58 assert (theStream.good());
59 // Pass a nullptr StreamReleaser; memory ownership of the istream remains
60 // with the caller of this method.
61@@ -426,7 +428,6 @@
62 }
63
64 private:
65- zstring theLibraryModuleNamespace;
66 zstring theLibraryModuleFilename;
67 std::istream& theStream;
68 };
69@@ -462,7 +463,7 @@
70 aXQuery.seekg(0);
71
72 FakeLibraryModuleURLResolver* aFakeResolver =
73- new FakeLibraryModuleURLResolver(lib_namespace.str(), aFileName, aXQuery);
74+ new FakeLibraryModuleURLResolver(aFileName, aXQuery);
75
76 theCompilerCB->theRootSctx->add_url_resolver(aFakeResolver);
77
78
79=== removed directory 'test/fots_driver'
80=== removed file 'test/fots_driver/FOTSZorbaManifest.xml'
81--- test/fots_driver/FOTSZorbaManifest.xml 2012-11-14 14:02:58 +0000
82+++ test/fots_driver/FOTSZorbaManifest.xml 1970-01-01 00:00:00 +0000
83@@ -1,66 +0,0 @@
84-<?xml version="1.0" encoding="UTF-8"?>
85-<FOTS-test-suite-result xmlns="http://www.w3.org/2010/09/qt-fots-catalog">
86- <implementation name="Zorba" version="trunk" anonymous-result-column="false">
87- <organization name="http://www.zorba-xquery.com" anonymous="false"/>
88- <submitter name="Sorin Nasoi" email="spungi@gmail.com"/>
89- </implementation>
90- <dependencies-satisfied>
91- <dependency type="feature" value="collection-stability" satisfied="true"/> <!-- Is this correct? -->
92- <dependency type="feature" value="directory-as-collection-uri" satisfied="true"/> <!-- Is this correct? -->
93- <dependency type="feature" value="higherOrderFunctions" satisfied="false"/>
94- <dependency type="feature" value="moduleImport" satisfied="true"/>
95- <dependency type="feature" value="namespace-axis" satisfied="false"/> <!-- Is this correct? -->
96- <dependency type="feature" value="schema-location-hint" satisfied="false"/> <!-- Is this correct? -->
97- <dependency type="feature" value="schemaAware" satisfied="true"/>
98- <dependency type="feature" value="schemaImport" satisfied="true"/>
99- <dependency type="feature" value="schemaValidation" satisfied="true"/>
100- <dependency type="feature" value="staticTyping" satisfied="false"/>
101- <dependency type="feature" value="xpath-1.0-compatibility" satisfied="true"/> <!-- Is this correct? -->
102-
103- <dependency type="spec" value="XP10 XQ10" satisfied="true"/>
104- <dependency type="spec" value="XP10+" satisfied="true"/>
105- <dependency type="spec" value="XP20 XQ10" satisfied="true"/>
106- <dependency type="spec" value="XP20+" satisfied="true"/>
107- <dependency type="spec" value="XP30+" satisfied="true"/>
108- <dependency type="spec" value="XP30+ XQ10+" satisfied="true"/>
109- <dependency type="spec" value="XP30+ XQ30+" satisfied="true"/>
110- <dependency type="spec" value="XQ10" satisfied="true"/>
111- <dependency type="spec" value="XQ10 XP20" satisfied="true"/>
112- <dependency type="spec" value="XQ10+" satisfied="true"/>
113- <dependency type="spec" value="XQ10+ XP20+" satisfied="true"/>
114- <dependency type="spec" value="XQ10+ XP30+" satisfied="true"/>
115- <dependency type="spec" value="XQ30" satisfied="true"/>
116- <dependency type="spec" value="XQ30 XP30" satisfied="true"/>
117- <dependency type="spec" value="XQ30+" satisfied="true"/>
118- <dependency type="spec" value="XQ30+ XP30+" satisfied="true"/>
119- <dependency type="spec" value="XT30+" satisfied="false"/>
120-
121- <dependency type="xml-version" value="1.0" satisfied="true"/>
122- <dependency type="xml-version" value="1.0:4-" satisfied="true"/>
123- <dependency type="xml-version" value="1.0:5+ 1.1" satisfied="false"/>
124- <dependency type="xml-version" value="1.1" satisfied="false"/>
125-
126- <dependency type="language" value="de" satisfied="false"/> <!-- Is this correct? -->
127- <dependency type="language" value="en" satisfied="true"/>
128- <dependency type="language" value="xib" satisfied="false"/> <!-- Is this correct? -->
129-
130- <!-- Are these correct? -->
131- <dependency type="limits" value="year_lt_0" satisfied="true"/>
132- <dependency type="calendar" value="CB" satisfied="true"/>
133- <dependency type="format-integer-sequence" value="Α" satisfied="true"/>
134- <dependency type="format-integer-sequence" value="α" satisfied="true"/>
135- <dependency type="format-integer-sequence" value="١" satisfied="true"/>
136- <dependency type="format-integer-sequence" value="①" satisfied="true"/>
137- <dependency type="format-integer-sequence" value="⑴" satisfied="true"/>
138- <dependency type="format-integer-sequence" value="⒈" satisfied="true"/>
139- <dependency type="format-integer-sequence" value="一" satisfied="true"/>
140- <dependency type="format-integer-sequence" value="ﯴ" satisfied="true"/>
141- <dependency type="default-language" value="en" satisfied="true"/>
142- <dependency type="unicode-normalization-form" value="FULLY-NORMALIZED" satisfied="true"/>
143- <dependency type="unicode-normalization-form" value="NFD" satisfied="true"/>
144- <dependency type="unicode-normalization-form" value="NFKC" satisfied="true"/>
145- <dependency type="unicode-normalization-form" value="NFKD" satisfied="true"/>
146- <dependency type="xsd-version" value="1.0" satisfied="true"/>
147- <dependency type="xsd-version" value="1.1" satisfied="false"/>
148- </dependencies-satisfied>
149-</FOTS-test-suite-result>
150
151=== removed file 'test/fots_driver/README.TXT'
152--- test/fots_driver/README.TXT 2012-11-27 10:54:05 +0000
153+++ test/fots_driver/README.TXT 1970-01-01 00:00:00 +0000
154@@ -1,49 +0,0 @@
155-Information about the W3C XQuery/XPath/XSLT 3.* Test Suite can be found at:
156- http://dev.w3.org/2011/QT3-test-suite.
157-
158-In order to use the Zorba FOTS driver (written in XQuery) one has to follow
159-these steps:
160-
161-0) Build Zorba with ZORBA_WITH_BIG_INTEGER flag set to ON.
162-
163- For example with CMake:
164- cmake -DZORBA_WITH_BIG_INTEGER=ON ..
165- make
166-
167-1) Download the FOTS testsuite from W3C
168- Since currently there is no official release, a simple "cvs get" will do:
169-
170- $ export CVSROOT=":pserver:anonymous@dev.w3.org:/sources/public"
171- $ cvs login
172- (Logging in to anonymous@dev.w3.org)
173- CVS password: anonymous
174- $ cvs get 2011/QT3-test-suite
175-
176-3) run
177- ./zorba -f
178- -q ../../test/fots_driver/cli.xq
179-
180-Zorba FOTS driver usage examples:
181-If you run Zorba from a checkout of the trunk and the build/bin folder,
182-- /path/to/cli.xq can be set to ../../test/fots_driver/cli.xq
183-
184-Always try to output the result back to an XML file with nice indentation:
185-./zorba -f -q ../../test/fots_driver/cli.xq -e SET_CLI_OPTIONS_HERE -o output.xml --indent
186-
187- This way you will see trace information in the CLI window and detailed
188- results of the test cases in the 'output.xml'.
189-
190-zorba -f -q /path/to/cli.xq -e fotsPath:=/path/to/QT3-test-suite/catalog.xml -e fotsZorbaManifestPath:=/path/to/Zorba_manifest.xml -e mode:=list-test-sets
191-zorba -f -q /path/to/cli.xq -e fotsPath:=/path/to/QT3-test-suite/catalog.xml -e mode:=list-test-sets
192-zorba -f -q /path/to/cli.xq -e fotsPath:=/path/to/QT3-test-suite/catalog.xml -e mode:=list-test-sets -e testSetPrefixes:=prod,app
193-zorba -f -q /path/to/cli.xq -e fotsPath:=/path/to/QT3-test-suite/catalog.xml -e mode:=list-test-cases -e testSetPrefixes:=prod-Literal
194-zorba -f -q /path/to/cli.xq -e fotsPath:=/path/to/QT3-test-suite/catalog.xml -e mode:=list-test-cases -e dependency:=higherOrderFunctions
195-zorba -f -q /path/to/cli.xq -e fotsPath:=/path/to/QT3-test-suite/catalog.xml -e mode:=list-matching-test-cases -e pattern:=catch
196-zorba -f -q /path/to/cli.xq -e fotsPath:=/path/to/QT3-test-suite/catalog.xml -e mode:=run-test-sets -e testSetPrefixes:=prod -o result.xml --indent
197-zorba -f -q /path/to/cli.xq -e fotsPath:=/path/to/QT3-test-suite/catalog.xml -e mode:=run-test-sets -e testSetPrefixes:=prod -e dependency:=higherOrderFunctions_false -o result.xml --indent
198-zorba -f -q /path/to/cli.xq -e fotsPath:=/path/to/QT3-test-suite/catalog.xml -e mode:=run-test-sets -e testSetPrefixes:=prod-Literal -e verbose:=false -o result.xml --indent
199-zorba -f -q /path/to/cli.xq -e fotsPath:=/path/to/QT3-test-suite/catalog.xml -e mode:=run-test-case -e testSetName:=prod-Literal -e testCaseName:=Literals001 -o result.xml --indent
200-zorba -f -q /path/to/cli.xq -e fotsPath:=/path/to/QT3-test-suite/catalog.xml -e mode:=run-test-case -e assertType:=assert-count -e testSetName:=fn-innermost -o result.xml --indent
201-zorba -f -q /path/to/cli.xq -e fotsPath:=/path/to/QT3-test-suite/catalog.xml -e mode:=run-test-case -e assertType:=assert-count -o result.xml --indent
202-zorba -f -q /path/to/cli.xq -e fotsPath:=/path/to/QT3-test-suite/catalog.xml -e mode:=run-and-report -o report.xml --indent
203-zorba -f -q /path/to/cli.xq -e fotsPath:=/path/to/QT3-test-suite/catalog.xml -e mode:=report -e failuresFilePath:=failures.xml -e verbose:=false -o report.xml --indent
204
205=== removed file 'test/fots_driver/cli.xq'
206--- test/fots_driver/cli.xq 2012-11-27 10:54:05 +0000
207+++ test/fots_driver/cli.xq 1970-01-01 00:00:00 +0000
208@@ -1,197 +0,0 @@
209-(:
210- : Copyright 2006-2011 The FLWOR Foundation.
211- :
212- : Licensed under the Apache License, Version 2.0 (the "License");
213- : you may not use this file except in compliance with the License.
214- : You may obtain a copy of the License at
215- :
216- : http://www.apache.org/licenses/LICENSE-2.0
217- :
218- : Unless required by applicable law or agreed to in writing, software
219- : distributed under the License is distributed on an "AS IS" BASIS,
220- : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
221- : See the License for the specific language governing permissions and
222- : limitations under the License.
223- :)
224-
225-(:~
226- : Zorba FOTS driver CLI
227- : @author Ghislain Fourny, Sorin Nasoi
228- :)
229-
230-import module namespace d =
231- "http://www.zorba-xquery.com/fots-driver" at "fots-driver.xq";
232-import module namespace r =
233- "http://www.zorba-xquery.com/fots-driver/reporting" at "reporting.xq";
234-
235-(:~ path to the place where FOTS can be found :)
236-declare variable $fotsPath as xs:string external := "";
237-
238-(:~ path to the place where the FOTS Zorba manifest can be found :)
239-declare variable $fotsZorbaManifestPath as xs:string external :=
240- "FOTSZorbaManifest.xml";
241-
242-(:~ Path to the results from a previous run :)
243-declare variable $failuresFilePath as xs:string external := "";
244-
245-(:~ choose the CLI option you want to run :)
246-declare variable $mode as xs:string external := "";
247-
248-(:~ name/criteria for the test sets :)
249-declare variable $testSetPrefixes as xs:string external := "";
250-
251-(:~ name/criteria for the test cases :)
252-declare variable $testCasePrefixes as xs:string external := "";
253-
254-(:~ name for the test set :)
255-declare variable $testSetName as xs:string external := "";
256-
257-(:~ name for the test case :)
258-declare variable $testCaseName as xs:string external := "";
259-
260-(:~ Enable or disable verbose output :)
261-declare variable $verbose as xs:string external := "true";
262-
263-(:~
264- Enable or disable showing the actual query result in the output.
265- True by default.
266-:)
267-declare variable $showResult as xs:string external := "true";
268-
269-(:~ assertion type :)
270-declare variable $assertType as xs:string external := "";
271-
272-(:~ dependency: used in 'list-test-cases' and 'run-test-sets' modes:)
273-declare variable $dependency as xs:string external := "";
274-
275-(:~ regex for the tests in the 'list-matching-test-cases' option :)
276-declare variable $pattern as xs:string external := "";
277-
278-(:~ flags for the tests in the 'list-matching-test-cases' option :)
279-declare variable $flags as xs:string external := "";
280-
281-(:~ Tokenize comma or empty string :)
282-declare %private function local:tokenize(
283- $input as xs:string
284-) as xs:string*
285-{
286- let $tokens := tokenize($input, ",")
287- return if (exists($tokens)) then $tokens else ""
288-};
289-
290-declare function local:usage() as xs:string
291-{
292- string-join((
293- "Zorba FOTS driver usage examples:",
294- "If you run Zorba from a checkout of the trunk and the build/bin folder,",
295- "- /path/to/cli.xq can be set to ../../test/fots_driver/cli.xq",
296- "",
297- "Always try to output the result back to an XML file with nice indentation:",
298- "./zorba -f -q ../../test/fots_driver/cli.xq -e SET_CLI_OPTIONS_HERE -o output.xml --indent",
299- "",
300- " This way you will see trace information in the CLI window and detailed",
301- " results of the test cases in the 'output.xml'.",
302- "",
303- "zorba -f -q /path/to/cli.xq -e fotsPath:=/path/to/QT3-test-suite/catalog.xml -e fotsZorbaManifestPath:=/path/to/Zorba_manifest.xml -e mode:=list-test-sets",
304- "zorba -f -q /path/to/cli.xq -e fotsPath:=/path/to/QT3-test-suite/catalog.xml -e mode:=list-test-sets",
305- "zorba -f -q /path/to/cli.xq -e fotsPath:=/path/to/QT3-test-suite/catalog.xml -e mode:=list-test-sets -e testSetPrefixes:=prod,app",
306- "zorba -f -q /path/to/cli.xq -e fotsPath:=/path/to/QT3-test-suite/catalog.xml -e mode:=list-test-cases -e testSetPrefixes:=prod-Literal",
307- "zorba -f -q /path/to/cli.xq -e fotsPath:=/path/to/QT3-test-suite/catalog.xml -e mode:=list-test-cases -e dependency:=higherOrderFunctions",
308- "zorba -f -q /path/to/cli.xq -e fotsPath:=/path/to/QT3-test-suite/catalog.xml -e mode:=list-matching-test-cases -e pattern:=catch",
309- "zorba -f -q /path/to/cli.xq -e fotsPath:=/path/to/QT3-test-suite/catalog.xml -e mode:=run-test-sets -e testSetPrefixes:=prod -o result.xml --indent",
310- "zorba -f -q /path/to/cli.xq -e fotsPath:=/path/to/QT3-test-suite/catalog.xml -e mode:=run-test-sets -e testSetPrefixes:=prod -e dependency:=higherOrderFunctions_false -o result.xml --indent",
311- "zorba -f -q /path/to/cli.xq -e fotsPath:=/path/to/QT3-test-suite/catalog.xml -e mode:=run-test-sets -e testSetPrefixes:=prod-Literal -e verbose:=false -o result.xml --indent",
312- "zorba -f -q /path/to/cli.xq -e fotsPath:=/path/to/QT3-test-suite/catalog.xml -e mode:=run-test-case -e testSetName:=prod-Literal -e testCaseName:=Literals001 -o result.xml --indent",
313- "zorba -f -q /path/to/cli.xq -e fotsPath:=/path/to/QT3-test-suite/catalog.xml -e mode:=run-test-case -e assertType:=assert-count -e testSetName:=fn-innermost -o result.xml --indent",
314- "zorba -f -q /path/to/cli.xq -e fotsPath:=/path/to/QT3-test-suite/catalog.xml -e mode:=run-test-case -e assertType:=assert-count -o result.xml --indent",
315- "zorba -f -q /path/to/cli.xq -e fotsPath:=/path/to/QT3-test-suite/catalog.xml -e mode:=run-and-report -o report.xml --indent",
316- "zorba -f -q /path/to/cli.xq -e fotsPath:=/path/to/QT3-test-suite/catalog.xml -e mode:=report -e failuresFilePath:=failures.xml -e verbose:=false -o report.xml --indent",
317- ""
318- ), "&#xA;")
319-};
320-
321-(:~ The test cases in this list have bugs assigned and should not be run :)
322-variable $exceptedTestCases := (
323-"cbcl-subsequence-011", "cbcl-subsequence-012", "cbcl-subsequence-013",
324-"cbcl-subsequence-014" (:see bug lp:1069794 :)
325-, "re00975", "re00976", "re00976a" (:see bug lp:1070533 :)
326-, "fn-unparsed-text-lines-052" (:see bug lp:1073175 :)
327-);
328-
329-(:~ The test in this list have bugs assigned already and should not be run :)
330-variable $exceptedTestSets := ();
331-
332-switch ($mode)
333-case "list-test-sets"
334- return
335- string-join(
336- (d:list-test-sets(
337- trace($fotsPath, "Path to FOTS catalog.xml set to: "),
338- local:tokenize(trace($testSetPrefixes, "'testSetPrefixes' set to: ")))),
339- "&#xA;")
340-case "list-test-cases"
341- return
342- string-join(
343- (d:list-test-cases( trace($fotsPath,
344- "Path to FOTS catalog.xml set to: "),
345- local:tokenize(trace($testSetPrefixes,
346- "'testSetPrefixes' set to: ")),
347- "",
348- trace($dependency,
349- "'dependency' set to:"))),
350- "&#xA;")
351-case "list-matching-test-cases"
352- return string-join((d:list-matching-test-cases(
353- trace($fotsPath,
354- "Path to FOTS catalog.xml set to: "),
355- trace($pattern,
356- "pattern set to: "),
357- trace($flags,
358- "flags were set to: ")), ""),
359- "&#xA;")
360-case "run-test-sets"
361- return d:run-fots($fotsPath,
362- $fotsZorbaManifestPath,
363- d:list-test-sets($fotsPath,
364- local:tokenize(trace($testSetPrefixes,
365- "'testSetPrefixes' set to: "))),
366- d:list-test-cases($fotsPath,
367- local:tokenize($testSetPrefixes),
368- local:tokenize(trace($testCasePrefixes,
369- "'$testCasePrefixes' set to: ")),
370- trace($dependency,
371- "'dependency' set to:")),
372- $exceptedTestCases,
373- $exceptedTestSets,
374- $assertType,
375- xs:boolean($verbose),
376- xs:boolean($showResult))
377-case "run-test-case"
378- return d:run-fots($fotsPath,
379- $fotsZorbaManifestPath,
380- trace($testSetName,"'testSetName' set to: "),
381- trace($testCaseName,"'testCaseName' set to: "),
382- $exceptedTestCases,
383- $exceptedTestSets,
384- trace($assertType,"'assertType' set to: "),
385- xs:boolean($verbose),
386- xs:boolean($showResult))
387-case "run-and-report"
388- return r:run-and-report($fotsPath,
389- $fotsZorbaManifestPath,
390- d:list-test-sets($fotsPath,
391- local:tokenize($testSetPrefixes)),
392- '',
393- $exceptedTestCases,
394- $exceptedTestSets,
395- $assertType,
396- fn:false(), (: the reports to W3C are always generated with verbose set to false:)
397- xs:boolean($showResult))
398-case "report"
399- return r:report($fotsPath,
400- $failuresFilePath,
401- $exceptedTestCases,
402- $exceptedTestSets,
403- xs:boolean($verbose))
404-default
405- return local:usage()
406
407=== removed file 'test/fots_driver/environment.xq'
408--- test/fots_driver/environment.xq 2012-11-20 07:32:15 +0000
409+++ test/fots_driver/environment.xq 1970-01-01 00:00:00 +0000
410@@ -1,561 +0,0 @@
411-(:
412- : Copyright 2006-2011 The FLWOR Foundation.
413- :
414- : Licensed under the Apache License, Version 2.0 (the "License");
415- : you may not use this file except in compliance with the License.
416- : You may obtain a copy of the License at
417- :
418- : http://www.apache.org/licenses/LICENSE-2.0
419- :
420- : Unless required by applicable law or agreed to in writing, software
421- : distributed under the License is distributed on an "AS IS" BASIS,
422- : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
423- : See the License for the specific language governing permissions and
424- : limitations under the License.
425- :)
426-
427-(:~
428- : Zorba FOTS driver environment
429- : @author Sorin Nasoi
430- :)
431-
432-module namespace env =
433- "http://www.zorba-xquery.com/fots-driver/environment";
434-
435-import module namespace xqxq =
436- "http://www.zorba-xquery.com/modules/xqxq";
437-import module namespace util =
438- "http://www.zorba-xquery.com/fots-driver/util" at "util.xq";
439-
440-declare namespace fots =
441- "http://www.w3.org/2010/09/qt-fots-catalog";
442-
443-declare namespace ann =
444- "http://www.zorba-xquery.com/annotations";
445-
446-
447-declare variable $env:hof as xs:string :=
448- string-join(
449- ( "declare namespace op = 'http://www.zorba-xquery.com/options/features';",
450- "declare namespace f = 'http://www.zorba-xquery.com/features';",
451- "declare option op:enable 'f:hof';"),
452- "&#xA;");
453-
454-
455-(:~
456- : If there is a dependency on XQuery 3.0 and there is at least one HOF
457- : function in the test, return the strings for enabling the HOF feature.
458- :
459- : @param $deps the dependencies of the test set and test case
460- : @param $test the Query test.
461- : @return the strings for enabling the HOF feature
462- :)
463-declare function env:enable-HOF-feature(
464- $deps as element(fots:dependency)*,
465- $test as xs:string
466-) as xs:string?
467-{
468- let $depSpec := string-join(distinct-values( for $dep in $deps
469- where $dep[@type="spec"]
470- return data($dep/@value)),""),
471- $depFeature := string-join(distinct-values(for $dep in $deps
472- where $dep[@type="feature"]
473- return data($dep/@value)),"")
474- return
475- if ((contains($depSpec,"XQ30") or contains($depSpec,"XP30")) and
476- contains($depFeature,"higherOrderFunctions"))
477- then $env:hof else ()
478-};
479-
480-
481-(:~
482- : Check if an XQuery version declaration needs to be added.
483- :
484- : @param $deps the dependencies of the test set and test case.
485- : @param $test the Query test.
486- : @return the XQuery version declaration.
487- :)
488-declare function env:add-xquery-version-decl(
489- $deps as element(fots:dependency)*,
490- $test as xs:string
491-) as xs:string?
492-{
493- let $dependencies := string-join(distinct-values(for $dep in $deps
494- where $dep[@type="spec"]
495- return data($dep/@value)),"")
496- return
497- if ((contains($dependencies,"XQ30") or contains($dependencies,"XP30")) and
498- not(contains($test, "xquery version ")))
499- then 'xquery version "3.0";'
500- else if(contains($dependencies,"XQ10") and
501- not(contains($test, "xquery version ")))
502- then 'xquery version "1.0";'
503- else ()
504-};
505-
506-
507-(:~
508- : Sets the declared default element namespace.
509- :
510- : @param $env the environment of the catalog/test-set (given with 'ref').
511- : @param $envCase the environment of the test-case.
512- : @return the declare default element namespace.
513- :)
514-declare function env:decl-def-elem-namespace(
515- $env as element(fots:environment)?,
516- $envCase as element(fots:environment)?
517-) as xs:string?
518-{
519- for $ns in ($env/fots:namespace, $envCase/fots:namespace)
520- where $ns[@prefix=""]
521- return concat('declare default element namespace "',
522- data($ns/@uri),
523- '";')
524-};
525-
526-
527-(:~
528- : Adds the declare namespace statements.
529- :
530- : @param $env the environment of the catalog/test-set (given with 'ref').
531- : @param $case the test-case.
532- : @param $testSetBaseURI the URI of the test set file.
533- : @return the declare namespace statements.
534- :)
535-declare %ann:nondeterministic function env:decl-namespaces(
536- $env as element(fots:environment)?,
537- $case as element(fots:test-case),
538- $testSetBaseURI as xs:anyURI
539-) as xs:string?
540-{
541- string-join(
542- for $ns in ($env/fots:namespace, $case/fots:environment/fots:namespace)
543- where not($ns[@prefix=""]) and
544- not(env:is-schema-prefix-bound(data($ns/@prefix),
545- $case,
546- $testSetBaseURI))
547- return concat('declare namespace ',
548- data($ns/@prefix),
549- ' = "',
550- data($ns/@uri),
551- '";')
552- ," ")
553-};
554-
555-
556-(:~
557- : Return true if the prefix will be bound to a schema in the Query
558- : It's a bug in the FOTS if this function returns true: TODO report to W3C
559- :)
560-declare %private %ann:nondeterministic function env:is-schema-prefix-bound(
561- $prefix as xs:string,
562- $case as element(fots:test-case),
563- $testSetBaseURI as xs:anyURI
564-) as xs:boolean
565-{
566- contains(util:get-value($case,
567- $testSetBaseURI,
568- "test"),
569- concat("import schema namespace ",
570- $prefix))
571-};
572-
573-
574-(:~
575- : Returns the the declare base-uri prolog statement.
576- :
577- : @param $env the environment of the catalog/test-set (given with 'ref').
578- : @param $envCase the environment of the test-case.
579- : @return the declare base-uri prolog statement.
580- :)
581-declare function env:decl-base-uri(
582- $env as element(fots:environment)?,
583- $envCase as element(fots:environment)?
584-) as xs:string?
585-{
586- for $baseURI in ($env/fots:static-base-uri, $envCase/fots:static-base-uri)
587- return concat("declare base-uri '",
588- data($baseURI/@uri),
589- "';")
590-};
591-
592-
593-(:~
594- : Add the decimal format declarations.
595- :
596- : @param $decimal-formats decimal formats.
597- : @return the decimal formats declarations.
598- :)
599-declare function env:decl-decimal-formats(
600- $decimal-formats as element(fots:decimal-format)*
601-) as xs:string*
602-{
603- if(empty($decimal-formats))
604- then ()
605- else
606- for $tmp in $decimal-formats
607- let $default := if(exists($tmp/@name))
608- then ()
609- else "default"
610- let $name := if(exists($tmp/@name))
611- then data($tmp/@name)
612- else ()
613- return
614- string-join(("declare",
615- $default,
616- "decimal-format",
617- $name,
618- env:set-properties($tmp),
619- ";"),' ')
620-};
621-
622-
623-declare %private function env:set-properties(
624- $decimal-format as element(fots:decimal-format)
625-) as xs:string*
626-{
627- for $att in $decimal-format/attribute::*
628- let $name := node-name($att)
629- let $value := data($att)
630- return
631- if(exists(index-of(("decimal-separator", "grouping-separator", "infinity",
632- "minus-sign", "NaN", "percent", "per-mille",
633- "zero-digit", "digit", "pattern-separator"),
634- xs:string($name))))
635- then concat($name, '="' , $value, '"')
636- else ()
637-};
638-
639-
640-(:~
641- : Adds the variable declarations.
642- : @param $env environment.
643- : @param $case test case.
644- : @param $envBaseURI the relative URI for the environment.
645- : @param $testSetBaseURI the URI of the test set.
646- : @return the variable declarations.
647- :)
648-declare %ann:nondeterministic function env:add-var-decl(
649- $env as element(fots:environment)?,
650- $case as element(fots:test-case),
651- $envBaseURI as xs:anyURI,
652- $testSetBaseURI as xs:anyURI
653-) as xs:string?
654-{
655- concat( env:var-decl-with-value($env,
656- $envBaseURI),
657- env:var-decl-with-value($case/fots:environment,
658- $testSetBaseURI),
659- env:var-decl-without-value($env,
660- $case/fots:environment))
661-};
662-
663-
664-declare %private function env:var-decl-with-value(
665- $env as element(fots:environment)?,
666- $baseURI as xs:anyURI
667-) as xs:string?
668-{
669- string-join(
670- for $param in $env/fots:param
671- let $select := $param/@select
672- let $file := $env/fots:source[@uri = translate($select, "'", "")]/@file
673- let $type := $param/@as
674- let $varValue := if(starts-with($select, "'") and
675- ends-with($select, "'") and
676- exists($file))
677- then concat('"',
678- resolve-uri($file, $baseURI),
679- '"')
680- else $select
681- where (exists($select) and
682-(: if there is an attribute 'declared' set to true, this means that the variable
683- is declared within the 'test' itself so no additional variable declaration
684- is needed :)
685- empty($param[@declared="true"]))
686- return concat("declare variable $",
687- $param/@name,
688- ((concat(" as ", $type)))[$type],
689- " := ",
690- $varValue,
691- ";")
692- ," ")
693-};
694-
695-
696-declare %private function env:var-decl-without-value(
697- $env as element(fots:environment)?,
698- $envCase as element(fots:environment)?
699-) as xs:string?
700-{
701- string-join(
702- (for $param in ($env/fots:param, $envCase/fots:param)
703- let $select := $param/@select
704- let $type := $param/@as
705- where (empty($select) and
706- empty($param[@declared="true"]))
707- return concat("declare variable $",
708- $param/@name,
709- ((concat(" as ", $type)))[$type],
710- " external;"),
711- for $source in ($env/fots:source, $envCase/fots:source)
712- let $role := $source/@role
713- where starts-with($role,"$")
714- return concat("declare variable ",
715- $role,
716- " external;"))
717- ," ")
718-};
719-
720-
721-(:~
722- : Returns the string for setting the context item if needed.
723- : @param $env environment.
724- : @param $envBaseURI test base URI of the environment.
725- : @return the string for setting the context item if needed.
726- :)
727-declare function env:set-context-item(
728- $env as element(fots:environment)?,
729- $envBaseURI as xs:anyURI?
730-) as xs:string? {
731- if (exists($env/fots:source[@role = "."]))
732- then string-join((env:declare-context-item($env, $envBaseURI),
733- 'xqxq:bind-context-item($queryID, $contextItem);')
734- ,"&#xA;")
735- else ()
736-};
737-
738-
739-declare %private function env:declare-context-item(
740- $env as element(fots:environment)?,
741- $envBaseURI as xs:anyURI?
742-) as xs:string
743-{
744- let $ciURI := resolve-uri($env/fots:source[@role = "."]/@file, $envBaseURI)
745- return
746- if(empty($env/fots:source[@validation = "strict"]))
747- then concat('variable $contextItem := doc("', $ciURI, '");')
748- else string-join(
749- ("&#xA;",
750- "variable $contextItemQuery := xqxq:prepare-main-module('",
751- env:get-schema-import($env),
752- concat('validate { doc("', $ciURI, '")', "}',", " "),
753- "resolver:url-resolver#2, ());",
754- "variable $contextItem := xqxq:evaluate($contextItemQuery);")
755- ,"&#xA;")
756-};
757-
758-
759-(:~
760- : Returns the strings for variable binding in XQXQ.
761- :
762- : @param $env the environment of the catalog/test-set (given with 'ref').
763- : @param $envBaseURI the relative URI for the environment.
764- : @return the strings for variable binding in XQXQ.
765- :)
766-declare function env:set-variables(
767- $env as element(fots:environment)?,
768- $envBaseURI as xs:anyURI
769-) as xs:string?
770-{
771- if(empty($env))
772- then ()
773- else
774- let $srcNames := for $source in $env/fots:source
775- where starts-with(data($source/@role),"$")
776- return substring-after(data($source/@role),"$"),
777- $srcValues := for $srcName in $srcNames
778- return concat('doc("',
779- resolve-uri($env/fots:source[@role = concat("$",$srcName)]/@file, $envBaseURI),
780- '")')
781- return
782- string-join(
783- (for $srcName in $srcNames
784- let $index := index-of($srcNames, $srcName)
785- return
786- concat('xqxq:bind-variable( $queryID, xs:QName("', $srcName, '")', ', ',
787- $srcValues[$index], ');'),
788- for $param in $env/fots:param
789- let $select:= $param/@select
790- let $file := $env/fots:source[@uri = translate($select, "'", "")]/@file
791- let $varValue := if(starts-with($select, "'") and
792- ends-with($select, "'") and
793- exists($file))
794- then concat('"',
795- resolve-uri($file, $envBaseURI),
796- '"')
797- else $select
798- let $varName := $param/@name
799- where (exists($select) and
800-(: if there is an attribute 'declared' set to true, this means that the variable
801- is declared within the 'test' itself :)
802- exists($param[@declared="true"]))
803- return
804- concat('xqxq:bind-variable( $queryID, xs:QName("',
805- $param/@name,
806- '")', ', ',
807- $varValue, ');'))
808- , "&#xA;")
809-};
810-
811-
812-declare %private function env:get-schema-import (
813- $env as element(fots:environment)?
814-) as xs:string
815-{
816- if (empty($env))
817- then ""
818- else
819- let $namespace := $env/fots:namespace[@uri = data($env/fots:schema/@uri)]
820- let $prefix as xs:string := if(exists($namespace))
821- then xs:string(data($namespace/@prefix))
822- else "p"
823- return
824- if($prefix = "")
825- then concat('import schema default element namespace "',
826- $env/fots:schema/@uri,
827- '";&#xA;')
828- else concat('import schema namespace ',
829- $prefix,
830- ' = "',
831- $env/fots:schema/@uri,
832- '";&#xA;')
833-};
834-
835-
836-(:~
837- : Returns the XQXQ URL resolver declaration.
838- : @param $case the test case.
839- : @param $env the environment.
840- : @param $envBaseURI URI of the environment.
841- : @param $testSetBaseURI URI to the test set that defines the test case.
842- : @return the XQXQ URL resolver declaration.
843- :)
844-declare function env:resolver(
845- $case as element(fots:test-case),
846- $env as element(fots:environment)?,
847- $envBaseURI as xs:anyURI?,
848- $testSetBaseURI as xs:anyURI
849-) as xs:string?
850-{
851- let $envSchema := $env/fots:schema,
852- $tcSchema := $case/fots:environment/fots:schema,
853- $schemas := ($envSchema, $tcSchema),
854- $modules := $case/fots:module,
855- $resources := ($env/fots:resource, $case/fots:environment/fots:schema)
856- return
857- if (empty($schemas) and empty($modules) and empty($resources))
858- then ()
859- else string-join(
860- ("declare namespace resolver = 'http://www.zorba-xquery.com/modules/xqxq/url-resolver';",
861- $env:hof,
862- "declare function resolver:url-resolver($namespace as xs:string, $entity as xs:string) {",
863- "switch($entity)",
864- if (exists($schemas))
865- then string-join(("case 'schema'",
866- " return switch($namespace)",
867- (for $schema in $envSchema
868- return concat(" case '",
869- data($schema/@uri),
870- "' return doc('",
871- resolve-uri($schema/@file, $envBaseURI),
872- "')"),
873- for $schema in $tcSchema
874- return concat(" case '",
875- data($schema/@uri),
876- "' return doc('",
877- resolve-uri($schema/@file, $testSetBaseURI),
878- "')")),
879- " default return ()"),
880- "&#xA;")
881- else (),
882- if (exists($modules))
883- then string-join(("case 'module'",
884- " return switch($namespace)",
885- for $module in $modules
886- return concat(" case '",
887- data($module/@uri),
888- "' return unparsed-text('",
889- resolve-uri($module/@file, $testSetBaseURI),
890- "') "),
891- " default return ()"),
892- "&#xA;")
893- else (),
894- if (exists($resources)) then
895- string-join(("case ''",
896- " return switch($namespace)",
897- for $resource in $resources
898- return concat(" case '",
899- data($resource/@uri),
900- "' return unparsed-text('",
901- resolve-uri($resource/@file, $envBaseURI),
902- "'",
903- if(exists($resource/@encoding))
904- then concat (",'",
905- data($resource/@encoding),
906- "'")
907- else (),
908- ") "),
909- " default return ()")
910- ,"&#xA;")
911- else ()
912- , "default return ()","};"),
913- "&#xA;")
914-};
915-
916-
917-(:~
918- : Checks the dependencies according to the Zorba manifest.
919- :
920- : @param $deps the dependencies of the test set and test case
921- : @param $zorbaManifest Zorba manifest document.
922- : @return if true empty string, otherwise returns a string with the
923- : dependencies that were not matched.
924- :)
925-declare function env:check-dependencies(
926- $deps as element(fots:dependency)*,
927- $zorbaManifest
928-) as xs:string*
929-{
930- if(empty($deps))
931- then ()
932- else
933- for $dep in $deps
934- let $satisfied := if(exists($dep/@satisfied))
935- then data($dep/@satisfied)
936- else "true"
937- let $zorbaDep := $zorbaManifest//fots:dependency[ @type = $dep/@type and
938- @value = $dep/@value and
939- @satisfied = $satisfied]
940- return
941- if(empty($zorbaDep))
942- then concat("Dependency (type=",
943- $dep/@type,
944- ", value=",
945- $dep/@value,
946- ", satisfied=",
947- $satisfied,
948- ") was not met. ")
949- else ()
950-};
951-
952-
953-(:~
954- : Retrieves the environment from a test-set/catalog given an environment name.
955- : @param $catalog FOTS catalog file.
956- : @param $testSet test set.
957- : @param $envName name of the environment.
958- : @return the environment with the given name.
959- :)
960-declare function env:get-environment (
961- $catalog,
962- $testSet as element (fots:test-set),
963- $envName as xs:string
964-) as element(fots:environment)?
965-{
966- let $envTestSet := $testSet/test-set//environment[@name = $envName]
967- return
968- if (empty($envTestSet))
969- then $catalog/catalog//environment[@name = $envName]
970- else $envTestSet
971-};
972
973=== removed file 'test/fots_driver/errors.xq'
974--- test/fots_driver/errors.xq 2012-11-14 14:02:58 +0000
975+++ test/fots_driver/errors.xq 1970-01-01 00:00:00 +0000
976@@ -1,36 +0,0 @@
977-(:
978- : Copyright 2006-2011 The FLWOR Foundation.
979- :
980- : Licensed under the Apache License, Version 2.0 (the "License");
981- : you may not use this file except in compliance with the License.
982- : You may obtain a copy of the License at
983- :
984- : http://www.apache.org/licenses/LICENSE-2.0
985- :
986- : Unless required by applicable law or agreed to in writing, software
987- : distributed under the License is distributed on an "AS IS" BASIS,
988- : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
989- : See the License for the specific language governing permissions and
990- : limitations under the License.
991- :)
992-
993-(:~
994- : Zorba FOTS driver errors
995- : @author Sorin Nasoi
996- :)
997-
998-module namespace err =
999- "http://www.zorba-xquery.com/fots-driver/errors";
1000-
1001-(:~
1002- : Errors namespace URI.
1003-:)
1004-declare variable $err:errNS as xs:string :=
1005- "http://www.zorba-xquery.com/fots-driver/errors";
1006-
1007-(:~
1008- : xs:QName with
1009- : namespace URI = "http://www.w3.org/2010/09/qt-fots-catalog/errors"
1010- : and local name "err:errNA"
1011-:)
1012-declare variable $err:errNA as xs:QName := fn:QName($err:errNS, "check:errNA");
1013
1014=== removed file 'test/fots_driver/evaluate.xq'
1015--- test/fots_driver/evaluate.xq 2012-11-19 07:08:11 +0000
1016+++ test/fots_driver/evaluate.xq 1970-01-01 00:00:00 +0000
1017@@ -1,565 +0,0 @@
1018-(:
1019- : Copyright 2006-2011 The FLWOR Foundation.
1020- :
1021- : Licensed under the Apache License, Version 2.0 (the "License");
1022- : you may not use this file except in compliance with the License.
1023- : You may obtain a copy of the License at
1024- :
1025- : http://www.apache.org/licenses/LICENSE-2.0
1026- :
1027- : Unless required by applicable law or agreed to in writing, software
1028- : distributed under the License is distributed on an "AS IS" BASIS,
1029- : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1030- : See the License for the specific language governing permissions and
1031- : limitations under the License.
1032- :)
1033-
1034-(:~
1035- : Zorba FOTS driver evaluate
1036- : @author Sorin Nasoi
1037- :)
1038-
1039-module namespace eval =
1040- "http://www.zorba-xquery.com/fots-driver/evaluate";
1041-
1042-import schema namespace output =
1043- "http://www.w3.org/2010/xslt-xquery-serialization";
1044-
1045-import module namespace xqxq =
1046- "http://www.zorba-xquery.com/modules/xqxq";
1047-import module namespace schema =
1048- "http://www.zorba-xquery.com/modules/schema";
1049-
1050-import module namespace fots-err =
1051- "http://www.zorba-xquery.com/fots-driver/errors" at "errors.xq";
1052-import module namespace util =
1053- "http://www.zorba-xquery.com/fots-driver/util" at "util.xq";
1054-
1055-declare namespace err =
1056- "http://www.w3.org/2005/xqt-errors";
1057-declare namespace fots =
1058- "http://www.w3.org/2010/09/qt-fots-catalog";
1059-
1060-declare namespace ann =
1061- "http://www.zorba-xquery.com/annotations";
1062-
1063-declare namespace features =
1064- "http://www.zorba-xquery.com/options/features";
1065-declare option features:enable "hof";
1066-
1067-(:~
1068- : Checks if the result matches the assertions.
1069- : @param $result actual result.
1070- : @param $expResult expected result.
1071- : @param $showResult is true the verbose mode is assumed.
1072- : @return the results of assertion evaluations.
1073- :)
1074-declare %ann:sequential function eval:result(
1075- $result as item()*,
1076- $expResult as element(),
1077- $showResult as xs:boolean?
1078-) as element()? {
1079- let $err := eval:check-assertion($result,
1080- $expResult,
1081- (),
1082- "",
1083- $showResult)
1084- return if(empty($err))
1085- then ()
1086- else
1087- <out>
1088- <expected-result>{$expResult}</expected-result>
1089- {
1090- if($showResult)
1091- then (<result>{$result}</result>,
1092- <errors>{$err}</errors>)
1093- else ()
1094- }
1095- </out>
1096-};
1097-
1098-(:~
1099- : Checks if the error found matches the expected error (if any).
1100- : @param $result actual result.
1101- : @param $expResult expected result.
1102- : @param $code err:code.
1103- : @param $errorDescription err:description.
1104- : @param $showResult is true the verbose mode is assumed.
1105- : @return the results of error evaluation.
1106- :)
1107-declare %ann:sequential function eval:error(
1108- $result as item()*,
1109- $expResult as element(),
1110- $code as xs:QName?,
1111- $errorDescription as xs:string?,
1112- $showResult as xs:boolean?
1113-) as xs:string* {
1114- if(empty($result)) then
1115- let $err := eval:error-code($code,
1116- $errorDescription,
1117- $expResult)
1118- return $err
1119- else
1120- concat("Expected error &#xA;",
1121- data($expResult/@code),
1122- ",&#xA; found result ",
1123- if ($showResult)
1124- then string-join(util:serialize-result($result),' ')
1125- else ())
1126-};
1127-
1128-declare %private %ann:sequential function eval:error-code(
1129- $code as xs:QName?,
1130- $errorDescription as xs:string?,
1131- $expResult as element()
1132-) as xs:string* {
1133- let $assertName := local-name($expResult)
1134- return
1135- if( $assertName = "error")
1136- then
1137- if (exists($expResult[@code = "*"]) or
1138- exists($expResult[@code = local-name-from-QName($code)]))
1139- then ()
1140- else concat("Expected error: ",
1141- data($expResult/@code),
1142- ". Found error: ",
1143- local-name-from-QName($code))
1144- else if (($assertName = "any-of") or ($assertName = "all-of"))
1145- then eval:check-assertion((),
1146- $expResult,
1147- $code,
1148- $errorDescription,
1149- fn:true())
1150- else concat("Expected result: &#xA;",
1151- data($expResult),
1152- ".&#xA; Found error ",
1153- local-name-from-QName($code),
1154- " - ",
1155- $errorDescription)
1156-};
1157-
1158-declare %private %ann:sequential function eval:check-assertion(
1159- $result as item()*,
1160- $expResult as element(),
1161- $code as xs:QName?,
1162- $errorDescription as xs:string?,
1163- $showResult as xs:boolean?
1164-) as xs:string* {
1165- let $test := local-name($expResult)
1166- return switch($test)
1167- case 'all-of'
1168- return eval:assert-all-of($result,
1169- $expResult,
1170- $code,
1171- $errorDescription,
1172- $showResult)
1173- case 'any-of'
1174- return eval:assert-any-of($result,
1175- $expResult,
1176- $code,
1177- $errorDescription,
1178- $showResult)
1179- case 'assert'
1180- return eval:assert($result,
1181- $expResult)
1182- case 'assert-count'
1183- return eval:assert-count($result,
1184- $expResult)
1185- case 'assert-deep-eq'
1186- return eval:assert-deep-eq($result,
1187- $expResult)
1188- case 'assert-empty'
1189- return eval:assert-empty($result)
1190- case 'assert-eq'
1191- return eval:assert-eq($result,
1192- $expResult)
1193- case 'assert-false'
1194- return eval:assert-false($result)
1195- case 'assert-permutation'
1196- return eval:assert-permutation($result,
1197- $expResult)
1198- case 'assert-xml'
1199- return eval:assert-xml($result,
1200- $expResult)
1201- case 'assert-serialization-error'
1202- return eval:assert-serialization-error($result,
1203- $expResult)
1204- case 'assert-string-value'
1205- return eval:assert-string-value($result,
1206- $expResult)
1207- case 'assert-true'
1208- return eval:assert-true($result)
1209- case 'assert-type'
1210- return eval:assert-type($result,
1211- $expResult)
1212- case 'serialization-matches'
1213- return eval:serialization-matches($result,
1214- $expResult)
1215- case 'error'
1216- return eval:error($result,
1217- $expResult,
1218- $code,
1219- $errorDescription,
1220- $showResult)
1221- default
1222- return error($fots-err:errNA,
1223- "&#xA;The requested assertion type is not implemented.")
1224-};
1225-
1226-(: http://dev.w3.org/2011/QT3-test-suite/catalog-schema.html#elem_any-of :)
1227-declare %private %ann:sequential function eval:assert-any-of(
1228- $result as item()*,
1229- $expResult as element(),
1230- $code as xs:QName?,
1231- $errorDescription as xs:string?,
1232- $showResult as xs:boolean
1233-) as xs:string? {
1234- let $results :=
1235- for $tmp in $expResult/*
1236- return <result>{
1237- for $r in eval:check-assertion($result,
1238- $tmp,
1239- $code,
1240- $errorDescription,
1241- $showResult)
1242- return <item>{$r}</item>
1243- } </result>
1244- where every $result in $results satisfies $result/item
1245- return concat("&#xA;Assert-any-of returned: ",
1246- string-join(util:serialize-result($results/data(item)), ' '))
1247-};
1248-
1249-(: http://dev.w3.org/2011/QT3-test-suite/catalog-schema.html#elem_all-of :)
1250-declare %private %ann:sequential function eval:assert-all-of(
1251- $result as item()*,
1252- $expResult as element(),
1253- $code as xs:QName?,
1254- $errorDescription as xs:string?,
1255- $showResult as xs:boolean
1256-) as xs:string* {
1257- for $tmp in $expResult/*
1258- return eval:check-assertion($result,
1259- $tmp,
1260- $code,
1261- $errorDescription,
1262- $showResult)
1263-};
1264-
1265-(: http://dev.w3.org/2011/QT3-test-suite/catalog-schema.html#elem_assert :)
1266-declare %private %ann:sequential function eval:assert(
1267- $result as item()*,
1268- $expResult as element()
1269-) as xs:string? {
1270- try {
1271- {
1272- variable $queryText := concat(
1273- "xquery version '3.0';",
1274- "declare namespace o = 'http://www.zorba-xquery.com/options/features';",
1275- "declare option o:enable 'hof';",
1276- "declare variable $result external; ",
1277- xs:string($expResult));
1278- variable $queryKey := xqxq:prepare-main-module($queryText),
1279- $queryKeyResult := xqxq:bind-variable($queryKey,
1280- xs:QName('result'),
1281- $result),
1282- $queryResult := xqxq:evaluate($queryKey);
1283-
1284- if($queryResult)
1285- then ()
1286- else concat("Assertion ", $expResult, " failed")
1287- }
1288- } catch * {
1289- concat("&#xA;Assertion '",
1290- $expResult,
1291- "'&#xA; failed with error ",
1292- $err:code, " : ", $err:description)
1293- }
1294-};
1295-
1296-(: http://dev.w3.org/2011/QT3-test-suite/catalog-schema.html#elem_assert-count :)
1297-declare %private function eval:assert-count(
1298- $result as item()*,
1299- $expResult as element()
1300-) as xs:string? {
1301- if(count($result) eq xs:integer($expResult))
1302- then ()
1303- else "Actual number of items is different than the expected number of items."
1304-};
1305-
1306-(: http://dev.w3.org/2011/QT3-test-suite/catalog-schema.html#elem_assert-deep-eq :)
1307-declare %private %ann:sequential function eval:assert-deep-eq(
1308- $result as item()*,
1309- $expResult as element()
1310-) as xs:string? {
1311- try {
1312- {
1313- variable $queryText := concat(
1314- "xquery version '3.0';",
1315- "declare namespace o = 'http://www.zorba-xquery.com/options/features';",
1316- "declare option o:enable 'hof';",
1317- "declare variable $x external;",
1318- "let $y := (",string(data($expResult)),") return ",
1319- "every $i in 1 to max((count($x),count($y))) satisfies deep-equal($x[$i],$y[$i])");
1320- variable $queryKey := xqxq:prepare-main-module($queryText),
1321- $queryKeyResult := xqxq:bind-variable($queryKey,
1322- xs:QName('x'),
1323- $result),
1324- $queryResult := xqxq:evaluate($queryKey);
1325- if($queryResult)
1326- then ()
1327- else concat("&#xA;Result is not deep-equal to '", $expResult, "'&#xA;")
1328- }
1329- } catch * {
1330- concat("&#xA;Assert-deep-eq '",
1331- $expResult,
1332- "'&#xA; failed with error ",
1333- $err:code,
1334- " : ",
1335- $err:description)
1336- }
1337-};
1338-
1339-(: http://dev.w3.org/2011/QT3-test-suite/catalog-schema.html#elem_assert-empty :)
1340-declare %private function eval:assert-empty(
1341- $result as item()*
1342-) as xs:string? {
1343- if(empty($result))
1344- then ()
1345- else "&#xA;Result is not empty as expected"
1346-};
1347-
1348-(: http://dev.w3.org/2011/QT3-test-suite/catalog-schema.html#elem_assert-eq :)
1349-declare %private %ann:sequential function eval:assert-eq(
1350- $result as item()*,
1351- $expResult as element()
1352-) as xs:string? {
1353- try {
1354- {
1355- variable $type := if (empty($result[1]) or (count($result) gt 1))
1356- then ()
1357- else
1358- let $tmp := xs:string(schema:schema-type($result[1]))
1359-(: add exception for the types defined in schemas available in the environment of the tests :)
1360- return
1361- if (starts-with($tmp, 'xs:'))
1362- then $tmp
1363- else ();
1364- variable $queryText := concat(
1365- "declare variable $x external;",
1366- "$x eq ",
1367- if (starts-with(data($expResult), $type))
1368- then data($expResult)
1369- else concat($type,"(", data($expResult), ")"));
1370- variable $queryKey := xqxq:prepare-main-module($queryText);
1371-
1372- xqxq:bind-variable($queryKey,
1373- xs:QName('x'),
1374- $result);
1375- variable $queryResult := xqxq:evaluate($queryKey);
1376- if($queryResult)
1377- then ()
1378- else concat("&#xA;Assert-eq: Result '",
1379- string-join(util:serialize-result($result),' '),
1380- "' &#xA;doesn't match expected item '",
1381- xs:string($expResult),
1382- "'.")
1383- }
1384- } catch * {
1385- concat("&#xA;Comparison to '",
1386- $expResult/text(),
1387- "' failed with error: ",
1388- $err:code,
1389- " : ",
1390- $err:description)
1391- }
1392-};
1393-
1394-(: http://dev.w3.org/2011/QT3-test-suite/catalog-schema.html#elem_assert-true :)
1395-declare %private function eval:assert-true(
1396- $result as item()*
1397-) as xs:string? {
1398- if($result eq fn:true())
1399- then ()
1400- else "&#xA;Query doesn't evaluate to true."
1401-};
1402-
1403-(: http://dev.w3.org/2011/QT3-test-suite/catalog-schema.html#elem_assert-false :)
1404-declare %private function eval:assert-false(
1405- $result as item()*
1406-) as xs:string? {
1407- if($result eq fn:false())
1408- then ()
1409- else "&#xA;Query doesn't evaluate to false."
1410-};
1411-
1412-(: http://dev.w3.org/2011/QT3-test-suite/catalog-schema.html#elem_assert-permutation :)
1413-declare %private %ann:sequential function eval:assert-permutation(
1414- $result as item()*,
1415- $expResult as element()
1416-) as xs:string? {
1417- try {
1418- {
1419- variable $queryText := concat(
1420- "xquery version '3.0';",
1421- "declare namespace o = 'http://www.zorba-xquery.com/options/features';",
1422- "declare option o:enable 'hof';",
1423- "declare variable $x external;",
1424- "let $y := (",string(data($expResult)),") return ",
1425- (: if count(intersection(M1,M2)) = count(union(M1,M2)) = count(M1) then the sequences are identical :)
1426- "(count(distinct-values($x[ . = $y])) = count(distinct-values(($x, $y)))) = count(distinct-values($x))");
1427- variable $queryKey := xqxq:prepare-main-module($queryText),
1428- $queryKeyResult := xqxq:bind-variable($queryKey,
1429- xs:QName('x'),
1430- $result),
1431- $queryResult := xqxq:evaluate($queryKey);
1432- if($queryResult)
1433- then ()
1434- else concat("&#xA;Result isn't a permutation of '",
1435- $expResult,
1436- "'&#xA;")
1437- }
1438- } catch * {
1439- concat("&#xA;Assert-permutation failed with error: ",
1440- $err:code,
1441- " : ",
1442- $err:description)
1443- }
1444-};
1445-
1446-(: http://dev.w3.org/2011/QT3-test-suite/catalog-schema.html#elem_assert-xml :)
1447-declare %private function eval:assert-xml(
1448- $result as item()*,
1449- $expResult as element()
1450-) {
1451-(:TODO call xml-canonicalization after bug #1076919 is implemented.:)
1452- try {
1453- let $serRes := util:serialize-result($result),
1454- $result1 as xs:string := string-join($serRes,''),
1455- $result2 as xs:string := string-join($serRes,' ')
1456- return
1457- if((normalize-space($result1) eq normalize-space(string($expResult))) or
1458- (normalize-space($result2) eq normalize-space(string($expResult))))
1459- then ()
1460- else concat("&#xA;Result '",
1461- $result1,
1462- "'&#xA; is different from the expected result &#xA;'",
1463- string($expResult),
1464- "'.")
1465- } catch * {
1466- concat("&#xA;Assert-xml failed with error:",
1467- $err:code,
1468- " : ",
1469- $err:description)
1470- }
1471-};
1472-
1473-(: http://dev.w3.org/2011/QT3-test-suite/catalog-schema.html#elem_assert-serialization-error :)
1474-declare %private %ann:sequential function eval:assert-serialization-error(
1475- $result as item()*,
1476- $expResult as element()
1477-) as xs:string? {
1478- try {
1479- let $serializedResult as xs:string := string-join(
1480- util:serialize-result($result), '')
1481- return
1482- concat("&#xA;Expected serialization error but got result: ",
1483- $serializedResult)
1484- } catch * {
1485- eval:error((),
1486- $expResult,
1487- $err:code,
1488- $err:description,
1489- fn:true())
1490- }
1491-};
1492-
1493-(: http://dev.w3.org/2011/QT3-test-suite/catalog-schema.html#elem_serialization-matches :)
1494-declare %private function eval:serialization-matches(
1495- $result as item()*,
1496- $expResult as element()
1497-) as xs:string? {
1498- let $serResult := string-join(util:serialize-result($result,
1499- $util:serParamXml),
1500- ''),
1501- $serExpResult := string-join(util:serialize-result(data($expResult),
1502- $util:serParamXml),
1503- '')
1504- let $matchesFlags := data($expResult/@flags)
1505- return
1506- if(exists($matchesFlags))
1507- then
1508- if(matches($serResult, $serExpResult, $matchesFlags))
1509- then ()
1510- else concat("&#xA;Expected '",
1511- $serResult,
1512- "'&#xA; does not match &#xA;'",
1513- $serExpResult,
1514- "' with flags '",
1515- $matchesFlags,
1516- "'")
1517- else
1518- if(matches($serResult, $serExpResult))
1519- then ()
1520- else concat("&#xA;Expected ",
1521- $serResult,
1522- "'&#xA; does not match &#xA;'",
1523- $serExpResult,
1524- "'")
1525-};
1526-
1527-(: http://dev.w3.org/2011/QT3-test-suite/catalog-schema.html#elem_assert-string-value :)
1528-declare %private function eval:assert-string-value(
1529- $result as item()*,
1530- $expResult as element()
1531-) as xs:string? {
1532- try {
1533- let $serRes := string-join(util:serialize-result($result), ' '),
1534- $res := if (empty($expResult[@normalize-space="true"]))
1535- then $serRes
1536- else normalize-space($serRes),
1537- $expRes := if (empty($expResult[@normalize-space="true"]))
1538- then xs:string($expResult)
1539- else normalize-space(xs:string($expResult))
1540- return
1541- if($res eq $expRes)
1542- then ()
1543- else concat("&#xA;Expected '",
1544- $expRes,
1545- "'&#xA; found &#xA;'",
1546- $res,
1547- "'")
1548- } catch * {
1549- concat("&#xA;String-value failed with error: ",
1550- $err:code,
1551- " : ",
1552- $err:description)
1553- }
1554-};
1555-
1556-(: http://dev.w3.org/2011/QT3-test-suite/catalog-schema.html#elem_assert-type :)
1557-declare %private %ann:sequential function eval:assert-type(
1558- $result as item()*,
1559- $expResult as element()
1560-) as xs:string? {
1561- try {
1562- {
1563- variable $queryText := concat( "declare variable $x external; $x instance of ",
1564- data($expResult));
1565- variable $queryKey := xqxq:prepare-main-module($queryText),
1566- $queryKeyResult := xqxq:bind-variable($queryKey,
1567- xs:QName('x'),
1568- $result),
1569- $queryResult := xqxq:evaluate($queryKey);
1570- if($queryResult)
1571- then ()
1572- else concat("&#xA;Result doesn't have type '",
1573- data($expResult),
1574- "'")
1575- }
1576- } catch * {
1577- concat("&#xA;Assert-type failed with error: ",
1578- $err:code,
1579- " : ",
1580- $err:description)
1581- }
1582-};
1583
1584=== removed file 'test/fots_driver/fots-driver.xq'
1585--- test/fots_driver/fots-driver.xq 2012-12-12 13:49:24 +0000
1586+++ test/fots_driver/fots-driver.xq 1970-01-01 00:00:00 +0000
1587@@ -1,752 +0,0 @@
1588-(:
1589- : Copyright 2006-2011 The FLWOR Foundation.
1590- :
1591- : Licensed under the Apache License, Version 2.0 (the "License");
1592- : you may not use this file except in compliance with the License.
1593- : You may obtain a copy of the License at
1594- :
1595- : http://www.apache.org/licenses/LICENSE-2.0
1596- :
1597- : Unless required by applicable law or agreed to in writing, software
1598- : distributed under the License is distributed on an "AS IS" BASIS,
1599- : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1600- : See the License for the specific language governing permissions and
1601- : limitations under the License.
1602- :)
1603-
1604-(:~
1605- : Zorba FOTS driver
1606- : @author Sorin Nasoi
1607- :)
1608-
1609-module namespace driver =
1610- "http://www.zorba-xquery.com/fots-driver";
1611-
1612-import module namespace functx =
1613- "http://www.functx.com/";
1614-
1615-import module namespace xqxq =
1616- "http://www.zorba-xquery.com/modules/xqxq";
1617-import module namespace datetime =
1618- "http://www.zorba-xquery.com/modules/datetime";
1619-
1620-import module namespace eval =
1621- "http://www.zorba-xquery.com/fots-driver/evaluate" at "evaluate.xq";
1622-import module namespace env =
1623- "http://www.zorba-xquery.com/fots-driver/environment" at "environment.xq";
1624-import module namespace util =
1625- "http://www.zorba-xquery.com/fots-driver/util" at "util.xq";
1626-import module namespace fots-err =
1627- "http://www.zorba-xquery.com/fots-driver/errors" at "errors.xq";
1628-
1629-declare default element namespace "http://www.w3.org/2010/09/qt-fots-catalog";
1630-
1631-declare namespace err =
1632- "http://www.w3.org/2005/xqt-errors";
1633-declare namespace fots =
1634- "http://www.w3.org/2010/09/qt-fots-catalog";
1635-
1636-declare namespace ann =
1637- "http://www.zorba-xquery.com/annotations";
1638-
1639-(:~
1640- : Loops through the FOTS catalog and returns all available test set names.
1641- : @param $fotsPath path to the FOTS catalog file.
1642- : @param $testSetPrefixes name/criteria for the test sets
1643- : (empty string means all).
1644- : @return available FOTS test sets.
1645- :)
1646-declare %ann:nondeterministic function driver:list-test-sets(
1647- $fotsPath as xs:string,
1648- $testSetPrefixes as xs:string*
1649-) as xs:string* {
1650- let $doc := doc(resolve-uri($fotsPath))
1651- return
1652- if(string-join($testSetPrefixes,'') = '')
1653- then
1654- for $testSet in $doc/fots:catalog/fots:test-set
1655- return data($testSet/@name)
1656- else
1657- for $prefix in $testSetPrefixes
1658- for $testSet in $doc/fots:catalog/fots:test-set[starts-with(@name, $prefix)]
1659- return data($testSet/@name)
1660-};
1661-
1662-declare %private function driver:matches-dependency(
1663- $dependencies as element(fots:dependency)*,
1664- $filter as xs:string
1665-) as xs:boolean {
1666- let $filter := tokenize($filter, '_')
1667- let $depValue := $filter[1]
1668- let $depSatisfied as xs:string := if(exists($filter[2]) and
1669- ($filter[2] = 'true' or $filter[2]='false'))
1670- then $filter[2]
1671- else 'true'
1672- return
1673- if(xs:boolean($depSatisfied))
1674-
1675- (: $depSatisfied = 'true' :)
1676- then (exists($dependencies[@value = $depValue and
1677- @satisfied = $depSatisfied]) or
1678- exists($dependencies[@value = $depValue and empty(@satisfied)]))
1679-
1680- (: $depSatisfied = 'false' :)
1681- else exists($dependencies[@value = $depValue and
1682- @satisfied = $depSatisfied])
1683-};
1684-
1685-(:~
1686- : Loops through the given test set and returns the test cases that have the
1687- : given dependencies defined.
1688- : @param $testSet test set document.
1689- : @param $dependency defined dependency
1690- : (empty string means all test cases).
1691- : @return matching test case names.
1692- :)
1693-declare function driver:list-test-cases(
1694- $testSetDoc as document-node(),
1695- $dependency as xs:string*
1696-) as xs:string* {
1697- if(string-join($dependency,'') = '')
1698- then $testSetDoc//fots:test-case/@name
1699- else for $testCase in $testSetDoc//fots:test-case
1700- let $cond := driver:matches-dependency(($testSetDoc/fots:test-set/fots:dependency,
1701- $testCase/fots:dependency),
1702- $dependency)
1703- where $cond
1704- return$testCase/@name
1705-
1706-};
1707-
1708-(:~
1709- : Loops through the given test sets and returns the corresponding test cases.
1710- : @param $fotsPath path to the FOTS catalog file.
1711- : @param $testSetPrefixes name/criteria for the test sets
1712- : (empty string means all test cases).
1713- : @param $dependency type of dependency that has to be met
1714- : (empty string means all test cases).
1715- : @return available FOTS test cases.
1716- :)
1717-declare %ann:nondeterministic function driver:list-test-cases(
1718- $fotsPath as xs:string,
1719- $testSetPrefixes as xs:string*,
1720- $dependency as xs:string*
1721-) as xs:string* {
1722- let $doc := doc(resolve-uri($fotsPath)),
1723- $baseUri:= resolve-uri(util:parent-folder($fotsPath))
1724- return
1725- if(string-join($testSetPrefixes,'') = '')
1726- then
1727- for $testSet in $doc/fots:catalog/fots:test-set
1728- let $testSetDoc := doc(resolve-uri($testSet/@file, $baseUri))
1729- return driver:list-test-cases($testSetDoc, $dependency)
1730- else
1731- for $prefix in $testSetPrefixes
1732- for $testSet in $doc/fots:catalog/fots:test-set[starts-with(@name, $prefix)]
1733- let $testSetDoc := doc(resolve-uri($testSet/@file, $baseUri))
1734- return driver:list-test-cases($testSetDoc, $dependency)
1735-};
1736-
1737-(:~
1738- : Loops through the given test sets and returns the corresponding test cases.
1739- : @param $fotsPath path to the FOTS catalog file.
1740- : @param $testSetPrefixes name/criteria for the test sets
1741- : (empty string means all test cases).
1742- : @param $testCasePrefixes name/criteria for the test cases
1743- : (empty string means all test cases).
1744- : @param $dependency type of dependency that has to be met
1745- : (empty string means all test cases).
1746- : @return available FOTS test cases.
1747- :)
1748-declare %ann:nondeterministic function driver:list-test-cases(
1749- $fotsPath as xs:string,
1750- $testSetPrefixes as xs:string*,
1751- $testCasePrefixes as xs:string*,
1752- $dependency as xs:string*
1753-) as xs:string* {
1754- let $doc := doc(resolve-uri($fotsPath)),
1755- $baseUri:= resolve-uri(util:parent-folder($fotsPath)),
1756- $testCaseNames := driver:list-test-cases($fotsPath,
1757- $testSetPrefixes,
1758- $dependency)
1759- return
1760- for $prefix in $testCasePrefixes
1761- return
1762- for $name in $testCaseNames
1763- where starts-with($name,
1764- $prefix)
1765- return $name
1766-};
1767-
1768-(:~
1769- : Loops through all the test cases and returns those that have a 'test' node
1770- : that matches given pattern using given flags.
1771- : @param $fotsPath path to the FOTS catalog file.
1772- : @param $pattern pattern.
1773- : @param $flags flags.
1774- : @return available FOTS test cases matching given pattern and flags.
1775- :)
1776-declare %ann:nondeterministic function driver:list-matching-test-cases(
1777- $fotsPath as xs:string,
1778- $pattern as xs:string,
1779- $flags as xs:string?
1780-) as xs:string* {
1781- let $doc := doc(resolve-uri($fotsPath)),
1782- $baseUri:= resolve-uri(util:parent-folder($fotsPath))
1783- return
1784- for $testSet in $doc/fots:catalog/fots:test-set
1785- let $uri := resolve-uri($testSet/@file, $baseUri),
1786- $testSetDoc := doc($uri)
1787- for $testCase in $testSetDoc//test-case
1788- where matches(util:get-value($testCase,
1789- util:parent-folder($uri),
1790- "test"),
1791- $pattern,
1792- $flags)
1793- return
1794- concat(resolve-uri($testSet/@file, $baseUri),
1795- ", test name:",
1796- data($testCase/@name))
1797-};
1798-
1799-declare %private function driver:list-assertions(
1800- $case as element(fots:test-case)
1801-) as xs:string* {
1802- distinct-values(for $assert in $case/result/descendant-or-self::*
1803- return local-name-from-QName(node-name($assert)))
1804-};
1805-
1806-(:~
1807- : Loops through the FOTS catalog and evaluates all test cases that have
1808- : a certain assert-type.
1809- : This is useful for testing the implementation of a certain assert type.
1810- : @param $FOTSCatalogFilePath path to the FOTS catalog file.
1811- : @param $FOTSZorbaManifestPath the path to the file that describes optional
1812- : features and implementation defined items in Zorba.
1813- : @param $testSetPrefixes name/criteria for the test sets (empty string
1814- : means all).
1815- : @param $testCasePrefixes name/criteria for the test cases (empty string
1816- : means all).
1817- : @param $exceptedTestCases lists of test cases that should not be run(empty
1818- : string means all tests will be run).
1819- : @param $exceptedTestSets lists of test sets that should not be run(empty
1820- : string means all tests will be run).
1821- : @param $assert lists of tests that contain a certain assert-type(empty
1822- : string means all tests will be run).
1823- : @param $verbose if set to TRUE it will also output the actual failures.
1824- : @param $showResult if set to TRUE it will also show the actual result of the
1825- : Query run.
1826- : @return an element containing all failed tests
1827- :)
1828-declare %ann:sequential function driver:run-fots(
1829- $FOTSCatalogFilePath as xs:string,
1830- $FOTSZorbaManifestPath as xs:string,
1831- $testSetPrefixes as xs:string*,
1832- $testCasePrefixes as xs:string*,
1833- $exceptedTestCases as xs:string*,
1834- $exceptedTestSets as xs:string*,
1835- $assert as xs:string*,
1836- $verbose as xs:boolean,
1837- $showResult as xs:boolean
1838-) as element(fots:test-cases) {
1839- try {
1840- let $FOTSCatalog := doc(trace(resolve-uri($FOTSCatalogFilePath),
1841- "Path to FOTS catalog.xml set to: ")),
1842- $FOTSZorbaManifest := doc(trace(resolve-uri($FOTSZorbaManifestPath),
1843- "Path to FOTSZorbaManifest set to:"))
1844- return driver:run($FOTSCatalog,
1845- resolve-uri(util:parent-folder($FOTSCatalogFilePath)),
1846- $FOTSZorbaManifest,
1847- $testSetPrefixes,
1848- $testCasePrefixes,
1849- $exceptedTestCases,
1850- $exceptedTestSets,
1851- trace($assert, "The filter for 'assert name' set to: "),
1852- trace($verbose, "'Verbose' parameter set to: "),
1853- $showResult)
1854- }
1855- catch * {
1856- error($err:code,
1857- concat("&#xA;Please make sure the passed 'fotsPath' points to the",
1858- "exact location of the FOTS catalog.xml:&#xA;",
1859- resolve-uri($FOTSCatalogFilePath),
1860- "&#xA;and that the passed 'fotsZorbaManifestPath' points to",
1861- "a file in the same folder as cli.xq:&#xA;",
1862- resolve-uri($FOTSZorbaManifestPath)))
1863- }
1864-};
1865-
1866-(:~
1867- : Loops through the FOTS catalog and evaluates all test cases
1868- :
1869- : @param $FOTSCatalog the FOTS catalog.xml file.
1870- : @param $FOTSZorbaManifest the file that describes optional features and
1871- : implementation defined items in Zorba.
1872- : @param $testSetPrefixes name/criteria for the test sets (empty string means
1873- : all).
1874- : @param $testCasePrefixes name/criteria for the test cases (empty string
1875- : means all).
1876- : @param $exceptedTestCases lists of test cases that should not be run(empty
1877- : string means all tests will be run).
1878- : @param $exceptedTestSets lists of test sets that should not be run(empty
1879- : string means all tests will be run).
1880- : @param $assert lists of tests that contain a certain assert-type(empty
1881- : string means all tests will be run).
1882- : @param $verbose if set to TRUE it will also output the actual failures.
1883- : @param $showResult if set to TRUE it will also show the actual result of the
1884- : Query run.
1885- : @return an element containing all failed tests
1886- :)
1887-declare %ann:sequential function driver:run(
1888- $FOTSCatalog as document-node(),
1889- $catalogBaseURI as xs:anyURI,
1890- $FOTSZorbaManifest as document-node(),
1891- $testSetPrefixes as xs:string*,
1892- $testCasePrefixes as xs:string*,
1893- $exceptedTestCases as xs:string*,
1894- $exceptedTestSets as xs:string*,
1895- $assert as xs:string*,
1896- $verbose as xs:boolean,
1897- $showResult as xs:boolean
1898-) as element(fots:test-cases) {
1899- <test-cases>{
1900- let $catalogTestSetNames := $FOTSCatalog//fots:test-set/@name,
1901- $testSetNames := if ($testSetPrefixes = '')
1902- then functx:value-except($catalogTestSetNames,
1903- $exceptedTestSets)
1904- else functx:value-except(
1905- functx:value-intersect($testSetPrefixes,
1906- $catalogTestSetNames),
1907- $exceptedTestSets)
1908- for $testSetName in $testSetNames
1909- let $testSet := $FOTSCatalog//fots:test-set[@name=$testSetName],
1910- $testSetURI := resolve-uri($testSet/@file,
1911- $catalogBaseURI),
1912- $testSetDoc := doc($testSetURI),
1913- $depMet as xs:string*:= env:check-dependencies($testSetDoc/fots:test-set/fots:dependency,
1914- $FOTSZorbaManifest)
1915- return
1916- if(exists($depMet))
1917- then <test-set name="{$testSetName}">
1918- {
1919- for $testCase in $testSetDoc/fots:test-set/fots:test-case
1920- let $envName := data($testCase/fots:environment/@ref),
1921- $envTestSet := $testSetDoc/fots:test-set/fots:environment[@name = $envName],
1922- $envCatalog := $FOTSCatalog/fots:catalog/fots:environment[@name = $envName],
1923- $shouldRun := if ($testCasePrefixes = '')
1924- then functx:value-except(xs:string(data($testCase/@name)),
1925- $exceptedTestCases)
1926- else functx:value-except(
1927- functx:value-intersect(data($testCase/@name),
1928- $testCasePrefixes),
1929- $exceptedTestCases),
1930- (:true if the tests-case has an assertion type that is requested :)
1931- $hasReqAssert := (($assert = '') or
1932- exists(functx:value-intersect(
1933- driver:list-assertions($testCase),
1934- $assert)))
1935- where $shouldRun and $hasReqAssert
1936- return
1937- driver:not-applicable($testCase,
1938- $envTestSet,
1939- string-join($depMet,''),
1940- $verbose)
1941- }</test-set>
1942- else <test-set name="{$testSetName}">
1943- {
1944- for $testCase in $testSetDoc/fots:test-set/fots:test-case
1945- let $envName := data($testCase/fots:environment/@ref),
1946- $envTestSet := $testSetDoc/fots:test-set/fots:environment[@name = $envName],
1947- $envCatalog := $FOTSCatalog/fots:catalog/fots:environment[@name = $envName],
1948- $shouldRun := if ($testCasePrefixes = '')
1949- then functx:value-except(xs:string(data($testCase/@name)),
1950- $exceptedTestCases)
1951- else functx:value-except(
1952- functx:value-intersect(data($testCase/@name),
1953- $testCasePrefixes),
1954- $exceptedTestCases),
1955- (:true if the tests-case has an assertion type that is requested :)
1956- $hasReqAssert := (($assert = '') or
1957- exists(functx:value-intersect(driver:list-assertions($testCase),
1958- $assert)))
1959- where $shouldRun and $hasReqAssert
1960- return
1961- if(exists(env:check-dependencies($testCase/fots:dependency,
1962- $FOTSZorbaManifest)))
1963- then driver:not-applicable( $testCase,
1964- $envTestSet,
1965- string-join(distinct-values(env:check-dependencies($testCase/fots:dependency,
1966- $FOTSZorbaManifest)),
1967- ''),
1968- $verbose)
1969- else if(empty($envTestSet))
1970- then driver:test( $FOTSZorbaManifest,
1971- $testCase,
1972- $envCatalog,
1973- $catalogBaseURI,
1974- ($testCase/fots:dependency,
1975- $testSetDoc/fots:test-set/fots:dependency),
1976- $testSetName,
1977- $testSetURI,
1978- $verbose,
1979- $showResult)
1980- else driver:test( $FOTSZorbaManifest,
1981- $testCase,
1982- $envTestSet,
1983- $testSetURI,
1984- ($testCase/fots:dependency,
1985- $testSetDoc/fots:test-set/fots:dependency),
1986- $testSetName,
1987- $testSetURI,
1988- $verbose,
1989- $showResult)
1990- }</test-set>
1991- }</test-cases>
1992-};
1993-
1994-(:~
1995- : Creates the complete query that will be evaluated by adding the necessary
1996- : XQXQ URL resolvers.
1997- : @param $queryText the test-case/test after all the additional prolog
1998- : statements were added.
1999- : @param $case the test case.
2000- : @param $env the environment.
2001- : @param $envBaseURI URI of the environment.
2002- : @param $testSetBaseURI URI of the test set that defines the test case.
2003- : @return the query that will be evaluated.
2004- :)
2005-declare %private function driver:create-XQXQ-query(
2006- $queryText as xs:string,
2007- $case as element(fots:test-case),
2008- $env as element(fots:environment)?,
2009- $envBaseURI as xs:anyURI?,
2010- $testSetBaseURI as xs:anyURI
2011-) as xs:string {
2012- let $resolver as xs:string? := env:resolver($case,
2013- $env,
2014- $envBaseURI,
2015- $testSetBaseURI)
2016- return string-join(
2017- ("import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';",
2018- if (exists($resolver))
2019- then $resolver
2020- else (),
2021- (concat("variable $queryID := xqxq:prepare-main-module('",
2022- "&#xA;",
2023- replace($queryText,"'","''"),
2024- "'",
2025- "&#xA;",
2026- if (exists($resolver))
2027- then ", resolver:url-resolver#2, ());"
2028- else ");")),
2029- env:set-context-item($env, $envBaseURI),
2030- env:set-context-item($case/fots:environment,
2031- $testSetBaseURI),
2032- env:set-variables($env,
2033- $envBaseURI),
2034- env:set-variables($case/environment,
2035- $testSetBaseURI),
2036- "xqxq:evaluate($queryID)"
2037- ),
2038- "&#xA;")
2039-};
2040-
2041-(:~
2042- : XQXQ invoke.
2043- : @param $xqxqQueryText the query that will be run.
2044- : @param $case the test case.
2045- : @return the result of running the query with XQXQ.
2046- :)
2047-declare %private %ann:sequential function driver:xqxq-invoke(
2048- $xqxqQueryText as xs:string,
2049- $case as element(fots:test-case),
2050- $showResult as xs:boolean?,
2051- $testSetBaseURI as xs:anyURI
2052-) {
2053- try {
2054- {
2055- variable $queryKey := xqxq:prepare-main-module($xqxqQueryText);
2056- variable $queryResult := xqxq:evaluate-sequential($queryKey);
2057- (:TODO check if this works:)
2058- (:variable $expResult := util:get-value($case, $testSetBaseURI, "result");:)
2059- eval:result($queryResult,
2060- $case/fots:result/*,
2061- $showResult)
2062- }
2063- } catch * {
2064- eval:error((),
2065- $case/fots:result/*,
2066- $err:code,
2067- $err:description,
2068- $showResult)
2069- }
2070-};
2071-
2072-(:~
2073- : Runs a single test case.
2074- :
2075- : @param $FOTSZorbaManifest the file that describes optional features and
2076- : implementation defined items in Zorba.
2077- : @param $case test case.
2078- : @param $env the environment.
2079- : @param $envBaseURI the relative URI used to calculate the full URI for the
2080- : different children of the environment that have a "file" attribute.
2081- : @param $deps the dependencies that should be checked for given test case.
2082- : @param $testSetName the name of the test set.
2083- : @param $testSetBaseURI the URI of the test set.
2084- : @param $verbose xs:boolean indicating if a result should be returned in case
2085- : of success or not.
2086- : @return the result of running the test case depending on $verbose.
2087- :)
2088-declare %ann:sequential function driver:test(
2089- $FOTSZorbaManifest as document-node(),
2090- $case as element(fots:test-case),
2091- $env as element(fots:environment)?,
2092- $envBaseURI as xs:anyURI?,
2093- $deps as element(fots:dependency)*,
2094- $testSetName as xs:string?,
2095- $testSetBaseURI as xs:anyURI,
2096- $verbose as xs:boolean,
2097- $showResult as xs:boolean?
2098-) as element(fots:test-case)? {
2099-(:TODO Cover the "(:%VARDECL%:)"when there are tests in FOTS that use it:)
2100-try {
2101-{
2102- variable $queryName := trace(data($case/@name),
2103- "processing test case :");
2104-
2105- variable $test := util:get-value($case,
2106- $testSetBaseURI,
2107- "test");
2108- variable $enableHOF := env:enable-HOF-feature(($deps, $case//fots:dependency),
2109- $test);
2110- variable $query := string-join((env:add-xquery-version-decl(($deps, $case//fots:dependency),
2111- $test),
2112- env:decl-def-elem-namespace($env,
2113- $case/fots:environment),
2114- env:decl-base-uri($env,
2115- $case/fots:environment),
2116- env:decl-namespaces($env,
2117- $case,
2118- $testSetBaseURI),
2119- $enableHOF,
2120- env:decl-decimal-formats(($env/fots:decimal-format,
2121- $case/fots:environment/fots:decimal-format)),
2122- env:add-var-decl($env,
2123- $case,
2124- $envBaseURI,
2125- $testSetBaseURI),
2126- $test
2127- ),"&#xA;"),
2128- $xqxqQuery := driver:create-XQXQ-query($query,
2129- $case,
2130- $env,
2131- $envBaseURI,
2132- $testSetBaseURI),
2133- $startDateTime := datetime:current-dateTime (),
2134- $result := driver:xqxq-invoke($xqxqQuery,
2135- $case,
2136- $showResult,
2137- $testSetBaseURI),
2138- $duration := (datetime:current-dateTime () - $startDateTime);
2139-
2140- if(empty($result))
2141- then driver:pass($case,
2142- $result,
2143- $xqxqQuery,
2144- $env,
2145- (),
2146- $duration,
2147- $verbose)
2148-
2149-(: if the exact error code was not found, report the test as 'Pass'
2150- with an attribute correctError=false :)
2151- else if(exists($result) and
2152- contains(string-join($result,''), "Expected error:") and
2153- contains(string-join($result,''), "Found error:"))
2154- then driver:pass($case,
2155- $result,
2156- $xqxqQuery,
2157- $env,
2158- $result,
2159- $duration,
2160- $verbose)
2161- else
2162- driver:fail($case,
2163- $result,
2164- $xqxqQuery,
2165- $testSetName,
2166- $env,
2167- $duration,
2168- $verbose)
2169-}
2170-} catch * {
2171- driver:fail($case,
2172- <result>{$err:description}</result>,
2173- "",
2174- $testSetName,
2175- $env,
2176- xs:dayTimeDuration("PT0S"),
2177- $verbose)
2178-}
2179-};
2180-
2181-(:~
2182- : Gives feedback on a test case that is not run when dependencies are not met.
2183- :
2184- : @param $case test case.
2185- : @param $dependencyError test error returned by the dependency checking.
2186- : @return the test case.
2187- :)
2188-declare %private %ann:sequential function driver:not-applicable(
2189- $case as element(fots:test-case),
2190- $env as element(fots:environment)?,
2191- $dependencyError as xs:string,
2192- $verbose as xs:boolean
2193-) as element(fots:test-case)? {
2194- trace(data($case/@name), "processing test case :");
2195- trace($dependencyError, "Dependency error :");
2196- if($verbose)
2197- then
2198- {
2199- let $tmp := $case
2200- return {
2201- insert node
2202- attribute result{'not applicable'}
2203- as last into $tmp;
2204-
2205- insert node
2206- attribute comment{$dependencyError}
2207- as last into $tmp;
2208-
2209- insert node
2210- <info>
2211- {$env}
2212- </info>
2213- as last into $tmp;
2214-
2215- delete node $tmp/description;
2216- delete node $tmp/created;
2217-
2218- $tmp
2219- }
2220- }
2221- else
2222- <test-case name="{data($case/@name)}"
2223- result="not applicable"
2224- comment="{$dependencyError}" />
2225-};
2226-
2227-(:~
2228- : Gives feedback on a test case run with success.
2229- :
2230- : @param $case test case.
2231- : @return the test case after certain information was added.
2232- :)
2233-declare %private %ann:sequential function driver:pass(
2234- $case as element(fots:test-case),
2235- $result as item()*,
2236- $zorbaQuery as xs:string,
2237- $env as element(fots:environment)?,
2238- $comment as xs:string?,
2239- $duration as xs:dayTimeDuration,
2240- $verbose as xs:boolean
2241-) as element(fots:test-case)? {
2242- if($verbose)
2243- then
2244- {
2245- let $tmp := $case
2246- return {
2247- insert node
2248- attribute result{'pass'}
2249- as last into $tmp;
2250-
2251- if(exists($comment)) then
2252- insert node
2253- attribute correctError{'false'}
2254- as last into $tmp;
2255- else ();
2256-
2257- if(exists($comment)) then
2258- insert node
2259- attribute comment{$comment}
2260- as last into $tmp;
2261- else ();
2262-
2263- insert node
2264- attribute executionTime{$duration}
2265- as last into $tmp;
2266-
2267- insert node
2268- <info>
2269- {$env}
2270- <query>{$zorbaQuery}</query>
2271- <actual-result>{$result}</actual-result>
2272- </info>
2273- as last into $tmp;
2274-
2275- delete node $tmp/description;
2276- delete node $tmp/created;
2277-
2278- $tmp
2279- }
2280- }
2281- else if(empty($comment))
2282- then <test-case name="{data($case/@name)}"
2283- result="pass"
2284- executionTime="{$duration}" />
2285- else <test-case name="{data($case/@name)}"
2286- result="pass"
2287- correctError="{empty($comment)}"
2288- executionTime="{$duration}" />
2289-};
2290-
2291-(:~
2292- : Gives feedback on a test case run without success.
2293- :
2294- : @param $case test case.
2295- : @return the test case after certain information was added.
2296- :)
2297-declare %private %ann:sequential function driver:fail(
2298- $case as element(fots:test-case),
2299- $result as item()*,
2300- $zorbaQuery as xs:string,
2301- $testSetName as xs:string?,
2302- $env as element(fots:environment)?,
2303- $duration as xs:dayTimeDuration,
2304- $verbose as xs:boolean
2305-) as element(fots:test-case)? {
2306- trace($testSetName, "test set name");
2307- trace("above test case failed", "result");
2308-
2309- if($verbose)
2310- then
2311- {
2312- let $tmp := $case
2313- return {
2314- insert node
2315- attribute result{'fail'}
2316- as last into $tmp;
2317-
2318- insert node
2319- attribute executionTime{$duration}
2320- as last into $tmp;
2321-
2322- insert node
2323- <info>
2324- {$env}
2325- <query>{$zorbaQuery}</query>
2326- <actual-result>{$result}</actual-result>
2327- </info>
2328- as last into $tmp;
2329-
2330- delete node $tmp/description;
2331- delete node $tmp/created;
2332-
2333- $tmp
2334- }
2335- }
2336- else <test-case name="{data($case/@name)}"
2337- result="fail"
2338- executionTime="{$duration}"/>
2339-};
2340
2341=== removed file 'test/fots_driver/reporting.xq'
2342--- test/fots_driver/reporting.xq 2012-11-27 10:54:05 +0000
2343+++ test/fots_driver/reporting.xq 1970-01-01 00:00:00 +0000
2344@@ -1,250 +0,0 @@
2345-(:
2346- : Copyright 2006-2011 The FLWOR Foundation.
2347- :
2348- : Licensed under the Apache License, Version 2.0 (the "License");
2349- : you may not use this file except in compliance with the License.
2350- : You may obtain a copy of the License at
2351- :
2352- : http://www.apache.org/licenses/LICENSE-2.0
2353- :
2354- : Unless required by applicable law or agreed to in writing, software
2355- : distributed under the License is distributed on an "AS IS" BASIS,
2356- : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2357- : See the License for the specific language governing permissions and
2358- : limitations under the License.
2359- :)
2360-
2361-(:~
2362- : Zorba FOTS driver reporting
2363- : @author Sorin Nasoi
2364- :)
2365-
2366-module namespace reporting =
2367- "http://www.zorba-xquery.com/fots-driver/reporting";
2368-
2369-import module namespace file =
2370- "http://expath.org/ns/file";
2371-
2372-import module namespace driver =
2373- "http://www.zorba-xquery.com/fots-driver" at "fots-driver.xq";
2374-import module namespace util =
2375- "http://www.zorba-xquery.com/fots-driver/util" at "util.xq";
2376-import module namespace fots-err =
2377- "http://www.zorba-xquery.com/fots-driver/errors" at "errors.xq";
2378-
2379-declare default element namespace "http://www.w3.org/2010/09/qt-fots-catalog";
2380-
2381-declare namespace err =
2382- "http://www.w3.org/2005/xqt-errors";
2383-declare namespace fots =
2384- "http://www.w3.org/2010/09/qt-fots-catalog";
2385-
2386-declare namespace ann =
2387- "http://www.zorba-xquery.com/annotations";
2388-
2389-(:~
2390- : Loops through the test-sets, runs then and creates statistics.
2391- : @param $FOTSCatalogFilePath path to the FOTS catalog file.
2392- : @param $FOTSZorbaManifestPath path to the FOTS Zorba manifest file.
2393- : @param $testSetPrefixes name/criteria for the test sets( empty string means
2394- : all).
2395- : @param $testCasePrefixes name/criteria for the test cases(empty string means
2396- : all).
2397- : @param $exceptedTestCases lists of test cases that are not run( empty string
2398- : means all tests will be run).
2399- : @param $exceptedTestSets lists of test sets that are not run(empty string
2400- : means all tests will be run).
2401- : @param $verbose if set to TRUE it will also output the actual failures.
2402- : @param $showResult if set to TRUE it will also show the actual result of the
2403- : Query run.
2404- : @return a report of tests run.
2405- :)
2406-declare %ann:sequential function reporting:run-and-report(
2407- $FOTSCatalogFilePath as xs:string,
2408- $FOTSZorbaManifestPath as xs:string,
2409- $testSetPrefixes as xs:string*,
2410- $testCasePrefixes as xs:string*,
2411- $exceptedTestCases as xs:string*,
2412- $exceptedTestSets as xs:string*,
2413- $assert as xs:string*,
2414- $verbose as xs:boolean,
2415- $showResult as xs:boolean
2416-) {
2417-try {
2418- {
2419- variable $FOTSCatalog := doc(trace(resolve-uri($FOTSCatalogFilePath),
2420- "Path to FOTS catalog.xml set to: "));
2421-
2422- variable $catalogBaseURI := resolve-uri(util:parent-folder($FOTSCatalogFilePath));
2423-
2424- variable $FOTSZorbaManifest := doc(trace(resolve-uri($FOTSZorbaManifestPath),
2425- "Path to FOTSZorbaManifest set to:"));
2426-
2427- variable $failures := <fots:FOTS-test-suite-result>{
2428- ( $FOTSZorbaManifest//fots:implementation,
2429- $FOTSZorbaManifest//fots:dependencies-satisfied,
2430- driver:run($FOTSCatalog,
2431- $catalogBaseURI,
2432- $FOTSZorbaManifest,
2433- $testSetPrefixes,
2434- $testCasePrefixes,
2435- $exceptedTestCases,
2436- $exceptedTestSets,
2437- $assert,
2438- $verbose,
2439- $showResult)
2440- )
2441- }</fots:FOTS-test-suite-result>;
2442-
2443- file:write("failures.xml",
2444- $failures,
2445- $util:writeXML);
2446-
2447- reporting:do-reporting($FOTSCatalog,
2448- $catalogBaseURI,
2449- $failures,
2450- $exceptedTestCases,
2451- $exceptedTestSets,
2452- $verbose)
2453- }
2454-}
2455-catch *
2456-{
2457- error($err:code,
2458- $err:description,
2459- concat("&#xA;Please make sure the passed 'fotsPath' points to the ",
2460- "exact location of the FOTS catalog.xml:&#xA;",
2461- resolve-uri($FOTSCatalogFilePath),
2462- "&#xA;and that the passed 'fotsZorbaManifestPath' points to",
2463- " a file in the same folder as cli.xq:&#xA;",
2464- resolve-uri($FOTSZorbaManifestPath)))
2465-}
2466-};
2467-
2468-(:~
2469- : Loops through the test cases report and creates statistics.
2470- : @param $pathFOTSCatalog path to the FOTS catalog file.
2471- : @param $pathFailures path to the FOTS failures.
2472- : @param $exceptedTestCases lists of test cases that are not run( empty string
2473- : means all tests will be run).
2474- : @param $exceptedTestSets lists of test sets that are not run(empty string
2475- : means all tests will be run).
2476- : @param $verbose if set to TRUE it will also output the actual failures.
2477- : @param $showResult if set to TRUE it will also show the actual result of the
2478- : Query run.
2479- : @return a report of tests run.
2480- :)
2481-declare %ann:nondeterministic function reporting:report(
2482- $FOTSCatalogFilePath as xs:string,
2483- $pathFailures as xs:string,
2484- $exceptedTestCases as xs:string*,
2485- $exceptedTestSets as xs:string*,
2486- $verbose as xs:boolean
2487-) as element(fots:report) {
2488- try {
2489- {
2490- if(not(file:is-file($pathFailures)))
2491- then
2492- {
2493- error($fots-err:errNA,
2494- "The file failures file was not found. Suggestion: use driver:run-fots to generate it or use reporting:run-and-report function.");
2495- }
2496- else ();
2497-
2498- variable $failures := parse-xml(file:read-text($pathFailures));
2499-
2500- variable $FOTSCatalog := doc(trace(resolve-uri($FOTSCatalogFilePath),
2501- "Path to FOTS catalog.xml set to: "));
2502-
2503- variable $catalogBaseURI := resolve-uri(util:parent-folder($FOTSCatalogFilePath));
2504-
2505- reporting:do-reporting($FOTSCatalog,
2506- $catalogBaseURI,
2507- $failures,
2508- $exceptedTestCases,
2509- $exceptedTestSets,
2510- $verbose)
2511- }
2512- }
2513- catch *
2514- {
2515- error($err:code, $err:description)
2516- }
2517-};
2518-
2519-
2520-(:~
2521- : Loops through the test-sets and creates statistics.
2522- : @param $FOTSCatalog FOTS catalog file.
2523- : @param $failures the test reported by Zorba as failed.
2524- : @param $exceptedTestCases lists of test cases that are not run(empty string
2525- : means all tests will be run).
2526- : @param $exceptedTestSets lists of test sets that are not run(empty string
2527- : means all tests will be run).
2528- : @param $verbose is set to TRUE it will also output the actual failures.
2529- : @return a report of tests run.
2530- :)
2531-declare %ann:nondeterministic function reporting:do-reporting(
2532- $FOTSCatalog as document-node(),
2533- $catalogBaseURI as xs:anyURI,
2534- $failures,
2535- $exceptedTestCases as xs:string*,
2536- $exceptedTestSets as xs:string*,
2537- $verbose as xs:boolean
2538-) as element(fots:report) {
2539- let $excepted := count($exceptedTestCases)
2540- return
2541- <report>
2542- {
2543- let $totalNoTests := sum(for $testSet in $FOTSCatalog//fots:test-set
2544- let $testSetDoc := doc(resolve-uri($testSet/@file,
2545- $catalogBaseURI))
2546- return count($testSetDoc//fots:test-case)),
2547- $totalFailures := sum(for $testSet in $failures//fots:test-set
2548- return count($testSet//fots:test-case[@result ='fail'])),
2549- $totalNotApplicable := sum(for $testSet in $failures//fots:test-set
2550- return count($testSet//fots:test-case[@result ='not applicable'])),
2551- $notRun := sum(for $exeptedTS in $exceptedTestSets
2552- return
2553- for $testSet in $FOTSCatalog//fots:test-set
2554- let $testSetDoc := doc(resolve-uri($testSet/@file, $catalogBaseURI))
2555- where (data($testSetDoc/fots:test-set/@name) = $exeptedTS)
2556- return count($testSetDoc//fots:test-case)),
2557- $executionTime := sum(for $testCase in $failures//fots:test-set//fots:test-case return xs:dayTimeDuration($testCase/@executionTime))
2558- return
2559- <brief totalTests="{$totalNoTests}"
2560- totalFailures="{$totalFailures}"
2561- totalNotApplicable="{$totalNotApplicable}"
2562- totalNotRun="{$notRun + $excepted}"
2563- totalExecutionTime="{$executionTime}"/>
2564- }
2565- {
2566- for $testSetFile in $FOTSCatalog//fots:test-set
2567- let $testSetURI := resolve-uri($testSetFile/@file,
2568- $catalogBaseURI),
2569- $testSetDoc := doc($testSetURI),
2570- $testSetName := data($testSetDoc/fots:test-set/@name),
2571- $totalNoTestCases := count($testSetDoc//fots:test-case),
2572- $totalFailures := for $testCase in $failures//fots:test-set[@name = $testSetName]//fots:test-case[@result ="fail"]
2573- return $testCase,
2574- $percent := round((1 - (count($totalFailures) div $totalNoTestCases))*100,2),
2575- $executionTime := sum(for $testCase in $failures//fots:test-set[@name = $testSetName]//fots:test-case
2576- return xs:dayTimeDuration($testCase/@executionTime))
2577- order by count($totalFailures) descending
2578- return
2579- <test-set name="{$testSetName}"
2580- executionTime="{$executionTime}"
2581- noFailures="{count($totalFailures)}"
2582- noTestCases="{$totalNoTestCases}"
2583- percent="{$percent}"
2584- failedTestNames="{string-join( for $failure in $totalFailures
2585- order by data($failure/@name)
2586- return data($failure/@name)
2587- ,",")}">
2588- {if (not($verbose)) then $totalFailures else ()}
2589- </test-set>
2590- }
2591- <exceptedTestCases>{$exceptedTestCases}</exceptedTestCases>
2592- <exceptedTestSets>{$exceptedTestSets}</exceptedTestSets>
2593- </report>
2594-};
2595
2596=== removed directory 'test/fots_driver/tools'
2597=== removed file 'test/fots_driver/tools/dependencies.xq'
2598--- test/fots_driver/tools/dependencies.xq 2012-11-13 10:45:24 +0000
2599+++ test/fots_driver/tools/dependencies.xq 1970-01-01 00:00:00 +0000
2600@@ -1,27 +0,0 @@
2601-(: this query loads a rezults.xml file and reports the number of 'non applicable' tests grouped by feature :)
2602-(:
2603- sample usage
2604- ./zorba -f -q ../../test/fots_driver/tools/dependencies.xq
2605- -e pathFailures:=results_12_nov.xml
2606- -o driver_dependencies.xml
2607- --indent
2608-:)
2609-
2610- import module namespace file = "http://expath.org/ns/file";
2611-
2612- declare default element namespace "http://www.w3.org/2010/09/qt-fots-catalog";
2613- declare namespace fots = "http://www.w3.org/2010/09/qt-fots-catalog";
2614-
2615- declare variable $pathFailures external;
2616-
2617- variable $failures := fn:parse-xml(file:read-text($pathFailures));
2618-
2619- <report> {
2620- for $d in distinct-values(data($failures/fots:test-cases/fots:test-set/fots:test-case[@result="not applicable"]/@comment))
2621- order by $d
2622- return
2623- <dependency type="{$d}"> {
2624- <value number-of-tests="{count($failures/fots:test-cases//fots:test-set//fots:test-case[@result="not applicable" and @comment=$d])}" />
2625- }</dependency>
2626- }</report>
2627-
2628\ No newline at end of file
2629
2630=== removed file 'test/fots_driver/tools/process.xq'
2631--- test/fots_driver/tools/process.xq 2012-12-12 13:49:24 +0000
2632+++ test/fots_driver/tools/process.xq 1970-01-01 00:00:00 +0000
2633@@ -1,127 +0,0 @@
2634-(:
2635- : Copyright 2006-2011 The FLWOR Foundation.
2636- :
2637- : Licensed under the Apache License, Version 2.0 (the "License");
2638- : you may not use this file except in compliance with the License.
2639- : You may obtain a copy of the License at
2640- :
2641- : http://www.apache.org/licenses/LICENSE-2.0
2642- :
2643- : Unless required by applicable law or agreed to in writing, software
2644- : distributed under the License is distributed on an "AS IS" BASIS,
2645- : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2646- : See the License for the specific language governing permissions and
2647- : limitations under the License.
2648- :)
2649-
2650-(:~
2651- : Run every test case that matches a given criterion in a different process
2652- : and report every test case that HANGS or ends in a SEG FAULT.
2653- :
2654- : @author Sorin Nasoi
2655- :)
2656-
2657-
2658-import module namespace proc =
2659- "http://www.zorba-xquery.com/modules/process";
2660-import module namespace util =
2661- "http://www.zorba-xquery.com/fots-driver/util" at "../util.xq";
2662-import module namespace d =
2663- "http://www.zorba-xquery.com/fots-driver" at "../fots-driver.xq";
2664-import module namespace fots-err =
2665- "http://www.zorba-xquery.com/fots-driver/errors" at "../errors.xq";
2666-
2667-declare namespace ann =
2668- "http://www.zorba-xquery.com/annotations";
2669-declare namespace fots =
2670- "http://www.w3.org/2010/09/qt-fots-catalog";
2671-
2672-declare variable $pathFOTS as xs:string external :="";
2673-
2674-(:~
2675- : Return the exit-code after invoking the FOTS driver with given $params.
2676- :
2677- : @param $params additional params.
2678- : @return the exit-code returned by the invoked application.
2679- :)
2680-declare %ann:sequential function local:exec(
2681- $params as xs:string*
2682-) as xs:string {
2683- variable $pathZorba := normalize-space(xs:string(proc:exec("pwd")/proc:stdout));
2684-
2685- proc:exec(string-join(($pathZorba, "/zorba"),''),
2686- ("-f", "-q", concat($pathZorba, "/../../test/fots_driver/cli.xq"),
2687- "-e", concat("fotsPath:=", $pathFOTS),
2688- "-e", "verbose:=false",
2689- $params
2690- )
2691- )/proc:exit-code
2692-};
2693-
2694-declare %private %ann:sequential function local:invoke-exec(
2695- $testSets as element(fots:test-set)*,
2696- $baseUri as xs:anyURI,
2697- $dependency as xs:string*
2698-) as xs:string* {
2699- for $testSet in $testSets
2700- let $testSetDoc := doc(resolve-uri($testSet/@file, $baseUri))
2701- let $testSetName := xs:string($testSet/@name)
2702- let $testCaseNames as xs:string* := d:list-test-cases($testSetDoc,
2703- $dependency)
2704- return
2705- for $testCaseName in $testCaseNames
2706- let $exit-code :=
2707- trace(local:exec(("-e", "mode:=run-test-case",
2708- "-e", concat("testSetName:=", $testSetName),
2709- "-e", concat("testCaseName:=", trace($testCaseName, "processing test case :"))
2710- )
2711- ),"exit-code")
2712- where (xs:integer($exit-code) gt xs:integer(134))
2713- return $testCaseName
2714-};
2715-
2716-(:~
2717- : Return the name of the test cases that return an exit-code > 128.
2718- :
2719- : @param $fotsPath path to the FOTS catalog file.
2720- : @param $testSetPrefixes name/criteria for the test sets.
2721- : @param $dependency defined dependency.
2722- : @return the exit-codes returned by the invoked applications.
2723- :)
2724-declare %ann:sequential function local:list-test-cases(
2725- $fotsPath as xs:string,
2726- $testSetPrefixes as xs:string*,
2727- $dependency as xs:string*
2728-) as xs:string* {
2729- variable $doc := doc(resolve-uri($fotsPath)),
2730- $baseUri:= resolve-uri(util:parent-folder($fotsPath));
2731-
2732- if(string-join($testSetPrefixes,'') = '')
2733- then local:invoke-exec($doc/fots:catalog/fots:test-set,
2734- $baseUri,
2735- $dependency)
2736- else
2737- for $prefix in $testSetPrefixes
2738- return
2739- local:invoke-exec($doc/fots:catalog/fots:test-set[starts-with(@name, $prefix)],
2740- $baseUri,
2741- $dependency)
2742-};
2743-
2744-if( $pathFOTS = '')
2745-then fn:error($fots-err:errNA,
2746- "please set the external variable $pathFOTS to point to FOTS catalog.xml file.")
2747-else
2748-concat("'",
2749- string-join(local:list-test-cases($pathFOTS, '', 'higherOrderFunctions'),"', '"),
2750- "'")
2751-
2752-
2753-(:
2754-local:exec(
2755- ("-e", "mode:=run-test-case",
2756- "-e", concat("testSetName:=", "misc-HigherOrderFunctions"),
2757- "-e", concat("testCaseName:=", "xqhof2")
2758- )
2759- )
2760-:)
2761\ No newline at end of file
2762
2763=== removed file 'test/fots_driver/util.xq'
2764--- test/fots_driver/util.xq 2012-11-14 14:02:58 +0000
2765+++ test/fots_driver/util.xq 1970-01-01 00:00:00 +0000
2766@@ -1,119 +0,0 @@
2767-(:
2768- : Copyright 2006-2011 The FLWOR Foundation.
2769- :
2770- : Licensed under the Apache License, Version 2.0 (the "License");
2771- : you may not use this file except in compliance with the License.
2772- : You may obtain a copy of the License at
2773- :
2774- : http://www.apache.org/licenses/LICENSE-2.0
2775- :
2776- : Unless required by applicable law or agreed to in writing, software
2777- : distributed under the License is distributed on an "AS IS" BASIS,
2778- : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2779- : See the License for the specific language governing permissions and
2780- : limitations under the License.
2781- :)
2782-
2783-(:~
2784- : Zorba FOTS driver util
2785- : @author Sorin Nasoi
2786- :)
2787-
2788-module namespace util =
2789- "http://www.zorba-xquery.com/fots-driver/util";
2790-
2791-import schema namespace output =
2792- "http://www.w3.org/2010/xslt-xquery-serialization";
2793-
2794-import module namespace file =
2795- "http://expath.org/ns/file";
2796-
2797-import module namespace fots-err =
2798- "http://www.zorba-xquery.com/fots-driver/errors" at "errors.xq";
2799-
2800-declare namespace err =
2801- "http://www.w3.org/2005/xqt-errors";
2802-declare namespace fots =
2803- "http://www.w3.org/2010/09/qt-fots-catalog";
2804-
2805-declare namespace ann =
2806- "http://www.zorba-xquery.com/annotations";
2807-
2808-
2809-(:~
2810- : The serialization parameters for XML serialization.
2811- :)
2812- declare variable $util:serParamXml :=
2813- <output:serialization-parameters>
2814- <output:method value="xml" />
2815- <output:indent value="no" />
2816- <output:omit-xml-declaration value="yes" />
2817- </output:serialization-parameters>;
2818-
2819-(:~
2820- : The serialization parameters for XML serialization.
2821- :)
2822- declare variable $util:writeXML :=
2823- <output:serialization-parameters>
2824- <output:method value="xml" />
2825- <output:indent value="yes" />
2826- <output:omit-xml-declaration value="no" />
2827- </output:serialization-parameters>;
2828-
2829-(:~
2830- : Retrieve the value of from the given node that is either given as text node
2831- : or in a file attribute.
2832- :
2833- : @param $case test-case element.
2834- : @param $path the path of the test-set.
2835- : @return the query text.
2836- :)
2837-declare %ann:nondeterministic function util:get-value(
2838- $case as element(fots:test-case),
2839- $envBaseURI as xs:anyURI,
2840- $node-name as xs:string
2841-) as xs:string {
2842- try {
2843- for $node in $case/descendant-or-self::*
2844- where (fn:local-name-from-QName(fn:node-name($node)) = $node-name)
2845- return
2846- if(exists($node/@file))
2847- then fn:unparsed-text(resolve-uri($node/@file, $envBaseURI))
2848- else fn:data($node)
2849- } catch * {
2850- fn:error($fots-err:errNA, $err:description)
2851- }
2852-};
2853-
2854-(:~
2855- : returns the parent folder of the given file path.
2856- : example: util:parent-folder('/home/user/file.ext') returns '/home/user'.
2857- : @param $path Path.
2858- : @return the parent folder of the given file.
2859- :)
2860-
2861-declare function util:parent-folder(
2862- $path as xs:string
2863-) as xs:anyURI {
2864- xs:anyURI(fn:substring-before($path,
2865- file:base-name($path)))
2866-};
2867-
2868-declare function util:serialize-result(
2869- $result as item()*
2870-) as xs:string* {
2871-util:serialize-result($result,
2872- $util:serParamXml)
2873-};
2874-
2875-declare function util:serialize-result(
2876- $result as item()*,
2877- $SerParams
2878-) as xs:string* {
2879- for $res in $result
2880- return
2881- if($res instance of node())
2882- then fn:serialize($res,
2883- $SerParams)
2884- else fn:string($res)
2885-};

Subscribers

People subscribed via source and target branches