Merge lp:~zorba-coders/zorba/bug1123016 into lp:zorba

Proposed by Juan Zacarias
Status: Merged
Approved by: Chris Hillery
Approved revision: 11311
Merged at revision: 11357
Proposed branch: lp:~zorba-coders/zorba/bug1123016
Merge into: lp:zorba
Diff against target: 1208 lines (+618/-151)
22 files modified
modules/xqxq/CMakeLists.txt (+1/-1)
modules/xqxq/xqxq.xq (+75/-1)
modules/xqxq/xqxq.xq.src/xqxq.cpp (+130/-2)
modules/xqxq/xqxq.xq.src/xqxq.h (+128/-47)
src/compiler/api/compilercb.cpp (+1/-0)
test/fots/CMakeLists.txt (+3/-1)
test/fots/ImportFOTS.cmake (+2/-0)
test/fots/get-tests.xq (+0/-1)
test/fots_driver/README.TXT (+20/-15)
test/fots_driver/cli.xq (+36/-21)
test/fots_driver/execute.xq (+95/-0)
test/fots_driver/feedback.xq (+6/-8)
test/fots_driver/fots-driver.xq (+33/-53)
test/fots_driver/reporting.xq (+2/-1)
test/rbkt/ExpQueryResults/zorba/xqxq/query-plan.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/xqxq/query-plan2.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/xqxq/query-plan3.xml.res (+1/-0)
test/rbkt/Queries/zorba/xqxq/query-plan.xq (+6/-0)
test/rbkt/Queries/zorba/xqxq/query-plan2.xq (+20/-0)
test/rbkt/Queries/zorba/xqxq/query-plan3.xq (+28/-0)
test/rbkt/Queries/zorba/xqxq/query-plan4.spec (+1/-0)
test/rbkt/Queries/zorba/xqxq/query-plan4.xq (+28/-0)
To merge this branch: bzr merge lp:~zorba-coders/zorba/bug1123016
Reviewer Review Type Date Requested Status
Chris Hillery Approve
Matthias Brantner Approve
Review via email: mp+155082@code.launchpad.net

Commit message

Implmentation of two new functions for xqxq module xqxq:query-plan and xqxq:load-from-query-plan

Description of the change

Implmentation of two new functions for xqxq module xqxq:query-plan and xqxq:load-from-query-plan

To post a comment you must log in.
Revision history for this message
Matthias Brantner (matthias-brantner) wrote :

- nice job
- comments of the functions in xqxq.xq are missing
- std::stringstream* lExcPlan = new std::stringstream();
  will leak if saveExecutionPlan returns false or raises an error. You should use an auto_ptr or something similar
- Chris do you have ideas for better/nicer function names?

review: Needs Fixing
Revision history for this message
Juan Zacarias (juan457) wrote :

I added the comments and changed std::stringstream to an auto_ptr.

For names of the function something simple like xqxq:get-serialized-query and xqxq:load-serialized-query could work in my opnion

Revision history for this message
Matthias Brantner (matthias-brantner) wrote :

- in the documentation, I wouldn't use the word serialized because it's heavily overloaded
- xs:Base64Binary => xs:base64Binary
- why does the xqxq:query-plan function raise xqxq:UnboundVariable or xqxq:UndeclaredVariable?

Revision history for this message
Matthias Brantner (matthias-brantner) :
review: Needs Fixing
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 bug1123016-2013-03-26T01-17-05.571Z 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, Needs Information < 1, Resubmit < 1. Got: 1 Needs Fixing, 1 Pending.

Revision history for this message
Juan Zacarias (juan457) wrote :

> - in the documentation, I wouldn't use the word serialized because it's
> heavily overloaded
I removed the world serialized and just mentioned it was being returned as xs:base64binary.

> - xs:Base64Binary => xs:base64Binary
typo corrected.

> - why does the xqxq:query-plan function raise xqxq:UnboundVariable or
> xqxq:UndeclaredVariable?
Sorry this was an error, I copied the comments from another function to keep the comment and forgot to remove the extra errors. This was removed from the documentation.

Revision history for this message
Matthias Brantner (matthias-brantner) :
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 bug1123016-2013-03-27T15-09-04.172Z 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, Needs Information < 1, Resubmit < 1. Got: 1 Approve, 1 Pending.

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 bug1123016-2013-04-09T14-40-52.746Z 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, Needs Information < 1, Resubmit < 1. Got: 1 Approve, 1 Pending.

Revision history for this message
Chris Hillery (ceejatec) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.

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 bug1123016-2013-04-09T23-53-53.996Z 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 'modules/xqxq/CMakeLists.txt'
2--- modules/xqxq/CMakeLists.txt 2012-10-25 00:07:03 +0000
3+++ modules/xqxq/CMakeLists.txt 2013-04-09 23:43:20 +0000
4@@ -12,4 +12,4 @@
5 # See the License for the specific language governing permissions and
6 # limitations under the License.
7
8-DECLARE_ZORBA_MODULE (URI "http://www.zorba-xquery.com/modules/xqxq" VERSION 1.0 FILE "xqxq.xq")
9\ No newline at end of file
10+DECLARE_ZORBA_MODULE (URI "http://www.zorba-xquery.com/modules/xqxq" VERSION 2.0 FILE "xqxq.xq")
11\ No newline at end of file
12
13=== modified file 'modules/xqxq/xqxq.xq'
14--- modules/xqxq/xqxq.xq 2013-03-15 18:25:44 +0000
15+++ modules/xqxq/xqxq.xq 2013-04-09 23:43:20 +0000
16@@ -30,7 +30,7 @@
17 declare namespace op = "http://www.zorba-xquery.com/options/features";
18 declare namespace f = "http://www.zorba-xquery.com/features";
19
20-declare option ver:module-version "1.0";
21+declare option ver:module-version "2.0";
22
23 (:~
24 : The function prepares a given XQuery program for execution.
25@@ -386,6 +386,80 @@
26 declare function xqxq:variable-value($query-key as xs:anyURI, $var-name as
27 xs:QName) as item()* external;
28
29+(:~
30+ : Returns the compiled query identified by the given query-key
31+ : as binary data.
32+ :
33+ : @param $query-key the identifier of a compiled query.
34+ :
35+ : @return the query as xs:base64Binary.
36+ :
37+ : @error xqxq:NoQueryMatch if no query with the given identifier
38+ : was prepared.
39+ : @error xqxq:QueryPlanError if there is an error serializing the query.
40+ :)
41+declare function xqxq:query-plan($query-key as xs:anyURI)
42+ as xs:base64Binary external;
43+
44+
45+(:~
46+ : The function loads a given XQuery program for execution from a
47+ : xs:base64Binary query plan, obtained through the xqxq:query-plan function.
48+ : If the program was successfully loaded, the function returns an
49+ : identifier as xs:anyURI. This URI can be passed to other functions
50+ : of this module (e.g. to actually evaluate the program). The URI
51+ : is opaque and its lifetime is bound by the lifetime of the XQuery
52+ : program that invoked this function. Further reference or uses
53+ : of the identifier lead to unexpected results.
54+ :
55+ : Successfully prepared queries need to be deleted by passing the resulting
56+ : identifier to the xqxq:delete-query function of this module.
57+ :
58+ : @param $main-module-text the XQuery program that should be prepared.
59+ : The program needs to be a XQuery main module.
60+ :
61+ : @return an identifier for the compiled program that can be passed
62+ : as arguments to other functions of this module.
63+ :
64+ : @error any (static or type) error that may be raised during the compilation
65+ : of the query. For example, err:XPST0003 if the given XQuery program could
66+ : not be parsed.
67+ :)
68+declare function xqxq:load-from-query-plan($plan as xs:base64Binary)
69+ as xs:anyURI external;
70+
71+(:~
72+ : The function loads a given XQuery program for execution from a
73+ : xs:base64Binary query plan, obtained through the xqxq:query-plan function.
74+ : If the program was successfully loaded, the function returns an
75+ : identifier as xs:anyURI. This URI can be passed to other functions
76+ : of this module (e.g. to actually evaluate the program). The URI
77+ : is opaque and its lilfetime is bound by the lifetime of the XQuery
78+ : program that invoked this function. Further reference or uses
79+ : of the identifier lead to unexpected results.
80+ :
81+ : For important notes regarding the second and third parameters of the
82+ : function, review the comments in xqxq:prepare-main-module#3.
83+ :
84+ : Successfully prepared queries need to be deleted by passing the resulting
85+ : identifier to the xqxq:delete-query function of this module.
86+ :
87+ : @param $main-module-text the XQuery program that should be prepared.
88+ : The program needs to be a XQuery main module.
89+ :
90+ : @param $resolver the URL resolver function.
91+ :
92+ : @param $mapper the URI mapper function.
93+ :
94+ : @return an identifier for the compiled program that can be passed
95+ : as arguments to other functions of this module.
96+ :
97+ : @error any (static or type) error that may be raised during the compilation
98+ : of the query. For example, err:XPST0003 if the given XQuery program could
99+ : not be parsed.
100+ :)
101+declare function xqxq:load-from-query-plan($plan as xs:base64Binary,
102+ $resolver as item()?, $mapper as item()?) as xs:anyURI external;
103
104 (:~
105 : Internal helper function. Only necessary because of incomplete HOF
106
107=== modified file 'modules/xqxq/xqxq.xq.src/xqxq.cpp'
108--- modules/xqxq/xqxq.xq.src/xqxq.cpp 2013-03-13 16:17:38 +0000
109+++ modules/xqxq/xqxq.xq.src/xqxq.cpp 2013-04-09 23:43:20 +0000
110@@ -85,6 +85,14 @@
111 {
112 lFunc = new VariableValueFunction(this);
113 }
114+ else if (localName == "query-plan")
115+ {
116+ lFunc = new QueryPlanFunction(this);
117+ }
118+ else if (localName == "load-from-query-plan")
119+ {
120+ lFunc = new LoadFromQueryPlanFunction(this);
121+ }
122 }
123
124 return lFunc;
125@@ -325,7 +333,7 @@
126 /*******************************************************************************
127
128 ********************************************************************************/
129-void PrepareMainModuleFunction::XQXQURIMapper::mapURI(
130+void XQXQURIMapper::mapURI(
131 String aUri,
132 EntityData const* aEntityData,
133 std::vector<String>& oUris)
134@@ -376,7 +384,7 @@
135 /*******************************************************************************
136
137 ********************************************************************************/
138-Resource* PrepareMainModuleFunction::XQXQURLResolver::resolveURL(
139+Resource* XQXQURLResolver::resolveURL(
140 const String& aUrl,
141 EntityData const* aEntityData)
142 {
143@@ -964,7 +972,127 @@
144 }
145 }
146
147+/*******************************************************************************
148+
149+********************************************************************************/
150+zorba::ItemSequence_t QueryPlanFunction::evaluate(
151+ const Arguments_t& aArgs,
152+ const zorba::StaticContext* aSctx,
153+ const zorba::DynamicContext* aDctx) const
154+{
155+ String lQueryID = XQXQFunction::getOneStringArgument(aArgs,0);
156+
157+ QueryMap* lQueryMap;
158+ if (!(lQueryMap= dynamic_cast<QueryMap*>(aDctx->getExternalFunctionParameter("xqxqQueryMap"))))
159+ {
160+ throwError("NoQueryMatch", "String identifying query does not exists.");
161+ }
162+
163+ XQuery_t lQuery = getQuery(aDctx, lQueryID);
164+
165+ std::auto_ptr<std::stringstream> lExcPlan;
166+ lExcPlan.reset(new std::stringstream());
167+ if (!lQuery->saveExecutionPlan(*lExcPlan.get(), ZORBA_USE_BINARY_ARCHIVE))
168+ {
169+ throwError("QueryPlanError", "FAILED getting query execution plan.");
170+ }
171+
172+ return ItemSequence_t(new SingletonItemSequence(XQXQModule::getItemFactory()->createStreamableBase64Binary(*lExcPlan.release(), &streamReleaser)));
173+}
174
175+
176+/*******************************************************************************
177+
178+********************************************************************************/
179+zorba::ItemSequence_t LoadFromQueryPlanFunction::evaluate(
180+ const Arguments_t& aArgs,
181+ const zorba::StaticContext* aSctx,
182+ const zorba::DynamicContext* aDctx) const
183+{
184+ Item lQueryPlanItem = XQXQFunction::getItemArgument(aArgs,0);
185+ std::istream& lQueryPlanStream = lQueryPlanItem.getStream();
186+
187+ DynamicContext* lDynCtx = const_cast<DynamicContext*>(aDctx);
188+ StaticContext_t lSctxChild = aSctx->createChildContext();
189+
190+ QueryMap* lQueryMap;
191+ if (!(lQueryMap = dynamic_cast<QueryMap*>(lDynCtx->getExternalFunctionParameter("xqxqQueryMap"))))
192+ {
193+ lQueryMap = new QueryMap();
194+ lDynCtx->addExternalFunctionParameter("xqxqQueryMap", lQueryMap);
195+ }
196+
197+ Zorba* lZorba = Zorba::getInstance(0);
198+ XQuery_t lQuery;
199+
200+ std::auto_ptr<XQXQURLResolver> lResolver;
201+ std::auto_ptr<XQXQURIMapper> lMapper;
202+ try
203+ {
204+ lQuery = lZorba->createQuery();
205+ if ( aArgs.size() > 2)
206+ {
207+ QueryPlanSerializationCallback lPlanSer;
208+
209+ Item lMapperFunctionItem = getItemArgument(aArgs, 2);
210+ if (!lMapperFunctionItem.isNull())
211+ {
212+ lMapper.reset(new XQXQURIMapper(lMapperFunctionItem, lSctxChild));
213+ lPlanSer.add_URIMapper(lMapper.get());
214+ }
215+
216+ Item lResolverFunctionItem = getItemArgument(aArgs, 1);
217+ if (!lResolverFunctionItem.isNull())
218+ {
219+ lResolver.reset(new XQXQURLResolver(lResolverFunctionItem, lSctxChild));
220+ lPlanSer.add_URLResolver(lResolver.get());
221+ }
222+
223+ lQuery->loadExecutionPlan(lQueryPlanStream, &lPlanSer);
224+ }
225+ else
226+ {
227+ lQuery->loadExecutionPlan(lQueryPlanStream);
228+ }
229+ }
230+ catch (XQueryException& xe)
231+ {
232+ lQuery = NULL;
233+ std::ostringstream err;
234+ err << "The query loaded from the query plan raised an error at"
235+ << " file" << xe.source_uri() << " line" << xe.source_line()
236+ << " column" << xe.source_column() << ": " << xe.what();
237+ Item errQName = XQXQModule::getItemFactory()->createQName(
238+ xe.diagnostic().qname().ns(),
239+ xe.diagnostic().qname().localname());
240+ throw USER_EXCEPTION(errQName, err.str());
241+ }
242+ catch (ZorbaException& ze)
243+ {
244+ lQuery = NULL;
245+ std::ostringstream err;
246+ if (ze.diagnostic() == zerr::ZCSE0013_UNABLE_TO_LOAD_QUERY)
247+ err << "The query loaded from the query plan raised an error: failed to load pre-compiled query: document, collection, or module resolver required but not given.";
248+ else
249+ err << "The query loaded from the query plan raised an error: "<< ze.what();
250+ Item errQName = XQXQModule::getItemFactory()->createQName(
251+ ze.diagnostic().qname().ns(),
252+ ze.diagnostic().qname().localname());
253+ throw USER_EXCEPTION(errQName, err.str());
254+ }
255+
256+ uuid lUUID;
257+ uuid::create(&lUUID);
258+
259+ std::stringstream lStream;
260+ lStream << lUUID;
261+
262+ String lStrUUID = lStream.str();
263+
264+ lQueryMap->storeQuery(lStrUUID, lQuery, lMapper.release(), lResolver.release());
265+ return ItemSequence_t(new SingletonItemSequence(XQXQModule::getItemFactory()->createAnyURI(lStrUUID)));
266+}
267+
268 }/*namespace xqxq*/ }/*namespace zorba*/
269
270 #ifdef WIN32
271
272=== modified file 'modules/xqxq/xqxq.xq.src/xqxq.h'
273--- modules/xqxq/xqxq.xq.src/xqxq.h 2013-02-15 06:11:20 +0000
274+++ modules/xqxq/xqxq.xq.src/xqxq.h 2013-04-09 23:43:20 +0000
275@@ -7,6 +7,7 @@
276 #include <zorba/external_module.h>
277 #include <zorba/function.h>
278 #include <zorba/dynamic_context.h>
279+#include <zorba/serialization_callback.h>
280
281 #define XQXQ_MODULE_NAMESPACE "http://www.zorba-xquery.com/modules/xqxq"
282
283@@ -51,6 +52,52 @@
284
285
286 /*******************************************************************************
287+
288+********************************************************************************/
289+class XQXQURLResolver : public URLResolver
290+{
291+protected:
292+ Item theFunction;
293+ StaticContext_t theCtx;
294+
295+public:
296+ XQXQURLResolver(Item& aFunction, StaticContext_t& aSctx)
297+ :
298+ URLResolver(),
299+ theFunction(aFunction),
300+ theCtx(aSctx)
301+ {
302+ }
303+
304+ virtual ~XQXQURLResolver() { }
305+
306+ virtual Resource* resolveURL(const String& url, EntityData const* entityData);
307+};
308+
309+
310+class XQXQURIMapper : public URIMapper
311+{
312+protected:
313+ Item theFunction;
314+ StaticContext_t theCtx;
315+
316+public:
317+ XQXQURIMapper(Item& aFunction, StaticContext_t& aSctx)
318+ :
319+ URIMapper(),
320+ theFunction(aFunction),
321+ theCtx(aSctx)
322+ {
323+ }
324+
325+ virtual ~XQXQURIMapper(){ }
326+
327+ virtual void mapURI(
328+ const zorba::String aUri,
329+ EntityData const* aEntityData,
330+ std::vector<zorba::String>& oUris);
331+};
332+/*******************************************************************************
333 Bag class for objects associated with a prepared query
334 ********************************************************************************/
335 class QueryData : public SmartObject
336@@ -144,52 +191,6 @@
337 evaluate(const Arguments_t&,
338 const zorba::StaticContext*,
339 const zorba::DynamicContext*) const;
340-
341-protected:
342-
343- class XQXQURLResolver : public URLResolver
344- {
345- protected:
346- Item theFunction;
347- StaticContext_t theCtx;
348-
349- public:
350- XQXQURLResolver(Item& aFunction, StaticContext_t& aSctx)
351- :
352- URLResolver(),
353- theFunction(aFunction),
354- theCtx(aSctx)
355- {
356- }
357-
358- virtual ~XQXQURLResolver() { }
359-
360- virtual Resource* resolveURL(const String& url, EntityData const* entityData);
361- };
362-
363-
364- class XQXQURIMapper : public URIMapper
365- {
366- protected:
367- Item theFunction;
368- StaticContext_t theCtx;
369-
370- public:
371- XQXQURIMapper(Item& aFunction, StaticContext_t& aSctx)
372- :
373- URIMapper(),
374- theFunction(aFunction),
375- theCtx(aSctx)
376- {
377- }
378-
379- virtual ~XQXQURIMapper(){ }
380-
381- virtual void mapURI(
382- const zorba::String aUri,
383- EntityData const* aEntityData,
384- std::vector<zorba::String>& oUris);
385- };
386 };
387
388
389@@ -561,7 +562,87 @@
390 const zorba::DynamicContext*) const;
391 };
392
393-
394+/*******************************************************************************
395+
396+********************************************************************************/
397+class QueryPlanFunction : public XQXQFunction
398+{
399+public:
400+ QueryPlanFunction(const XQXQModule* aModule) : XQXQFunction(aModule) {}
401+
402+ virtual ~QueryPlanFunction() {}
403+
404+ virtual zorba::String
405+ getLocalName() const {return "query-plan"; }
406+
407+ virtual zorba::ItemSequence_t
408+ evaluate(const Arguments_t&,
409+ const zorba::StaticContext*,
410+ const zorba::DynamicContext*) const;
411+
412+ virtual String getURI() const {
413+ return theModule->getURI();
414+ }
415+
416+protected:
417+ const XQXQModule* theModule;
418+};
419+
420+
421+/*******************************************************************************
422+
423+********************************************************************************/
424+class LoadFromQueryPlanFunction : public XQXQFunction
425+{
426+public:
427+ LoadFromQueryPlanFunction(const XQXQModule* aModule) : XQXQFunction(aModule) {}
428+
429+ virtual ~LoadFromQueryPlanFunction() {}
430+
431+ virtual zorba::String
432+ getLocalName() const {return "load-from-query-plan"; }
433+
434+ virtual zorba::ItemSequence_t
435+ evaluate(const Arguments_t&,
436+ const zorba::StaticContext*,
437+ const zorba::DynamicContext*) const;
438+
439+ virtual String getURI() const {
440+ return theModule->getURI();
441+ }
442+
443+protected:
444+ const XQXQModule* theModule;
445+
446+ class QueryPlanSerializationCallback : public zorba::SerializationCallback
447+ {
448+ std::vector<URIMapper*> theUriMappers;
449+ std::vector<URLResolver*>theUrlResolvers;
450+
451+ public:
452+ QueryPlanSerializationCallback()
453+ {
454+ }
455+
456+ virtual ~QueryPlanSerializationCallback() {}
457+
458+ void add_URIMapper(URIMapper* aMapper)
459+ {
460+ theUriMappers.push_back(aMapper);
461+ }
462+
463+ void add_URLResolver(URLResolver* aResolver)
464+ {
465+ theUrlResolvers.push_back(aResolver);
466+ }
467+
468+ virtual URIMapper*
469+ getURIMapper(size_t i ) const { return theUriMappers.size() < i? NULL : theUriMappers[i]; }
470+
471+ virtual URLResolver*
472+ getURLResolver(size_t i) const { return theUrlResolvers.size() < i? NULL : theUrlResolvers[i]; }
473+ };
474+};
475 }/*xqxq namespace*/}/*zorba namespace*/
476
477
478
479=== modified file 'src/compiler/api/compilercb.cpp'
480--- src/compiler/api/compilercb.cpp 2013-03-22 00:49:51 +0000
481+++ src/compiler/api/compilercb.cpp 2013-04-09 23:43:20 +0000
482@@ -199,6 +199,7 @@
483 ar & theIsEval;
484 ar & theIsLoadProlog;
485 ar & theIsUpdating;
486+ ar & theIsSequential;
487 ar & theSctxMap;
488 ar & theRootSctx;
489 #ifdef ZORBA_WITH_DEBUGGER
490
491=== modified file 'test/fots/CMakeLists.txt'
492--- test/fots/CMakeLists.txt 2013-04-08 22:59:58 +0000
493+++ test/fots/CMakeLists.txt 2013-04-09 23:43:20 +0000
494@@ -17,7 +17,9 @@
495 COMMAND "${CMAKE_COMMAND}"
496 -D "ZORBA=${ZORBA_EXE}"
497 -D "BUILDDIR=${PROJECT_BINARY_DIR}"
498- -P "${CMAKE_CURRENT_SOURCE_DIR}/ImportFOTS.cmake")
499+ -P "${CMAKE_CURRENT_SOURCE_DIR}/ImportFOTS.cmake"
500+ COMMAND "${CMAKE_COMMAND}" "${PROJECT_SOURCE_DIR}"
501+ WORKING_DIRECTORY "${PROJECT_BINARY_DIR}")
502
503 # Create cached version of activate setting
504 SET (ZORBA_FOTS_ACTIVATE inactive CACHE STRING "Which FOTS tests to activate")
505
506=== modified file 'test/fots/ImportFOTS.cmake'
507--- test/fots/ImportFOTS.cmake 2013-04-09 15:17:58 +0000
508+++ test/fots/ImportFOTS.cmake 2013-04-09 23:43:20 +0000
509@@ -82,6 +82,7 @@
510 "-e mode:=run-test-set -e testSetName:=${_testset} "
511 "-e expectedFailuresPath:=${BUILDDIR}/FOTSExpectedFailures.xml "
512 "-e verbose:=true "
513+ "-e usePlanSerializer:=true "
514 "--disable-http-resolution --indent "
515 "-z \"cdata-section-elements=${FOTS_CDATA_ELEMENTS}\")\n"
516 "ZORBA_SET_TEST_PROPERTY (FOTS/${_testset} "
517@@ -109,6 +110,7 @@
518 "-e testSetName:=${_testset} -e testCaseName:=${_testcase} "
519 "-e expectedFailuresPath:=${BUILDDIR}/FOTSExpectedFailures.xml "
520 "-e verbose:=true "
521+ "-e usePlanSerializer:=true "
522 "--disable-http-resolution --indent "
523 "-z \"cdata-section-elements=${FOTS_CDATA_ELEMENTS}\")\n"
524 "ZORBA_SET_TEST_PROPERTY (FOTS/${_testset}/${_testcase} "
525
526=== modified file 'test/fots/get-tests.xq'
527--- test/fots/get-tests.xq 2012-12-05 09:12:38 +0000
528+++ test/fots/get-tests.xq 2013-04-09 23:43:20 +0000
529@@ -16,7 +16,6 @@
530
531 declare namespace c = "http://www.w3.org/2010/09/qt-fots-catalog";
532
533-declare variable $fotsPath as xs:string external := "";
534 declare variable $testSet as xs:string external := "";
535
536 let $catalog := fn:doc(fn:static-base-uri())/c:catalog
537
538=== modified file 'test/fots_driver/README.TXT'
539--- test/fots_driver/README.TXT 2013-02-22 10:41:13 +0000
540+++ test/fots_driver/README.TXT 2013-04-09 23:43:20 +0000
541@@ -27,6 +27,10 @@
542 If you run Zorba from a checkout of the trunk and the build/bin folder,
543 - /path/to/cli.xq can be set to ../../test/fots_driver/cli.xq
544
545+'fotsPath' is set by default to the location where 'make fots-import' added the FOTS snapshot.
546+Currently this location is ZORBA_BUILD_FOLDER/test/fots/2011/QT3-test-suite/catalog.xml.
547+If you want to use other location please set 'fotsPath'.
548+
549 Always try to output the result back to an XML file with nice indentation:
550 ./zorba -f -q ../../test/fots_driver/cli.xq -e SET_CLI_OPTIONS_HERE -o output.xml --indent
551
552@@ -37,20 +41,21 @@
553 is written down into a query_TESTCASENAME.xq file, where TESTCASENAME is
554 the test case name.
555
556-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
557+zorba -f -q /path/to/cli.xq -e fotsZorbaManifestPath:=/path/to/Zorba_manifest.xml -e mode:=list-test-sets
558 zorba -f -q /path/to/cli.xq -e fotsPath:=/path/to/QT3-test-suite/catalog.xml -e mode:=list-test-sets
559-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
560-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
561-zorba -f -q /path/to/cli.xq -e fotsPath:=/path/to/QT3-test-suite/catalog.xml -e mode:=list-test-cases -e dependency:=higherOrderFunctions
562-zorba -f -q /path/to/cli.xq -e fotsPath:=/path/to/QT3-test-suite/catalog.xml -e mode:=list-test-cases -e dependency:=higherOrderFunctions -e assertions:=assert-count
563-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
564-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
565-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 expectedFailuresPath:=ExpectedFailures.xml -o result.xml --indent
566-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
567-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 assertions:=assert-count -o result.xml --indent
568-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:=true -o result.xml --indent
569-zorba -f -q /path/to/cli.xq -e fotsPath:=/path/to/QT3-test-suite/catalog.xml -e mode:=run-test-set -e testSetName:=fn-matches -o result.xml --indent
570-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
571-zorba -f -q /path/to/cli.xq -e fotsPath:=/path/to/QT3-test-suite/catalog.xml -e mode:=run-and-report -o results_Zorba_XQ30.xml --indent --disable-http-resolution
572-zorba -f -q /path/to/cli.xq -e fotsPath:=/path/to/QT3-test-suite/catalog.xml -e mode:=report -e resultsFilePath:=results.xml -o results_Zorba_XQ30.xml --indent
573+zorba -f -q /path/to/cli.xq -e mode:=list-test-sets -e testSetPrefixes:=prod,app
574+zorba -f -q /path/to/cli.xq -e mode:=list-test-cases -e testSetPrefixes:=prod-Literal
575+zorba -f -q /path/to/cli.xq -e mode:=list-test-cases -e dependency:=higherOrderFunctions
576+zorba -f -q /path/to/cli.xq -e mode:=list-test-cases -e dependency:=higherOrderFunctions -e assertions:=assert-count
577+zorba -f -q /path/to/cli.xq -e mode:=list-matching-test-cases -e pattern:=catch
578+zorba -f -q /path/to/cli.xq -e mode:=run-test-sets -e testSetPrefixes:=prod -o result.xml --indent
579+zorba -f -q /path/to/cli.xq -e mode:=run-test-sets -e testSetPrefixes:=prod -e expectedFailuresPath:=ExpectedFailures.xml -o result.xml --indent
580+zorba -f -q /path/to/cli.xq -e mode:=run-test-sets -e testSetPrefixes:=prod -e dependency:=higherOrderFunctions_false -o result.xml --indent
581+zorba -f -q /path/to/cli.xq -e mode:=run-test-sets -e testSetPrefixes:=prod -e assertions:=assert-count -o result.xml --indent
582+zorba -f -q /path/to/cli.xq -e mode:=run-test-sets -e testSetPrefixes:=prod-Literal -e verbose:=true -o result.xml --indent
583+zorba -f -q /path/to/cli.xq -e mode:=run-test-set -e testSetName:=fn-matches -o result.xml --indent
584+zorba -f -q /path/to/cli.xq -e mode:=run-test-set -e testSetName:=fn-matches -e usePlanSerializer:=true -o result.xml --indent
585+zorba -f -q /path/to/cli.xq -e mode:=run-test-case -e testSetName:=prod-Literal -e testCaseName:=Literals001 -o result.xml --indent
586+zorba -f -q /path/to/cli.xq -e mode:=run-and-report -o results_Zorba_XQ30.xml --indent --disable-http-resolution
587+zorba -f -q /path/to/cli.xq -e mode:=report -e resultsFilePath:=results.xml -o results_Zorba_XQ30.xml --indent
588 zorba -f -q /path/to/cli.xq -e mode:=generate-expected-failures -e resultsFilePath:=failures.xml -o ExpectedFailures.xml --indent
589
590=== modified file 'test/fots_driver/cli.xq'
591--- test/fots_driver/cli.xq 2013-04-03 07:40:51 +0000
592+++ test/fots_driver/cli.xq 2013-04-09 23:43:20 +0000
593@@ -184,6 +184,13 @@
594 declare variable $verbose as xs:string external := "false";
595
596
597+(:~
598+ : Enable or disable plan serializer usage. When this is set to true the query
599+ : plan is saved then loaded and executed by XQXQ.
600+ :)
601+declare variable $usePlanSerializer as xs:string external := "false";
602+
603+
604 declare function local:usage() as xs:string
605 {
606 string-join((
607@@ -191,6 +198,10 @@
608 "If you run Zorba from a checkout of the trunk and the build/bin folder,",
609 "- /path/to/cli.xq can be set to ../../test/fots_driver/cli.xq",
610 "",
611+ "'fotsPath' is set by default to the location where 'make fots-import' added the FOTS snapshot.",
612+ "Currently this location is ZORBA_BUILD_FOLDER/test/fots/2011/QT3-test-suite/catalog.xml.",
613+ "If you want to use other location please set 'fotsPath'.",
614+ "",
615 "Always try to output the result back to an XML file with nice indentation:",
616 "./zorba -f -q ../../test/fots_driver/cli.xq -e SET_CLI_OPTIONS_HERE -o output.xml --indent",
617 "",
618@@ -201,22 +212,23 @@
619 " is written down into a query_TESTCASENAME.xq file, where TESTCASENAME is",
620 " the test case name.",
621 "",
622- "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",
623+ "zorba -f -q /path/to/cli.xq -e fotsZorbaManifestPath:=/path/to/Zorba_manifest.xml -e mode:=list-test-sets",
624 "zorba -f -q /path/to/cli.xq -e fotsPath:=/path/to/QT3-test-suite/catalog.xml -e mode:=list-test-sets",
625- "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",
626- "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",
627- "zorba -f -q /path/to/cli.xq -e fotsPath:=/path/to/QT3-test-suite/catalog.xml -e mode:=list-test-cases -e dependency:=higherOrderFunctions",
628- "zorba -f -q /path/to/cli.xq -e fotsPath:=/path/to/QT3-test-suite/catalog.xml -e mode:=list-test-cases -e dependency:=higherOrderFunctions -e assertions:=assert-count",
629- "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",
630- "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",
631- "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 expectedFailuresPath:=ExpectedFailures.xml -o result.xml --indent",
632- "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",
633- "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 assertions:=assert-count -o result.xml --indent",
634- "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:=true -o result.xml --indent",
635- "zorba -f -q /path/to/cli.xq -e fotsPath:=/path/to/QT3-test-suite/catalog.xml -e mode:=run-test-set -e testSetName:=fn-matches -o result.xml --indent",
636- "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",
637- "zorba -f -q /path/to/cli.xq -e fotsPath:=/path/to/QT3-test-suite/catalog.xml -e mode:=run-and-report -o results_Zorba_XQ30.xml --indent --disable-http-resolution",
638- "zorba -f -q /path/to/cli.xq -e fotsPath:=/path/to/QT3-test-suite/catalog.xml -e mode:=report -e resultsFilePath:=results.xml -o results_Zorba_XQ30.xml --indent",
639+ "zorba -f -q /path/to/cli.xq -e mode:=list-test-sets -e testSetPrefixes:=prod,app",
640+ "zorba -f -q /path/to/cli.xq -e mode:=list-test-cases -e testSetPrefixes:=prod-Literal",
641+ "zorba -f -q /path/to/cli.xq -e mode:=list-test-cases -e dependency:=higherOrderFunctions",
642+ "zorba -f -q /path/to/cli.xq -e mode:=list-test-cases -e dependency:=higherOrderFunctions -e assertions:=assert-count",
643+ "zorba -f -q /path/to/cli.xq -e mode:=list-matching-test-cases -e pattern:=catch",
644+ "zorba -f -q /path/to/cli.xq -e mode:=run-test-sets -e testSetPrefixes:=prod -o result.xml --indent",
645+ "zorba -f -q /path/to/cli.xq -e mode:=run-test-sets -e testSetPrefixes:=prod -e expectedFailuresPath:=ExpectedFailures.xml -o result.xml --indent",
646+ "zorba -f -q /path/to/cli.xq -e mode:=run-test-sets -e testSetPrefixes:=prod -e dependency:=higherOrderFunctions_false -o result.xml --indent",
647+ "zorba -f -q /path/to/cli.xq -e mode:=run-test-sets -e testSetPrefixes:=prod -e assertions:=assert-count -o result.xml --indent",
648+ "zorba -f -q /path/to/cli.xq -e mode:=run-test-sets -e testSetPrefixes:=prod-Literal -e verbose:=true -o result.xml --indent",
649+ "zorba -f -q /path/to/cli.xq -e mode:=run-test-set -e testSetName:=fn-matches -o result.xml --indent",
650+ "zorba -f -q /path/to/cli.xq -e mode:=run-test-set -e testSetName:=fn-matches -e usePlanSerializer:=true -o result.xml --indent",
651+ "zorba -f -q /path/to/cli.xq -e mode:=run-test-case -e testSetName:=prod-Literal -e testCaseName:=Literals001 -o result.xml --indent",
652+ "zorba -f -q /path/to/cli.xq -e mode:=run-and-report -o results_Zorba_XQ30.xml --indent --disable-http-resolution",
653+ "zorba -f -q /path/to/cli.xq -e mode:=report -e resultsFilePath:=results.xml -o results_Zorba_XQ30.xml --indent",
654 "zorba -f -q /path/to/cli.xq -e mode:=generate-expected-failures -e resultsFilePath:=failures.xml -o ExpectedFailures.xml --indent",
655 ""
656 ), "&#xA;")
657@@ -307,7 +319,7 @@
658 trace($dependency, "'dependency' set to:");
659 trace($assertions, "'assertions' set to: ");
660 trace($verbose, "'verbose' set to:");
661- trace($mode, "Cli command was set to:");
662+ trace($mode, "Cli command set to:");
663
664 d:run-fots($fotsPath,
665 $fotsZorbaManifestPath,
666@@ -319,7 +331,8 @@
667 $assertions,
668 xs:boolean($verbose),
669 $expectedFailuresPath,
670- $mode)
671+ $mode,
672+ xs:boolean($usePlanSerializer))
673 }
674
675 case "run-test-set"
676@@ -329,7 +342,7 @@
677 trace($dependency, "'dependency' set to:");
678 trace($assertions, "'assertions' set to: ");
679 trace($verbose, "'verbose' set to:");
680- trace($mode, "Cli command was set to:");
681+ trace($mode, "Cli command set to:");
682
683 d:run-test-set($fotsPath,
684 $fotsZorbaManifestPath,
685@@ -341,7 +354,8 @@
686 $assertions,
687 xs:boolean($verbose),
688 $expectedFailuresPath,
689- $mode)
690+ $mode,
691+ xs:boolean($usePlanSerializer))
692 }
693
694 case "run-test-case"
695@@ -350,7 +364,7 @@
696 trace($testSetName, $testSetNameMsg);
697 trace($testCaseName, $testCaseNameMsg);
698 trace($verbose, "'verbose' set to:");
699- trace($mode, "Cli command was set to:");
700+ trace($mode, "Cli command set to:");
701
702 d:run-fots($fotsPath,
703 $fotsZorbaManifestPath,
704@@ -362,7 +376,8 @@
705 (),
706 xs:boolean($verbose),
707 $expectedFailuresPath,
708- $mode)
709+ $mode,
710+ xs:boolean($usePlanSerializer))
711 }
712
713 case "run-and-report"
714
715=== added file 'test/fots_driver/execute.xq'
716--- test/fots_driver/execute.xq 1970-01-01 00:00:00 +0000
717+++ test/fots_driver/execute.xq 2013-04-09 23:43:20 +0000
718@@ -0,0 +1,95 @@
719+(:
720+ : Copyright 2006-2011 The FLWOR Foundation.
721+ :
722+ : Licensed under the Apache License, Version 2.0 (the "License");
723+ : you may not use this file except in compliance with the License.
724+ : You may obtain a copy of the License at
725+ :
726+ : http://www.apache.org/licenses/LICENSE-2.0
727+ :
728+ : Unless required by applicable law or agreed to in writing, software
729+ : distributed under the License is distributed on an "AS IS" BASIS,
730+ : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
731+ : See the License for the specific language governing permissions and
732+ : limitations under the License.
733+ :)
734+
735+(:~
736+ : Zorba FOTS driver execute
737+ : @author Sorin Nasoi
738+ :)
739+
740+module namespace execute =
741+ "http://www.zorba-xquery.com/fots-driver/execute";
742+
743+import module namespace xqxq =
744+ "http://www.zorba-xquery.com/modules/xqxq#2.0";
745+
746+import module namespace eval =
747+ "http://www.zorba-xquery.com/fots-driver/evaluate" at "evaluate.xq";
748+
749+declare namespace fots =
750+ "http://www.w3.org/2010/09/qt-fots-catalog";
751+
752+declare namespace err =
753+ "http://www.w3.org/2005/xqt-errors";
754+
755+declare namespace ann =
756+ "http://www.zorba-xquery.com/annotations";
757+
758+
759+declare namespace op = "http://www.zorba-xquery.com/options/features";
760+declare namespace f = "http://www.zorba-xquery.com/features";
761+declare option op:disable "f:trace";
762+
763+(:~
764+ : XQXQ invoke.
765+ : @param $xqxqQueryText the query that will be run.
766+ : @param $case the test case.
767+ : @param $verbose if set to TRUE it will also output the actual result.
768+ : @param $testSetBaseURI the URI of the directory that contains the file of the
769+ associated test set.
770+ : @param $usePlanSerializer if true the plan serializer is used.
771+ : @return the result of running the query with XQXQ.
772+ :)
773+declare %ann:sequential function execute:xqxq-invoke(
774+ $xqxqQueryText as xs:string,
775+ $case as element(fots:test-case),
776+ $verbose as xs:boolean?,
777+ $testSetBaseURI as xs:anyURI,
778+ $usePlanSerializer as xs:boolean
779+)
780+{
781+ try
782+ {
783+ if($usePlanSerializer) then
784+ {
785+ variable $queryKey := xqxq:prepare-main-module($xqxqQueryText);
786+ variable $queryPlan := xqxq:query-plan($queryKey);
787+ variable $queryPlanKey := xqxq:load-from-query-plan($queryPlan);
788+ variable $queryResult := xqxq:evaluate-sequential($queryPlanKey);
789+
790+ xqxq:delete-query($queryPlanKey);
791+ xqxq:delete-query($queryKey);
792+
793+ eval:result($queryResult, $case/fots:result/*, $testSetBaseURI)
794+ }
795+ else
796+ {
797+ variable $queryKey := xqxq:prepare-main-module($xqxqQueryText);
798+ variable $queryResult := xqxq:evaluate-sequential($queryKey);
799+
800+ xqxq:delete-query($queryKey);
801+
802+ eval:result($queryResult, $case/fots:result/*, $testSetBaseURI)
803+ }
804+ }
805+ catch *
806+ {
807+ eval:error((),
808+ $case/fots:result/*,
809+ $err:code,
810+ $err:description,
811+ $testSetBaseURI)
812+ }
813+};
814
815=== modified file 'test/fots_driver/feedback.xq'
816--- test/fots_driver/feedback.xq 2013-03-29 06:15:19 +0000
817+++ test/fots_driver/feedback.xq 2013-04-09 23:43:20 +0000
818@@ -136,15 +136,13 @@
819 : @return info about test case that passed.
820 :)
821 declare %private function feedback:pass(
822- $case as element(fots:test-case),
823- $result as item()*
824+ $case as element(fots:test-case),
825+ $result as item()*
826 ) as element(fots:test-case)?
827 {
828- let $status := if(exists($result/fots:errors))
829- then 'wrongError'
830- else 'pass'
831- return
832- <fots:test-case name="{data($case/@name)}" result="{$status}"/>
833+ if(exists($result/fots:errors))
834+ then <fots:test-case name="{data($case/@name)}" result="wrongError" comment="{$result/fots:errors}"/>
835+ else <fots:test-case name="{data($case/@name)}" result="pass"/>
836 };
837
838
839@@ -200,7 +198,7 @@
840 then <fots:test-case name="{data($case/@name)}"
841 result="{$status}"
842 comment="{$info}"/>
843-
844+
845 else <fots:test-case name="{data($case/@name)}"
846 result="{$status}"/>
847 };
848
849=== modified file 'test/fots_driver/fots-driver.xq'
850--- test/fots_driver/fots-driver.xq 2013-03-29 06:15:19 +0000
851+++ test/fots_driver/fots-driver.xq 2013-04-09 23:43:20 +0000
852@@ -25,9 +25,6 @@
853 import module namespace functx =
854 "http://www.functx.com/";
855
856-import module namespace xqxq =
857- "http://www.zorba-xquery.com/modules/xqxq";
858-
859 import module namespace datetime =
860 "http://www.zorba-xquery.com/modules/datetime";
861
862@@ -37,6 +34,9 @@
863 import module namespace feedback =
864 "http://www.zorba-xquery.com/fots-driver/feedback" at "feedback.xq";
865
866+import module namespace execute =
867+ "http://www.zorba-xquery.com/fots-driver/execute" at "execute.xq";
868+
869 import module namespace env =
870 "http://www.zorba-xquery.com/fots-driver/environment" at "environment.xq";
871
872@@ -320,6 +320,7 @@
873 : about each processed test-case.
874 : @param $expectedFailures the root node of the ExpectedFailures.xml file.
875 : @param $cliMode the cli command.
876+ : @param $usePlanSerializer if true the plan serializer is used.
877 : @return an XML tree containing info about all the processed tests-cases
878 :)
879 declare %ann:sequential function driver:run-fots(
880@@ -333,12 +334,14 @@
881 $assertions as xs:string*,
882 $verbose as xs:boolean,
883 $expectedFailuresPath as xs:string,
884- $cliMode as xs:string
885+ $cliMode as xs:string,
886+ $usePlanSerializer as xs:boolean
887 ) as element(fots:test-cases)
888 {
889 trace($fotsPath, "Path to FOTS catalog.xml was set to: ");
890 trace($zorbaManifestPath, "Path to FOTSZorbaManifest set to :");
891 trace($expectedFailuresPath, "Path to ExpectedFailures.xml set to:");
892+ trace($usePlanSerializer, "'usePlanSerializer' set to:");
893
894 try
895 {
896@@ -347,6 +350,10 @@
897 let $zorbaManifest := doc(resolve-uri($zorbaManifestPath))
898
899 let $testSetNames :=
900+ if(($cliMode = 'run-test-case') ||
901+ ($cliMode = 'run-test-set'))
902+ then $testSetPrefixes
903+ else
904 {
905 if (empty($testSetPrefixes) and empty($exceptedTestSets)) then
906 {
907@@ -414,7 +421,8 @@
908 $exceptedTestCases,
909 $verbose,
910 $expectedFailures,
911- $cliMode)
912+ $cliMode,
913+ $usePlanSerializer)
914 }
915 catch err:FODC0002
916 {
917@@ -475,6 +483,7 @@
918 : about each processed test-case.
919 : @param $expectedFailures the root node of the ExpectedFailures.xml file.
920 : @param $cliMode the cli command.
921+ : @param $usePlanSerializer if true the plan serializer is used.
922 : @return an XML tree containing info about all the processed tests-cases
923 :)
924 declare %ann:sequential function driver:run-test-set(
925@@ -488,13 +497,15 @@
926 $assertions as xs:string*,
927 $verbose as xs:boolean,
928 $expectedFailuresPath as xs:string,
929- $cliMode as xs:string
930+ $cliMode as xs:string,
931+ $usePlanSerializer as xs:boolean
932 ) as element(fots:test-cases)
933 {
934 trace($fotsPath, "Path to FOTS catalog.xml was set to: ");
935 trace($zorbaManifestPath, "Path to FOTSZorbaManifest set to :");
936 trace($expectedFailuresPath, "Path to ExpectedFailures.xml set to:");
937-
938+ trace($usePlanSerializer, "'usePlanSerializer' set to:");
939+
940 try
941 {
942 let $FOTSCatalog := doc(resolve-uri($fotsPath))
943@@ -564,7 +575,8 @@
944 $exceptedTestCases,
945 $verbose,
946 $expectedFailures,
947- $cliMode)
948+ $cliMode,
949+ $usePlanSerializer)
950 }
951 catch err:FODC0002
952 {
953@@ -615,6 +627,7 @@
954 : about each processed test-case.
955 : @param $expectedFailures the root node of the ExpectedFailures.xml file.
956 : @param $cliMode the cli command.
957+ : @param $usePlanSerializer if true the plan serializer is used.
958 : @return an XML tree containing info about all the processed tests-cases
959 :)
960 declare %private %ann:sequential function driver:run-fots(
961@@ -626,7 +639,8 @@
962 $exceptedTestCases as xs:string*,
963 $verbose as xs:boolean,
964 $expectedFailures as document-node()?,
965- $cliMode as xs:string
966+ $cliMode as xs:string,
967+ $usePlanSerializer as xs:boolean
968 ) as element(fots:test-cases)
969 {
970 <fots:test-cases>
971@@ -730,7 +744,8 @@
972 $verbose,
973 $expectedFailures//TestSet[@name eq $testSetName]/Test[@name eq $testCase/@name],
974 $cliMode,
975- $mayNeedDTDValidation)
976+ $mayNeedDTDValidation,
977+ $usePlanSerializer)
978 }
979 else
980 {
981@@ -744,7 +759,8 @@
982 $verbose,
983 $expectedFailures//TestSet[@name eq $testSetName]/Test[@name eq $testCase/@name],
984 $cliMode,
985- $mayNeedDTDValidation)
986+ $mayNeedDTDValidation,
987+ $usePlanSerializer)
988 }
989 }
990 }
991@@ -776,6 +792,7 @@
992 : @param $cliMode the cli command.
993 : @param $mayNeedDTDValidation true if the test case may need DTD validation
994 : for the document bound as context item.
995+ : @param $usePlanSerializer if true the plan serializer is used.
996 : @return an XML tree containing info about the result of running the test case.
997 :)
998 declare %ann:sequential function driver:test(
999@@ -788,7 +805,8 @@
1000 $verbose as xs:boolean,
1001 $expectedFailure as element(Test)?,
1002 $cliMode as xs:string,
1003- $mayNeedDTDValidation as xs:boolean
1004+ $mayNeedDTDValidation as xs:boolean,
1005+ $usePlanSerializer as xs:boolean
1006 ) as element(fots:test-case)?
1007 {
1008 (:TODO Cover the "(:%VARDECL%:)"when there are tests in FOTS that use it:)
1009@@ -853,10 +871,11 @@
1010
1011 variable $startDateTime := datetime:current-dateTime();
1012
1013- variable $result := driver:xqxq-invoke($xqxqQuery,
1014+ variable $result := execute:xqxq-invoke($xqxqQuery,
1015 $case,
1016 $verbose,
1017- $testSetBaseURI);
1018+ $testSetBaseURI,
1019+ $usePlanSerializer);
1020
1021 variable $duration := (datetime:current-dateTime() - $startDateTime);
1022
1023@@ -1020,42 +1039,3 @@
1024 "&#xA;"
1025 )
1026 };
1027-
1028-
1029-(:~
1030- : XQXQ invoke.
1031- : @param $xqxqQueryText the query that will be run.
1032- : @param $case the test case.
1033- : @param $verbose if set to TRUE it will also output the actual result.
1034- : @param $testSetBaseURI the URI of the directory that contains the file of the
1035- associated test set.
1036- : @return the result of running the query with XQXQ.
1037- :)
1038-declare %private %ann:sequential function driver:xqxq-invoke(
1039- $xqxqQueryText as xs:string,
1040- $case as element(fots:test-case),
1041- $verbose as xs:boolean?,
1042- $testSetBaseURI as xs:anyURI
1043-)
1044-{
1045- try
1046- {
1047- {
1048- variable $queryKey := xqxq:prepare-main-module($xqxqQueryText);
1049-
1050- variable $queryResult := xqxq:evaluate-sequential($queryKey);
1051-
1052- xqxq:delete-query($queryKey);
1053-
1054- eval:result($queryResult, $case/fots:result/*, $testSetBaseURI)
1055- }
1056- }
1057- catch *
1058- {
1059- eval:error((),
1060- $case/fots:result/*,
1061- $err:code,
1062- $err:description,
1063- $testSetBaseURI)
1064- }
1065-};
1066
1067=== modified file 'test/fots_driver/reporting.xq'
1068--- test/fots_driver/reporting.xq 2013-03-12 21:04:31 +0000
1069+++ test/fots_driver/reporting.xq 2013-04-09 23:43:20 +0000
1070@@ -89,7 +89,8 @@
1071 (),
1072 fn:false(),
1073 '',
1074- 'run-test-sets');
1075+ 'run-test-sets',
1076+ fn:false());
1077
1078 file:write("results.xml",
1079 $results,
1080
1081=== added file 'test/rbkt/ExpQueryResults/zorba/xqxq/query-plan.xml.res'
1082--- test/rbkt/ExpQueryResults/zorba/xqxq/query-plan.xml.res 1970-01-01 00:00:00 +0000
1083+++ test/rbkt/ExpQueryResults/zorba/xqxq/query-plan.xml.res 2013-04-09 23:43:20 +0000
1084@@ -0,0 +1,1 @@
1085+2
1086\ No newline at end of file
1087
1088=== added file 'test/rbkt/ExpQueryResults/zorba/xqxq/query-plan2.xml.res'
1089--- test/rbkt/ExpQueryResults/zorba/xqxq/query-plan2.xml.res 1970-01-01 00:00:00 +0000
1090+++ test/rbkt/ExpQueryResults/zorba/xqxq/query-plan2.xml.res 2013-04-09 23:43:20 +0000
1091@@ -0,0 +1,1 @@
1092+foo
1093\ No newline at end of file
1094
1095=== added file 'test/rbkt/ExpQueryResults/zorba/xqxq/query-plan3.xml.res'
1096--- test/rbkt/ExpQueryResults/zorba/xqxq/query-plan3.xml.res 1970-01-01 00:00:00 +0000
1097+++ test/rbkt/ExpQueryResults/zorba/xqxq/query-plan3.xml.res 2013-04-09 23:43:20 +0000
1098@@ -0,0 +1,1 @@
1099+foo
1100\ No newline at end of file
1101
1102=== added file 'test/rbkt/Queries/zorba/xqxq/query-plan.xq'
1103--- test/rbkt/Queries/zorba/xqxq/query-plan.xq 1970-01-01 00:00:00 +0000
1104+++ test/rbkt/Queries/zorba/xqxq/query-plan.xq 2013-04-09 23:43:20 +0000
1105@@ -0,0 +1,6 @@
1106+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
1107+
1108+variable $queryID := xqxq:prepare-main-module("1+1");
1109+variable $query-plan := xqxq:query-plan($queryID);
1110+variable $queryID2 := xqxq:load-from-query-plan($query-plan);
1111+xqxq:evaluate ($queryID2)
1112
1113=== added file 'test/rbkt/Queries/zorba/xqxq/query-plan2.xq'
1114--- test/rbkt/Queries/zorba/xqxq/query-plan2.xq 1970-01-01 00:00:00 +0000
1115+++ test/rbkt/Queries/zorba/xqxq/query-plan2.xq 2013-04-09 23:43:20 +0000
1116@@ -0,0 +1,20 @@
1117+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
1118+
1119+declare namespace resolver = 'http://www.zorba-xquery.com/modules/xqxq/url-resolver';
1120+declare namespace op = "http://www.zorba-xquery.com/options/features";
1121+declare namespace f = "http://www.zorba-xquery.com/features";
1122+
1123+declare function resolver:url-resolver($namespace as xs:string, $entity as xs:string) {
1124+ if($namespace = 'http://test.xq')
1125+ then "module namespace test = 'http://test'; declare function test:foo(){'foo'};"
1126+ else ()
1127+};
1128+
1129+variable $queryID := xqxq:prepare-main-module(
1130+ "import module namespace test = 'http://test'; test:foo()",
1131+ resolver:url-resolver#2, ());
1132+
1133+
1134+variable $query-plan := xqxq:query-plan($queryID);
1135+variable $queryID2 := xqxq:load-from-query-plan($query-plan, resolver:url-resolver#2, ());
1136+xqxq:evaluate ($queryID2)
1137
1138=== added file 'test/rbkt/Queries/zorba/xqxq/query-plan3.xq'
1139--- test/rbkt/Queries/zorba/xqxq/query-plan3.xq 1970-01-01 00:00:00 +0000
1140+++ test/rbkt/Queries/zorba/xqxq/query-plan3.xq 2013-04-09 23:43:20 +0000
1141@@ -0,0 +1,28 @@
1142+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
1143+
1144+declare namespace resolver = 'http://www.zorba-xquery.com/modules/xqxq/url-resolver';
1145+declare namespace mapper = 'http://www.zorba-xquery.com/modules/xqxq/uri-mapper';
1146+declare namespace op = "http://www.zorba-xquery.com/options/features";
1147+declare namespace f = "http://www.zorba-xquery.com/features";
1148+
1149+declare function resolver:url-resolver($namespace as xs:string, $entity as xs:string) {
1150+ if($namespace = 'http://foo')
1151+ then "module namespace test = 'http://test'; declare function test:foo(){'foo'};"
1152+ else ()
1153+};
1154+
1155+declare function mapper:uri-mapper($namespace as xs:string, $entity as xs:string)
1156+{
1157+ if($namespace = 'http://test')
1158+ then 'http://foo'
1159+ else ()
1160+};
1161+
1162+variable $queryID := xqxq:prepare-main-module
1163+(
1164+ "import module namespace test = 'http://test'; test:foo()",
1165+ resolver:url-resolver#2, mapper:uri-mapper#2
1166+);
1167+variable $query-plan := xqxq:query-plan($queryID);
1168+variable $queryID2 := xqxq:load-from-query-plan($query-plan, resolver:url-resolver#2, mapper:uri-mapper#2);
1169+xqxq:evaluate ($queryID2)
1170
1171=== added file 'test/rbkt/Queries/zorba/xqxq/query-plan4.spec'
1172--- test/rbkt/Queries/zorba/xqxq/query-plan4.spec 1970-01-01 00:00:00 +0000
1173+++ test/rbkt/Queries/zorba/xqxq/query-plan4.spec 2013-04-09 23:43:20 +0000
1174@@ -0,0 +1,1 @@
1175+Error: http://www.zorba-xquery.com/errors:ZCSE0013
1176
1177=== added file 'test/rbkt/Queries/zorba/xqxq/query-plan4.xq'
1178--- test/rbkt/Queries/zorba/xqxq/query-plan4.xq 1970-01-01 00:00:00 +0000
1179+++ test/rbkt/Queries/zorba/xqxq/query-plan4.xq 2013-04-09 23:43:20 +0000
1180@@ -0,0 +1,28 @@
1181+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
1182+
1183+declare namespace resolver = 'http://www.zorba-xquery.com/modules/xqxq/url-resolver';
1184+declare namespace mapper = 'http://www.zorba-xquery.com/modules/xqxq/uri-mapper';
1185+declare namespace op = "http://www.zorba-xquery.com/options/features";
1186+declare namespace f = "http://www.zorba-xquery.com/features";
1187+
1188+declare function resolver:url-resolver($namespace as xs:string, $entity as xs:string) {
1189+ if($namespace = 'http://foo')
1190+ then "module namespace test = 'http://test'; declare function test:foo(){'foo'};"
1191+ else ()
1192+};
1193+
1194+declare function mapper:uri-mapper($namespace as xs:string, $entity as xs:string)
1195+{
1196+ if($namespace = 'http://test')
1197+ then 'http://foo'
1198+ else ()
1199+};
1200+
1201+variable $queryID := xqxq:prepare-main-module
1202+(
1203+ "import module namespace test = 'http://test'; test:foo()",
1204+ resolver:url-resolver#2, mapper:uri-mapper#2
1205+);
1206+variable $query-plan := xqxq:query-plan($queryID);
1207+variable $queryID2 := xqxq:load-from-query-plan($query-plan);
1208+xqxq:evaluate ($queryID2)

Subscribers

People subscribed via source and target branches