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
=== modified file 'modules/xqxq/CMakeLists.txt'
--- modules/xqxq/CMakeLists.txt 2012-10-25 00:07:03 +0000
+++ modules/xqxq/CMakeLists.txt 2013-04-09 23:43:20 +0000
@@ -12,4 +12,4 @@
12# See the License for the specific language governing permissions and12# See the License for the specific language governing permissions and
13# limitations under the License.13# limitations under the License.
1414
15DECLARE_ZORBA_MODULE (URI "http://www.zorba-xquery.com/modules/xqxq" VERSION 1.0 FILE "xqxq.xq")
16\ No newline at end of file15\ No newline at end of file
16DECLARE_ZORBA_MODULE (URI "http://www.zorba-xquery.com/modules/xqxq" VERSION 2.0 FILE "xqxq.xq")
17\ No newline at end of file17\ No newline at end of file
1818
=== modified file 'modules/xqxq/xqxq.xq'
--- modules/xqxq/xqxq.xq 2013-03-15 18:25:44 +0000
+++ modules/xqxq/xqxq.xq 2013-04-09 23:43:20 +0000
@@ -30,7 +30,7 @@
30declare namespace op = "http://www.zorba-xquery.com/options/features";30declare namespace op = "http://www.zorba-xquery.com/options/features";
31declare namespace f = "http://www.zorba-xquery.com/features";31declare namespace f = "http://www.zorba-xquery.com/features";
3232
33declare option ver:module-version "1.0";33declare option ver:module-version "2.0";
3434
35(:~35(:~
36 : The function prepares a given XQuery program for execution.36 : The function prepares a given XQuery program for execution.
@@ -386,6 +386,80 @@
386declare function xqxq:variable-value($query-key as xs:anyURI, $var-name as 386declare function xqxq:variable-value($query-key as xs:anyURI, $var-name as
387 xs:QName) as item()* external;387 xs:QName) as item()* external;
388388
389(:~
390 : Returns the compiled query identified by the given query-key
391 : as binary data.
392 :
393 : @param $query-key the identifier of a compiled query.
394 :
395 : @return the query as xs:base64Binary.
396 :
397 : @error xqxq:NoQueryMatch if no query with the given identifier
398 : was prepared.
399 : @error xqxq:QueryPlanError if there is an error serializing the query.
400 :)
401declare function xqxq:query-plan($query-key as xs:anyURI)
402 as xs:base64Binary external;
403
404
405(:~
406 : The function loads a given XQuery program for execution from a
407 : xs:base64Binary query plan, obtained through the xqxq:query-plan function.
408 : If the program was successfully loaded, the function returns an
409 : identifier as xs:anyURI. This URI can be passed to other functions
410 : of this module (e.g. to actually evaluate the program). The URI
411 : is opaque and its lifetime is bound by the lifetime of the XQuery
412 : program that invoked this function. Further reference or uses
413 : of the identifier lead to unexpected results.
414 :
415 : Successfully prepared queries need to be deleted by passing the resulting
416 : identifier to the xqxq:delete-query function of this module.
417 :
418 : @param $main-module-text the XQuery program that should be prepared.
419 : The program needs to be a XQuery main module.
420 :
421 : @return an identifier for the compiled program that can be passed
422 : as arguments to other functions of this module.
423 :
424 : @error any (static or type) error that may be raised during the compilation
425 : of the query. For example, err:XPST0003 if the given XQuery program could
426 : not be parsed.
427 :)
428declare function xqxq:load-from-query-plan($plan as xs:base64Binary)
429 as xs:anyURI external;
430
431(:~
432 : The function loads a given XQuery program for execution from a
433 : xs:base64Binary query plan, obtained through the xqxq:query-plan function.
434 : If the program was successfully loaded, the function returns an
435 : identifier as xs:anyURI. This URI can be passed to other functions
436 : of this module (e.g. to actually evaluate the program). The URI
437 : is opaque and its lilfetime is bound by the lifetime of the XQuery
438 : program that invoked this function. Further reference or uses
439 : of the identifier lead to unexpected results.
440 :
441 : For important notes regarding the second and third parameters of the
442 : function, review the comments in xqxq:prepare-main-module#3.
443 :
444 : Successfully prepared queries need to be deleted by passing the resulting
445 : identifier to the xqxq:delete-query function of this module.
446 :
447 : @param $main-module-text the XQuery program that should be prepared.
448 : The program needs to be a XQuery main module.
449 :
450 : @param $resolver the URL resolver function.
451 :
452 : @param $mapper the URI mapper function.
453 :
454 : @return an identifier for the compiled program that can be passed
455 : as arguments to other functions of this module.
456 :
457 : @error any (static or type) error that may be raised during the compilation
458 : of the query. For example, err:XPST0003 if the given XQuery program could
459 : not be parsed.
460 :)
461declare function xqxq:load-from-query-plan($plan as xs:base64Binary,
462 $resolver as item()?, $mapper as item()?) as xs:anyURI external;
389463
390(:~464(:~
391 : Internal helper function. Only necessary because of incomplete HOF465 : Internal helper function. Only necessary because of incomplete HOF
392466
=== modified file 'modules/xqxq/xqxq.xq.src/xqxq.cpp'
--- modules/xqxq/xqxq.xq.src/xqxq.cpp 2013-03-13 16:17:38 +0000
+++ modules/xqxq/xqxq.xq.src/xqxq.cpp 2013-04-09 23:43:20 +0000
@@ -85,6 +85,14 @@
85 {85 {
86 lFunc = new VariableValueFunction(this);86 lFunc = new VariableValueFunction(this);
87 }87 }
88 else if (localName == "query-plan")
89 {
90 lFunc = new QueryPlanFunction(this);
91 }
92 else if (localName == "load-from-query-plan")
93 {
94 lFunc = new LoadFromQueryPlanFunction(this);
95 }
88 }96 }
89 97
90 return lFunc;98 return lFunc;
@@ -325,7 +333,7 @@
325/*******************************************************************************333/*******************************************************************************
326334
327********************************************************************************/335********************************************************************************/
328void PrepareMainModuleFunction::XQXQURIMapper::mapURI(336void XQXQURIMapper::mapURI(
329 String aUri,337 String aUri,
330 EntityData const* aEntityData,338 EntityData const* aEntityData,
331 std::vector<String>& oUris)339 std::vector<String>& oUris)
@@ -376,7 +384,7 @@
376/*******************************************************************************384/*******************************************************************************
377385
378********************************************************************************/386********************************************************************************/
379Resource* PrepareMainModuleFunction::XQXQURLResolver::resolveURL(387Resource* XQXQURLResolver::resolveURL(
380 const String& aUrl,388 const String& aUrl,
381 EntityData const* aEntityData)389 EntityData const* aEntityData)
382{ 390{
@@ -964,7 +972,127 @@
964 }972 }
965}973}
966974
975/*******************************************************************************
976
977********************************************************************************/
978zorba::ItemSequence_t QueryPlanFunction::evaluate(
979 const Arguments_t& aArgs,
980 const zorba::StaticContext* aSctx,
981 const zorba::DynamicContext* aDctx) const
982{
983 String lQueryID = XQXQFunction::getOneStringArgument(aArgs,0);
984
985 QueryMap* lQueryMap;
986 if (!(lQueryMap= dynamic_cast<QueryMap*>(aDctx->getExternalFunctionParameter("xqxqQueryMap"))))
987 {
988 throwError("NoQueryMatch", "String identifying query does not exists.");
989 }
990
991 XQuery_t lQuery = getQuery(aDctx, lQueryID);
992
993 std::auto_ptr<std::stringstream> lExcPlan;
994 lExcPlan.reset(new std::stringstream());
995 if (!lQuery->saveExecutionPlan(*lExcPlan.get(), ZORBA_USE_BINARY_ARCHIVE))
996 {
997 throwError("QueryPlanError", "FAILED getting query execution plan.");
998 }
999
1000 return ItemSequence_t(new SingletonItemSequence(XQXQModule::getItemFactory()->createStreamableBase64Binary(*lExcPlan.release(), &streamReleaser)));
1001}
967 1002
1003
1004/*******************************************************************************
1005
1006********************************************************************************/
1007zorba::ItemSequence_t LoadFromQueryPlanFunction::evaluate(
1008 const Arguments_t& aArgs,
1009 const zorba::StaticContext* aSctx,
1010 const zorba::DynamicContext* aDctx) const
1011{
1012 Item lQueryPlanItem = XQXQFunction::getItemArgument(aArgs,0);
1013 std::istream& lQueryPlanStream = lQueryPlanItem.getStream();
1014
1015 DynamicContext* lDynCtx = const_cast<DynamicContext*>(aDctx);
1016 StaticContext_t lSctxChild = aSctx->createChildContext();
1017
1018 QueryMap* lQueryMap;
1019 if (!(lQueryMap = dynamic_cast<QueryMap*>(lDynCtx->getExternalFunctionParameter("xqxqQueryMap"))))
1020 {
1021 lQueryMap = new QueryMap();
1022 lDynCtx->addExternalFunctionParameter("xqxqQueryMap", lQueryMap);
1023 }
1024
1025 Zorba* lZorba = Zorba::getInstance(0);
1026 XQuery_t lQuery;
1027
1028 std::auto_ptr<XQXQURLResolver> lResolver;
1029 std::auto_ptr<XQXQURIMapper> lMapper;
1030 try
1031 {
1032 lQuery = lZorba->createQuery();
1033 if ( aArgs.size() > 2)
1034 {
1035 QueryPlanSerializationCallback lPlanSer;
1036
1037 Item lMapperFunctionItem = getItemArgument(aArgs, 2);
1038 if (!lMapperFunctionItem.isNull())
1039 {
1040 lMapper.reset(new XQXQURIMapper(lMapperFunctionItem, lSctxChild));
1041 lPlanSer.add_URIMapper(lMapper.get());
1042 }
1043
1044 Item lResolverFunctionItem = getItemArgument(aArgs, 1);
1045 if (!lResolverFunctionItem.isNull())
1046 {
1047 lResolver.reset(new XQXQURLResolver(lResolverFunctionItem, lSctxChild));
1048 lPlanSer.add_URLResolver(lResolver.get());
1049 }
1050
1051 lQuery->loadExecutionPlan(lQueryPlanStream, &lPlanSer);
1052 }
1053 else
1054 {
1055 lQuery->loadExecutionPlan(lQueryPlanStream);
1056 }
1057 }
1058 catch (XQueryException& xe)
1059 {
1060 lQuery = NULL;
1061 std::ostringstream err;
1062 err << "The query loaded from the query plan raised an error at"
1063 << " file" << xe.source_uri() << " line" << xe.source_line()
1064 << " column" << xe.source_column() << ": " << xe.what();
1065 Item errQName = XQXQModule::getItemFactory()->createQName(
1066 xe.diagnostic().qname().ns(),
1067 xe.diagnostic().qname().localname());
1068 throw USER_EXCEPTION(errQName, err.str());
1069 }
1070 catch (ZorbaException& ze)
1071 {
1072 lQuery = NULL;
1073 std::ostringstream err;
1074 if (ze.diagnostic() == zerr::ZCSE0013_UNABLE_TO_LOAD_QUERY)
1075 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.";
1076 else
1077 err << "The query loaded from the query plan raised an error: "<< ze.what();
1078 Item errQName = XQXQModule::getItemFactory()->createQName(
1079 ze.diagnostic().qname().ns(),
1080 ze.diagnostic().qname().localname());
1081 throw USER_EXCEPTION(errQName, err.str());
1082 }
1083
1084 uuid lUUID;
1085 uuid::create(&lUUID);
1086
1087 std::stringstream lStream;
1088 lStream << lUUID;
1089
1090 String lStrUUID = lStream.str();
1091
1092 lQueryMap->storeQuery(lStrUUID, lQuery, lMapper.release(), lResolver.release());
1093 return ItemSequence_t(new SingletonItemSequence(XQXQModule::getItemFactory()->createAnyURI(lStrUUID)));
1094}
1095
968}/*namespace xqxq*/ }/*namespace zorba*/1096}/*namespace xqxq*/ }/*namespace zorba*/
9691097
970#ifdef WIN321098#ifdef WIN32
9711099
=== modified file 'modules/xqxq/xqxq.xq.src/xqxq.h'
--- modules/xqxq/xqxq.xq.src/xqxq.h 2013-02-15 06:11:20 +0000
+++ modules/xqxq/xqxq.xq.src/xqxq.h 2013-04-09 23:43:20 +0000
@@ -7,6 +7,7 @@
7#include <zorba/external_module.h>7#include <zorba/external_module.h>
8#include <zorba/function.h>8#include <zorba/function.h>
9#include <zorba/dynamic_context.h>9#include <zorba/dynamic_context.h>
10#include <zorba/serialization_callback.h>
1011
11#define XQXQ_MODULE_NAMESPACE "http://www.zorba-xquery.com/modules/xqxq"12#define XQXQ_MODULE_NAMESPACE "http://www.zorba-xquery.com/modules/xqxq"
1213
@@ -51,6 +52,52 @@
5152
5253
53/*******************************************************************************54/*******************************************************************************
55
56********************************************************************************/
57class XQXQURLResolver : public URLResolver
58{
59protected:
60 Item theFunction;
61 StaticContext_t theCtx;
62
63public:
64 XQXQURLResolver(Item& aFunction, StaticContext_t& aSctx)
65 :
66 URLResolver(),
67 theFunction(aFunction),
68 theCtx(aSctx)
69 {
70 }
71
72 virtual ~XQXQURLResolver() { }
73
74 virtual Resource* resolveURL(const String& url, EntityData const* entityData);
75};
76
77
78class XQXQURIMapper : public URIMapper
79{
80protected:
81 Item theFunction;
82 StaticContext_t theCtx;
83
84public:
85 XQXQURIMapper(Item& aFunction, StaticContext_t& aSctx)
86 :
87 URIMapper(),
88 theFunction(aFunction),
89 theCtx(aSctx)
90 {
91 }
92
93 virtual ~XQXQURIMapper(){ }
94
95 virtual void mapURI(
96 const zorba::String aUri,
97 EntityData const* aEntityData,
98 std::vector<zorba::String>& oUris);
99};
100/*******************************************************************************
54 Bag class for objects associated with a prepared query101 Bag class for objects associated with a prepared query
55********************************************************************************/102********************************************************************************/
56class QueryData : public SmartObject103class QueryData : public SmartObject
@@ -144,52 +191,6 @@
144 evaluate(const Arguments_t&,191 evaluate(const Arguments_t&,
145 const zorba::StaticContext*,192 const zorba::StaticContext*,
146 const zorba::DynamicContext*) const;193 const zorba::DynamicContext*) const;
147
148protected:
149
150 class XQXQURLResolver : public URLResolver
151 {
152 protected:
153 Item theFunction;
154 StaticContext_t theCtx;
155
156 public:
157 XQXQURLResolver(Item& aFunction, StaticContext_t& aSctx)
158 :
159 URLResolver(),
160 theFunction(aFunction),
161 theCtx(aSctx)
162 {
163 }
164
165 virtual ~XQXQURLResolver() { }
166
167 virtual Resource* resolveURL(const String& url, EntityData const* entityData);
168 };
169
170
171 class XQXQURIMapper : public URIMapper
172 {
173 protected:
174 Item theFunction;
175 StaticContext_t theCtx;
176
177 public:
178 XQXQURIMapper(Item& aFunction, StaticContext_t& aSctx)
179 :
180 URIMapper(),
181 theFunction(aFunction),
182 theCtx(aSctx)
183 {
184 }
185
186 virtual ~XQXQURIMapper(){ }
187
188 virtual void mapURI(
189 const zorba::String aUri,
190 EntityData const* aEntityData,
191 std::vector<zorba::String>& oUris);
192 };
193};194};
194195
195196
@@ -561,7 +562,87 @@
561 const zorba::DynamicContext*) const;562 const zorba::DynamicContext*) const;
562 };563 };
563564
564565/*******************************************************************************
566
567********************************************************************************/
568class QueryPlanFunction : public XQXQFunction
569{
570public:
571 QueryPlanFunction(const XQXQModule* aModule) : XQXQFunction(aModule) {}
572
573 virtual ~QueryPlanFunction() {}
574
575 virtual zorba::String
576 getLocalName() const {return "query-plan"; }
577
578 virtual zorba::ItemSequence_t
579 evaluate(const Arguments_t&,
580 const zorba::StaticContext*,
581 const zorba::DynamicContext*) const;
582
583 virtual String getURI() const {
584 return theModule->getURI();
585 }
586
587protected:
588 const XQXQModule* theModule;
589};
590
591
592/*******************************************************************************
593
594********************************************************************************/
595class LoadFromQueryPlanFunction : public XQXQFunction
596{
597public:
598 LoadFromQueryPlanFunction(const XQXQModule* aModule) : XQXQFunction(aModule) {}
599
600 virtual ~LoadFromQueryPlanFunction() {}
601
602 virtual zorba::String
603 getLocalName() const {return "load-from-query-plan"; }
604
605 virtual zorba::ItemSequence_t
606 evaluate(const Arguments_t&,
607 const zorba::StaticContext*,
608 const zorba::DynamicContext*) const;
609
610 virtual String getURI() const {
611 return theModule->getURI();
612 }
613
614protected:
615 const XQXQModule* theModule;
616
617 class QueryPlanSerializationCallback : public zorba::SerializationCallback
618 {
619 std::vector<URIMapper*> theUriMappers;
620 std::vector<URLResolver*>theUrlResolvers;
621
622 public:
623 QueryPlanSerializationCallback()
624 {
625 }
626
627 virtual ~QueryPlanSerializationCallback() {}
628
629 void add_URIMapper(URIMapper* aMapper)
630 {
631 theUriMappers.push_back(aMapper);
632 }
633
634 void add_URLResolver(URLResolver* aResolver)
635 {
636 theUrlResolvers.push_back(aResolver);
637 }
638
639 virtual URIMapper*
640 getURIMapper(size_t i ) const { return theUriMappers.size() < i? NULL : theUriMappers[i]; }
641
642 virtual URLResolver*
643 getURLResolver(size_t i) const { return theUrlResolvers.size() < i? NULL : theUrlResolvers[i]; }
644 };
645};
565}/*xqxq namespace*/}/*zorba namespace*/646}/*xqxq namespace*/}/*zorba namespace*/
566647
567648
568649
=== modified file 'src/compiler/api/compilercb.cpp'
--- src/compiler/api/compilercb.cpp 2013-03-22 00:49:51 +0000
+++ src/compiler/api/compilercb.cpp 2013-04-09 23:43:20 +0000
@@ -199,6 +199,7 @@
199 ar & theIsEval;199 ar & theIsEval;
200 ar & theIsLoadProlog;200 ar & theIsLoadProlog;
201 ar & theIsUpdating;201 ar & theIsUpdating;
202 ar & theIsSequential;
202 ar & theSctxMap;203 ar & theSctxMap;
203 ar & theRootSctx;204 ar & theRootSctx;
204#ifdef ZORBA_WITH_DEBUGGER205#ifdef ZORBA_WITH_DEBUGGER
205206
=== modified file 'test/fots/CMakeLists.txt'
--- test/fots/CMakeLists.txt 2013-04-08 22:59:58 +0000
+++ test/fots/CMakeLists.txt 2013-04-09 23:43:20 +0000
@@ -17,7 +17,9 @@
17 COMMAND "${CMAKE_COMMAND}" 17 COMMAND "${CMAKE_COMMAND}"
18 -D "ZORBA=${ZORBA_EXE}"18 -D "ZORBA=${ZORBA_EXE}"
19 -D "BUILDDIR=${PROJECT_BINARY_DIR}"19 -D "BUILDDIR=${PROJECT_BINARY_DIR}"
20 -P "${CMAKE_CURRENT_SOURCE_DIR}/ImportFOTS.cmake")20 -P "${CMAKE_CURRENT_SOURCE_DIR}/ImportFOTS.cmake"
21 COMMAND "${CMAKE_COMMAND}" "${PROJECT_SOURCE_DIR}"
22 WORKING_DIRECTORY "${PROJECT_BINARY_DIR}")
2123
22# Create cached version of activate setting24# Create cached version of activate setting
23SET (ZORBA_FOTS_ACTIVATE inactive CACHE STRING "Which FOTS tests to activate")25SET (ZORBA_FOTS_ACTIVATE inactive CACHE STRING "Which FOTS tests to activate")
2426
=== modified file 'test/fots/ImportFOTS.cmake'
--- test/fots/ImportFOTS.cmake 2013-04-09 15:17:58 +0000
+++ test/fots/ImportFOTS.cmake 2013-04-09 23:43:20 +0000
@@ -82,6 +82,7 @@
82 "-e mode:=run-test-set -e testSetName:=${_testset} "82 "-e mode:=run-test-set -e testSetName:=${_testset} "
83 "-e expectedFailuresPath:=${BUILDDIR}/FOTSExpectedFailures.xml "83 "-e expectedFailuresPath:=${BUILDDIR}/FOTSExpectedFailures.xml "
84 "-e verbose:=true "84 "-e verbose:=true "
85 "-e usePlanSerializer:=true "
85 "--disable-http-resolution --indent "86 "--disable-http-resolution --indent "
86 "-z \"cdata-section-elements=${FOTS_CDATA_ELEMENTS}\")\n"87 "-z \"cdata-section-elements=${FOTS_CDATA_ELEMENTS}\")\n"
87 "ZORBA_SET_TEST_PROPERTY (FOTS/${_testset} "88 "ZORBA_SET_TEST_PROPERTY (FOTS/${_testset} "
@@ -109,6 +110,7 @@
109 "-e testSetName:=${_testset} -e testCaseName:=${_testcase} "110 "-e testSetName:=${_testset} -e testCaseName:=${_testcase} "
110 "-e expectedFailuresPath:=${BUILDDIR}/FOTSExpectedFailures.xml "111 "-e expectedFailuresPath:=${BUILDDIR}/FOTSExpectedFailures.xml "
111 "-e verbose:=true "112 "-e verbose:=true "
113 "-e usePlanSerializer:=true "
112 "--disable-http-resolution --indent "114 "--disable-http-resolution --indent "
113 "-z \"cdata-section-elements=${FOTS_CDATA_ELEMENTS}\")\n"115 "-z \"cdata-section-elements=${FOTS_CDATA_ELEMENTS}\")\n"
114 "ZORBA_SET_TEST_PROPERTY (FOTS/${_testset}/${_testcase} "116 "ZORBA_SET_TEST_PROPERTY (FOTS/${_testset}/${_testcase} "
115117
=== modified file 'test/fots/get-tests.xq'
--- test/fots/get-tests.xq 2012-12-05 09:12:38 +0000
+++ test/fots/get-tests.xq 2013-04-09 23:43:20 +0000
@@ -16,7 +16,6 @@
1616
17declare namespace c = "http://www.w3.org/2010/09/qt-fots-catalog";17declare namespace c = "http://www.w3.org/2010/09/qt-fots-catalog";
1818
19declare variable $fotsPath as xs:string external := "";
20declare variable $testSet as xs:string external := "";19declare variable $testSet as xs:string external := "";
2120
22let $catalog := fn:doc(fn:static-base-uri())/c:catalog21let $catalog := fn:doc(fn:static-base-uri())/c:catalog
2322
=== modified file 'test/fots_driver/README.TXT'
--- test/fots_driver/README.TXT 2013-02-22 10:41:13 +0000
+++ test/fots_driver/README.TXT 2013-04-09 23:43:20 +0000
@@ -27,6 +27,10 @@
27If you run Zorba from a checkout of the trunk and the build/bin folder,27If you run Zorba from a checkout of the trunk and the build/bin folder,
28- /path/to/cli.xq can be set to ../../test/fots_driver/cli.xq28- /path/to/cli.xq can be set to ../../test/fots_driver/cli.xq
2929
30'fotsPath' is set by default to the location where 'make fots-import' added the FOTS snapshot.
31Currently this location is ZORBA_BUILD_FOLDER/test/fots/2011/QT3-test-suite/catalog.xml.
32If you want to use other location please set 'fotsPath'.
33
30Always try to output the result back to an XML file with nice indentation:34Always try to output the result back to an XML file with nice indentation:
31./zorba -f -q ../../test/fots_driver/cli.xq -e SET_CLI_OPTIONS_HERE -o output.xml --indent35./zorba -f -q ../../test/fots_driver/cli.xq -e SET_CLI_OPTIONS_HERE -o output.xml --indent
3236
@@ -37,20 +41,21 @@
37 is written down into a query_TESTCASENAME.xq file, where TESTCASENAME is41 is written down into a query_TESTCASENAME.xq file, where TESTCASENAME is
38 the test case name.42 the test case name.
3943
40zorba -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-sets44zorba -f -q /path/to/cli.xq -e fotsZorbaManifestPath:=/path/to/Zorba_manifest.xml -e mode:=list-test-sets
41zorba -f -q /path/to/cli.xq -e fotsPath:=/path/to/QT3-test-suite/catalog.xml -e mode:=list-test-sets45zorba -f -q /path/to/cli.xq -e fotsPath:=/path/to/QT3-test-suite/catalog.xml -e mode:=list-test-sets
42zorba -f -q /path/to/cli.xq -e fotsPath:=/path/to/QT3-test-suite/catalog.xml -e mode:=list-test-sets -e testSetPrefixes:=prod,app46zorba -f -q /path/to/cli.xq -e mode:=list-test-sets -e testSetPrefixes:=prod,app
43zorba -f -q /path/to/cli.xq -e fotsPath:=/path/to/QT3-test-suite/catalog.xml -e mode:=list-test-cases -e testSetPrefixes:=prod-Literal47zorba -f -q /path/to/cli.xq -e mode:=list-test-cases -e testSetPrefixes:=prod-Literal
44zorba -f -q /path/to/cli.xq -e fotsPath:=/path/to/QT3-test-suite/catalog.xml -e mode:=list-test-cases -e dependency:=higherOrderFunctions48zorba -f -q /path/to/cli.xq -e mode:=list-test-cases -e dependency:=higherOrderFunctions
45zorba -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-count49zorba -f -q /path/to/cli.xq -e mode:=list-test-cases -e dependency:=higherOrderFunctions -e assertions:=assert-count
46zorba -f -q /path/to/cli.xq -e fotsPath:=/path/to/QT3-test-suite/catalog.xml -e mode:=list-matching-test-cases -e pattern:=catch 50zorba -f -q /path/to/cli.xq -e mode:=list-matching-test-cases -e pattern:=catch
47zorba -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 51zorba -f -q /path/to/cli.xq -e mode:=run-test-sets -e testSetPrefixes:=prod -o result.xml --indent
48zorba -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 52zorba -f -q /path/to/cli.xq -e mode:=run-test-sets -e testSetPrefixes:=prod -e expectedFailuresPath:=ExpectedFailures.xml -o result.xml --indent
49zorba -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 --indent53zorba -f -q /path/to/cli.xq -e mode:=run-test-sets -e testSetPrefixes:=prod -e dependency:=higherOrderFunctions_false -o result.xml --indent
50zorba -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 --indent54zorba -f -q /path/to/cli.xq -e mode:=run-test-sets -e testSetPrefixes:=prod -e assertions:=assert-count -o result.xml --indent
51zorba -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 --indent55zorba -f -q /path/to/cli.xq -e mode:=run-test-sets -e testSetPrefixes:=prod-Literal -e verbose:=true -o result.xml --indent
52zorba -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 --indent56zorba -f -q /path/to/cli.xq -e mode:=run-test-set -e testSetName:=fn-matches -o result.xml --indent
53zorba -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 --indent57zorba -f -q /path/to/cli.xq -e mode:=run-test-set -e testSetName:=fn-matches -e usePlanSerializer:=true -o result.xml --indent
54zorba -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-resolution58zorba -f -q /path/to/cli.xq -e mode:=run-test-case -e testSetName:=prod-Literal -e testCaseName:=Literals001 -o result.xml --indent
55zorba -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 --indent59zorba -f -q /path/to/cli.xq -e mode:=run-and-report -o results_Zorba_XQ30.xml --indent --disable-http-resolution
60zorba -f -q /path/to/cli.xq -e mode:=report -e resultsFilePath:=results.xml -o results_Zorba_XQ30.xml --indent
56zorba -f -q /path/to/cli.xq -e mode:=generate-expected-failures -e resultsFilePath:=failures.xml -o ExpectedFailures.xml --indent61zorba -f -q /path/to/cli.xq -e mode:=generate-expected-failures -e resultsFilePath:=failures.xml -o ExpectedFailures.xml --indent
5762
=== modified file 'test/fots_driver/cli.xq'
--- test/fots_driver/cli.xq 2013-04-03 07:40:51 +0000
+++ test/fots_driver/cli.xq 2013-04-09 23:43:20 +0000
@@ -184,6 +184,13 @@
184declare variable $verbose as xs:string external := "false";184declare variable $verbose as xs:string external := "false";
185185
186186
187(:~
188 : Enable or disable plan serializer usage. When this is set to true the query
189 : plan is saved then loaded and executed by XQXQ.
190 :)
191declare variable $usePlanSerializer as xs:string external := "false";
192
193
187declare function local:usage() as xs:string194declare function local:usage() as xs:string
188{195{
189 string-join((196 string-join((
@@ -191,6 +198,10 @@
191 "If you run Zorba from a checkout of the trunk and the build/bin folder,",198 "If you run Zorba from a checkout of the trunk and the build/bin folder,",
192 "- /path/to/cli.xq can be set to ../../test/fots_driver/cli.xq",199 "- /path/to/cli.xq can be set to ../../test/fots_driver/cli.xq",
193 "",200 "",
201 "'fotsPath' is set by default to the location where 'make fots-import' added the FOTS snapshot.",
202 "Currently this location is ZORBA_BUILD_FOLDER/test/fots/2011/QT3-test-suite/catalog.xml.",
203 "If you want to use other location please set 'fotsPath'.",
204 "",
194 "Always try to output the result back to an XML file with nice indentation:",205 "Always try to output the result back to an XML file with nice indentation:",
195 "./zorba -f -q ../../test/fots_driver/cli.xq -e SET_CLI_OPTIONS_HERE -o output.xml --indent",206 "./zorba -f -q ../../test/fots_driver/cli.xq -e SET_CLI_OPTIONS_HERE -o output.xml --indent",
196 "",207 "",
@@ -201,22 +212,23 @@
201 " is written down into a query_TESTCASENAME.xq file, where TESTCASENAME is",212 " is written down into a query_TESTCASENAME.xq file, where TESTCASENAME is",
202 " the test case name.",213 " the test case name.",
203 "",214 "",
204 "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",215 "zorba -f -q /path/to/cli.xq -e fotsZorbaManifestPath:=/path/to/Zorba_manifest.xml -e mode:=list-test-sets",
205 "zorba -f -q /path/to/cli.xq -e fotsPath:=/path/to/QT3-test-suite/catalog.xml -e mode:=list-test-sets",216 "zorba -f -q /path/to/cli.xq -e fotsPath:=/path/to/QT3-test-suite/catalog.xml -e mode:=list-test-sets",
206 "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",217 "zorba -f -q /path/to/cli.xq -e mode:=list-test-sets -e testSetPrefixes:=prod,app",
207 "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",218 "zorba -f -q /path/to/cli.xq -e mode:=list-test-cases -e testSetPrefixes:=prod-Literal",
208 "zorba -f -q /path/to/cli.xq -e fotsPath:=/path/to/QT3-test-suite/catalog.xml -e mode:=list-test-cases -e dependency:=higherOrderFunctions",219 "zorba -f -q /path/to/cli.xq -e mode:=list-test-cases -e dependency:=higherOrderFunctions",
209 "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",220 "zorba -f -q /path/to/cli.xq -e mode:=list-test-cases -e dependency:=higherOrderFunctions -e assertions:=assert-count",
210 "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",221 "zorba -f -q /path/to/cli.xq -e mode:=list-matching-test-cases -e pattern:=catch",
211 "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",222 "zorba -f -q /path/to/cli.xq -e mode:=run-test-sets -e testSetPrefixes:=prod -o result.xml --indent",
212 "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",223 "zorba -f -q /path/to/cli.xq -e mode:=run-test-sets -e testSetPrefixes:=prod -e expectedFailuresPath:=ExpectedFailures.xml -o result.xml --indent",
213 "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",224 "zorba -f -q /path/to/cli.xq -e mode:=run-test-sets -e testSetPrefixes:=prod -e dependency:=higherOrderFunctions_false -o result.xml --indent",
214 "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",225 "zorba -f -q /path/to/cli.xq -e mode:=run-test-sets -e testSetPrefixes:=prod -e assertions:=assert-count -o result.xml --indent",
215 "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",226 "zorba -f -q /path/to/cli.xq -e mode:=run-test-sets -e testSetPrefixes:=prod-Literal -e verbose:=true -o result.xml --indent",
216 "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",227 "zorba -f -q /path/to/cli.xq -e mode:=run-test-set -e testSetName:=fn-matches -o result.xml --indent",
217 "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",228 "zorba -f -q /path/to/cli.xq -e mode:=run-test-set -e testSetName:=fn-matches -e usePlanSerializer:=true -o result.xml --indent",
218 "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",229 "zorba -f -q /path/to/cli.xq -e mode:=run-test-case -e testSetName:=prod-Literal -e testCaseName:=Literals001 -o result.xml --indent",
219 "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",230 "zorba -f -q /path/to/cli.xq -e mode:=run-and-report -o results_Zorba_XQ30.xml --indent --disable-http-resolution",
231 "zorba -f -q /path/to/cli.xq -e mode:=report -e resultsFilePath:=results.xml -o results_Zorba_XQ30.xml --indent",
220 "zorba -f -q /path/to/cli.xq -e mode:=generate-expected-failures -e resultsFilePath:=failures.xml -o ExpectedFailures.xml --indent",232 "zorba -f -q /path/to/cli.xq -e mode:=generate-expected-failures -e resultsFilePath:=failures.xml -o ExpectedFailures.xml --indent",
221 ""233 ""
222 ), "&#xA;")234 ), "&#xA;")
@@ -307,7 +319,7 @@
307 trace($dependency, "'dependency' set to:");319 trace($dependency, "'dependency' set to:");
308 trace($assertions, "'assertions' set to: ");320 trace($assertions, "'assertions' set to: ");
309 trace($verbose, "'verbose' set to:");321 trace($verbose, "'verbose' set to:");
310 trace($mode, "Cli command was set to:");322 trace($mode, "Cli command set to:");
311323
312 d:run-fots($fotsPath,324 d:run-fots($fotsPath,
313 $fotsZorbaManifestPath,325 $fotsZorbaManifestPath,
@@ -319,7 +331,8 @@
319 $assertions,331 $assertions,
320 xs:boolean($verbose),332 xs:boolean($verbose),
321 $expectedFailuresPath,333 $expectedFailuresPath,
322 $mode)334 $mode,
335 xs:boolean($usePlanSerializer))
323}336}
324337
325case "run-test-set"338case "run-test-set"
@@ -329,7 +342,7 @@
329 trace($dependency, "'dependency' set to:");342 trace($dependency, "'dependency' set to:");
330 trace($assertions, "'assertions' set to: ");343 trace($assertions, "'assertions' set to: ");
331 trace($verbose, "'verbose' set to:");344 trace($verbose, "'verbose' set to:");
332 trace($mode, "Cli command was set to:");345 trace($mode, "Cli command set to:");
333346
334 d:run-test-set($fotsPath,347 d:run-test-set($fotsPath,
335 $fotsZorbaManifestPath,348 $fotsZorbaManifestPath,
@@ -341,7 +354,8 @@
341 $assertions,354 $assertions,
342 xs:boolean($verbose),355 xs:boolean($verbose),
343 $expectedFailuresPath,356 $expectedFailuresPath,
344 $mode)357 $mode,
358 xs:boolean($usePlanSerializer))
345}359}
346360
347case "run-test-case"361case "run-test-case"
@@ -350,7 +364,7 @@
350 trace($testSetName, $testSetNameMsg);364 trace($testSetName, $testSetNameMsg);
351 trace($testCaseName, $testCaseNameMsg);365 trace($testCaseName, $testCaseNameMsg);
352 trace($verbose, "'verbose' set to:");366 trace($verbose, "'verbose' set to:");
353 trace($mode, "Cli command was set to:");367 trace($mode, "Cli command set to:");
354368
355 d:run-fots($fotsPath,369 d:run-fots($fotsPath,
356 $fotsZorbaManifestPath,370 $fotsZorbaManifestPath,
@@ -362,7 +376,8 @@
362 (),376 (),
363 xs:boolean($verbose),377 xs:boolean($verbose),
364 $expectedFailuresPath,378 $expectedFailuresPath,
365 $mode)379 $mode,
380 xs:boolean($usePlanSerializer))
366}381}
367382
368case "run-and-report"383case "run-and-report"
369384
=== added file 'test/fots_driver/execute.xq'
--- test/fots_driver/execute.xq 1970-01-01 00:00:00 +0000
+++ test/fots_driver/execute.xq 2013-04-09 23:43:20 +0000
@@ -0,0 +1,95 @@
1(:
2 : Copyright 2006-2011 The FLWOR Foundation.
3 :
4 : Licensed under the Apache License, Version 2.0 (the "License");
5 : you may not use this file except in compliance with the License.
6 : You may obtain a copy of the License at
7 :
8 : http://www.apache.org/licenses/LICENSE-2.0
9 :
10 : Unless required by applicable law or agreed to in writing, software
11 : distributed under the License is distributed on an "AS IS" BASIS,
12 : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 : See the License for the specific language governing permissions and
14 : limitations under the License.
15 :)
16
17(:~
18 : Zorba FOTS driver execute
19 : @author Sorin Nasoi
20 :)
21
22module namespace execute =
23 "http://www.zorba-xquery.com/fots-driver/execute";
24
25import module namespace xqxq =
26 "http://www.zorba-xquery.com/modules/xqxq#2.0";
27
28import module namespace eval =
29 "http://www.zorba-xquery.com/fots-driver/evaluate" at "evaluate.xq";
30
31declare namespace fots =
32 "http://www.w3.org/2010/09/qt-fots-catalog";
33
34declare namespace err =
35 "http://www.w3.org/2005/xqt-errors";
36
37declare namespace ann =
38 "http://www.zorba-xquery.com/annotations";
39
40
41declare namespace op = "http://www.zorba-xquery.com/options/features";
42declare namespace f = "http://www.zorba-xquery.com/features";
43declare option op:disable "f:trace";
44
45(:~
46 : XQXQ invoke.
47 : @param $xqxqQueryText the query that will be run.
48 : @param $case the test case.
49 : @param $verbose if set to TRUE it will also output the actual result.
50 : @param $testSetBaseURI the URI of the directory that contains the file of the
51 associated test set.
52 : @param $usePlanSerializer if true the plan serializer is used.
53 : @return the result of running the query with XQXQ.
54 :)
55declare %ann:sequential function execute:xqxq-invoke(
56 $xqxqQueryText as xs:string,
57 $case as element(fots:test-case),
58 $verbose as xs:boolean?,
59 $testSetBaseURI as xs:anyURI,
60 $usePlanSerializer as xs:boolean
61)
62{
63 try
64 {
65 if($usePlanSerializer) then
66 {
67 variable $queryKey := xqxq:prepare-main-module($xqxqQueryText);
68 variable $queryPlan := xqxq:query-plan($queryKey);
69 variable $queryPlanKey := xqxq:load-from-query-plan($queryPlan);
70 variable $queryResult := xqxq:evaluate-sequential($queryPlanKey);
71
72 xqxq:delete-query($queryPlanKey);
73 xqxq:delete-query($queryKey);
74
75 eval:result($queryResult, $case/fots:result/*, $testSetBaseURI)
76 }
77 else
78 {
79 variable $queryKey := xqxq:prepare-main-module($xqxqQueryText);
80 variable $queryResult := xqxq:evaluate-sequential($queryKey);
81
82 xqxq:delete-query($queryKey);
83
84 eval:result($queryResult, $case/fots:result/*, $testSetBaseURI)
85 }
86 }
87 catch *
88 {
89 eval:error((),
90 $case/fots:result/*,
91 $err:code,
92 $err:description,
93 $testSetBaseURI)
94 }
95};
096
=== modified file 'test/fots_driver/feedback.xq'
--- test/fots_driver/feedback.xq 2013-03-29 06:15:19 +0000
+++ test/fots_driver/feedback.xq 2013-04-09 23:43:20 +0000
@@ -136,15 +136,13 @@
136 : @return info about test case that passed.136 : @return info about test case that passed.
137 :)137 :)
138declare %private function feedback:pass(138declare %private function feedback:pass(
139 $case as element(fots:test-case),139 $case as element(fots:test-case),
140 $result as item()*140 $result as item()*
141) as element(fots:test-case)?141) as element(fots:test-case)?
142{142{
143 let $status := if(exists($result/fots:errors))143 if(exists($result/fots:errors))
144 then 'wrongError'144 then <fots:test-case name="{data($case/@name)}" result="wrongError" comment="{$result/fots:errors}"/>
145 else 'pass'145 else <fots:test-case name="{data($case/@name)}" result="pass"/>
146 return
147 <fots:test-case name="{data($case/@name)}" result="{$status}"/>
148};146};
149147
150148
@@ -200,7 +198,7 @@
200 then <fots:test-case name="{data($case/@name)}"198 then <fots:test-case name="{data($case/@name)}"
201 result="{$status}"199 result="{$status}"
202 comment="{$info}"/>200 comment="{$info}"/>
203 201
204 else <fots:test-case name="{data($case/@name)}"202 else <fots:test-case name="{data($case/@name)}"
205 result="{$status}"/>203 result="{$status}"/>
206};204};
207205
=== modified file 'test/fots_driver/fots-driver.xq'
--- test/fots_driver/fots-driver.xq 2013-03-29 06:15:19 +0000
+++ test/fots_driver/fots-driver.xq 2013-04-09 23:43:20 +0000
@@ -25,9 +25,6 @@
25import module namespace functx =25import module namespace functx =
26 "http://www.functx.com/";26 "http://www.functx.com/";
2727
28import module namespace xqxq =
29 "http://www.zorba-xquery.com/modules/xqxq";
30
31import module namespace datetime =28import module namespace datetime =
32 "http://www.zorba-xquery.com/modules/datetime";29 "http://www.zorba-xquery.com/modules/datetime";
3330
@@ -37,6 +34,9 @@
37import module namespace feedback =34import module namespace feedback =
38 "http://www.zorba-xquery.com/fots-driver/feedback" at "feedback.xq";35 "http://www.zorba-xquery.com/fots-driver/feedback" at "feedback.xq";
3936
37import module namespace execute =
38 "http://www.zorba-xquery.com/fots-driver/execute" at "execute.xq";
39
40import module namespace env =40import module namespace env =
41 "http://www.zorba-xquery.com/fots-driver/environment" at "environment.xq";41 "http://www.zorba-xquery.com/fots-driver/environment" at "environment.xq";
4242
@@ -320,6 +320,7 @@
320 : about each processed test-case.320 : about each processed test-case.
321 : @param $expectedFailures the root node of the ExpectedFailures.xml file.321 : @param $expectedFailures the root node of the ExpectedFailures.xml file.
322 : @param $cliMode the cli command.322 : @param $cliMode the cli command.
323 : @param $usePlanSerializer if true the plan serializer is used.
323 : @return an XML tree containing info about all the processed tests-cases324 : @return an XML tree containing info about all the processed tests-cases
324 :)325 :)
325declare %ann:sequential function driver:run-fots(326declare %ann:sequential function driver:run-fots(
@@ -333,12 +334,14 @@
333 $assertions as xs:string*,334 $assertions as xs:string*,
334 $verbose as xs:boolean,335 $verbose as xs:boolean,
335 $expectedFailuresPath as xs:string,336 $expectedFailuresPath as xs:string,
336 $cliMode as xs:string337 $cliMode as xs:string,
338 $usePlanSerializer as xs:boolean
337) as element(fots:test-cases)339) as element(fots:test-cases)
338{340{
339 trace($fotsPath, "Path to FOTS catalog.xml was set to: ");341 trace($fotsPath, "Path to FOTS catalog.xml was set to: ");
340 trace($zorbaManifestPath, "Path to FOTSZorbaManifest set to :");342 trace($zorbaManifestPath, "Path to FOTSZorbaManifest set to :");
341 trace($expectedFailuresPath, "Path to ExpectedFailures.xml set to:");343 trace($expectedFailuresPath, "Path to ExpectedFailures.xml set to:");
344 trace($usePlanSerializer, "'usePlanSerializer' set to:");
342345
343 try346 try
344 {347 {
@@ -347,6 +350,10 @@
347 let $zorbaManifest := doc(resolve-uri($zorbaManifestPath))350 let $zorbaManifest := doc(resolve-uri($zorbaManifestPath))
348351
349 let $testSetNames :=352 let $testSetNames :=
353 if(($cliMode = 'run-test-case') ||
354 ($cliMode = 'run-test-set'))
355 then $testSetPrefixes
356 else
350 {357 {
351 if (empty($testSetPrefixes) and empty($exceptedTestSets)) then358 if (empty($testSetPrefixes) and empty($exceptedTestSets)) then
352 {359 {
@@ -414,7 +421,8 @@
414 $exceptedTestCases,421 $exceptedTestCases,
415 $verbose,422 $verbose,
416 $expectedFailures,423 $expectedFailures,
417 $cliMode)424 $cliMode,
425 $usePlanSerializer)
418 }426 }
419 catch err:FODC0002427 catch err:FODC0002
420 {428 {
@@ -475,6 +483,7 @@
475 : about each processed test-case.483 : about each processed test-case.
476 : @param $expectedFailures the root node of the ExpectedFailures.xml file.484 : @param $expectedFailures the root node of the ExpectedFailures.xml file.
477 : @param $cliMode the cli command.485 : @param $cliMode the cli command.
486 : @param $usePlanSerializer if true the plan serializer is used.
478 : @return an XML tree containing info about all the processed tests-cases487 : @return an XML tree containing info about all the processed tests-cases
479 :)488 :)
480declare %ann:sequential function driver:run-test-set(489declare %ann:sequential function driver:run-test-set(
@@ -488,13 +497,15 @@
488 $assertions as xs:string*,497 $assertions as xs:string*,
489 $verbose as xs:boolean,498 $verbose as xs:boolean,
490 $expectedFailuresPath as xs:string,499 $expectedFailuresPath as xs:string,
491 $cliMode as xs:string500 $cliMode as xs:string,
501 $usePlanSerializer as xs:boolean
492) as element(fots:test-cases)502) as element(fots:test-cases)
493{503{
494 trace($fotsPath, "Path to FOTS catalog.xml was set to: ");504 trace($fotsPath, "Path to FOTS catalog.xml was set to: ");
495 trace($zorbaManifestPath, "Path to FOTSZorbaManifest set to :");505 trace($zorbaManifestPath, "Path to FOTSZorbaManifest set to :");
496 trace($expectedFailuresPath, "Path to ExpectedFailures.xml set to:");506 trace($expectedFailuresPath, "Path to ExpectedFailures.xml set to:");
497507 trace($usePlanSerializer, "'usePlanSerializer' set to:");
508
498 try509 try
499 {510 {
500 let $FOTSCatalog := doc(resolve-uri($fotsPath))511 let $FOTSCatalog := doc(resolve-uri($fotsPath))
@@ -564,7 +575,8 @@
564 $exceptedTestCases,575 $exceptedTestCases,
565 $verbose,576 $verbose,
566 $expectedFailures,577 $expectedFailures,
567 $cliMode)578 $cliMode,
579 $usePlanSerializer)
568 }580 }
569 catch err:FODC0002581 catch err:FODC0002
570 {582 {
@@ -615,6 +627,7 @@
615 : about each processed test-case.627 : about each processed test-case.
616 : @param $expectedFailures the root node of the ExpectedFailures.xml file.628 : @param $expectedFailures the root node of the ExpectedFailures.xml file.
617 : @param $cliMode the cli command.629 : @param $cliMode the cli command.
630 : @param $usePlanSerializer if true the plan serializer is used.
618 : @return an XML tree containing info about all the processed tests-cases631 : @return an XML tree containing info about all the processed tests-cases
619 :)632 :)
620declare %private %ann:sequential function driver:run-fots(633declare %private %ann:sequential function driver:run-fots(
@@ -626,7 +639,8 @@
626 $exceptedTestCases as xs:string*,639 $exceptedTestCases as xs:string*,
627 $verbose as xs:boolean,640 $verbose as xs:boolean,
628 $expectedFailures as document-node()?,641 $expectedFailures as document-node()?,
629 $cliMode as xs:string642 $cliMode as xs:string,
643 $usePlanSerializer as xs:boolean
630) as element(fots:test-cases)644) as element(fots:test-cases)
631{645{
632 <fots:test-cases>646 <fots:test-cases>
@@ -730,7 +744,8 @@
730 $verbose,744 $verbose,
731 $expectedFailures//TestSet[@name eq $testSetName]/Test[@name eq $testCase/@name],745 $expectedFailures//TestSet[@name eq $testSetName]/Test[@name eq $testCase/@name],
732 $cliMode,746 $cliMode,
733 $mayNeedDTDValidation)747 $mayNeedDTDValidation,
748 $usePlanSerializer)
734 }749 }
735 else750 else
736 {751 {
@@ -744,7 +759,8 @@
744 $verbose,759 $verbose,
745 $expectedFailures//TestSet[@name eq $testSetName]/Test[@name eq $testCase/@name],760 $expectedFailures//TestSet[@name eq $testSetName]/Test[@name eq $testCase/@name],
746 $cliMode,761 $cliMode,
747 $mayNeedDTDValidation)762 $mayNeedDTDValidation,
763 $usePlanSerializer)
748 }764 }
749 }765 }
750 }766 }
@@ -776,6 +792,7 @@
776 : @param $cliMode the cli command.792 : @param $cliMode the cli command.
777 : @param $mayNeedDTDValidation true if the test case may need DTD validation793 : @param $mayNeedDTDValidation true if the test case may need DTD validation
778 : for the document bound as context item.794 : for the document bound as context item.
795 : @param $usePlanSerializer if true the plan serializer is used.
779 : @return an XML tree containing info about the result of running the test case.796 : @return an XML tree containing info about the result of running the test case.
780 :)797 :)
781declare %ann:sequential function driver:test(798declare %ann:sequential function driver:test(
@@ -788,7 +805,8 @@
788 $verbose as xs:boolean,805 $verbose as xs:boolean,
789 $expectedFailure as element(Test)?,806 $expectedFailure as element(Test)?,
790 $cliMode as xs:string,807 $cliMode as xs:string,
791 $mayNeedDTDValidation as xs:boolean808 $mayNeedDTDValidation as xs:boolean,
809 $usePlanSerializer as xs:boolean
792) as element(fots:test-case)?810) as element(fots:test-case)?
793{811{
794(:TODO Cover the "(:%VARDECL%:)"when there are tests in FOTS that use it:)812(:TODO Cover the "(:%VARDECL%:)"when there are tests in FOTS that use it:)
@@ -853,10 +871,11 @@
853871
854 variable $startDateTime := datetime:current-dateTime();872 variable $startDateTime := datetime:current-dateTime();
855873
856 variable $result := driver:xqxq-invoke($xqxqQuery,874 variable $result := execute:xqxq-invoke($xqxqQuery,
857 $case,875 $case,
858 $verbose,876 $verbose,
859 $testSetBaseURI);877 $testSetBaseURI,
878 $usePlanSerializer);
860879
861 variable $duration := (datetime:current-dateTime() - $startDateTime);880 variable $duration := (datetime:current-dateTime() - $startDateTime);
862 881
@@ -1020,42 +1039,3 @@
1020 "&#xA;"1039 "&#xA;"
1021 )1040 )
1022};1041};
1023
1024
1025(:~
1026 : XQXQ invoke.
1027 : @param $xqxqQueryText the query that will be run.
1028 : @param $case the test case.
1029 : @param $verbose if set to TRUE it will also output the actual result.
1030 : @param $testSetBaseURI the URI of the directory that contains the file of the
1031 associated test set.
1032 : @return the result of running the query with XQXQ.
1033 :)
1034declare %private %ann:sequential function driver:xqxq-invoke(
1035 $xqxqQueryText as xs:string,
1036 $case as element(fots:test-case),
1037 $verbose as xs:boolean?,
1038 $testSetBaseURI as xs:anyURI
1039)
1040{
1041 try
1042 {
1043 {
1044 variable $queryKey := xqxq:prepare-main-module($xqxqQueryText);
1045
1046 variable $queryResult := xqxq:evaluate-sequential($queryKey);
1047
1048 xqxq:delete-query($queryKey);
1049
1050 eval:result($queryResult, $case/fots:result/*, $testSetBaseURI)
1051 }
1052 }
1053 catch *
1054 {
1055 eval:error((),
1056 $case/fots:result/*,
1057 $err:code,
1058 $err:description,
1059 $testSetBaseURI)
1060 }
1061};
10621042
=== modified file 'test/fots_driver/reporting.xq'
--- test/fots_driver/reporting.xq 2013-03-12 21:04:31 +0000
+++ test/fots_driver/reporting.xq 2013-04-09 23:43:20 +0000
@@ -89,7 +89,8 @@
89 (),89 (),
90 fn:false(),90 fn:false(),
91 '',91 '',
92 'run-test-sets');92 'run-test-sets',
93 fn:false());
9394
94 file:write("results.xml",95 file:write("results.xml",
95 $results,96 $results,
9697
=== added file 'test/rbkt/ExpQueryResults/zorba/xqxq/query-plan.xml.res'
--- test/rbkt/ExpQueryResults/zorba/xqxq/query-plan.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/xqxq/query-plan.xml.res 2013-04-09 23:43:20 +0000
@@ -0,0 +1,1 @@
12
0\ No newline at end of file2\ No newline at end of file
13
=== added file 'test/rbkt/ExpQueryResults/zorba/xqxq/query-plan2.xml.res'
--- test/rbkt/ExpQueryResults/zorba/xqxq/query-plan2.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/xqxq/query-plan2.xml.res 2013-04-09 23:43:20 +0000
@@ -0,0 +1,1 @@
1foo
0\ No newline at end of file2\ No newline at end of file
13
=== added file 'test/rbkt/ExpQueryResults/zorba/xqxq/query-plan3.xml.res'
--- test/rbkt/ExpQueryResults/zorba/xqxq/query-plan3.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/xqxq/query-plan3.xml.res 2013-04-09 23:43:20 +0000
@@ -0,0 +1,1 @@
1foo
0\ No newline at end of file2\ No newline at end of file
13
=== added file 'test/rbkt/Queries/zorba/xqxq/query-plan.xq'
--- test/rbkt/Queries/zorba/xqxq/query-plan.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/xqxq/query-plan.xq 2013-04-09 23:43:20 +0000
@@ -0,0 +1,6 @@
1import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
2
3variable $queryID := xqxq:prepare-main-module("1+1");
4variable $query-plan := xqxq:query-plan($queryID);
5variable $queryID2 := xqxq:load-from-query-plan($query-plan);
6xqxq:evaluate ($queryID2)
07
=== added file 'test/rbkt/Queries/zorba/xqxq/query-plan2.xq'
--- test/rbkt/Queries/zorba/xqxq/query-plan2.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/xqxq/query-plan2.xq 2013-04-09 23:43:20 +0000
@@ -0,0 +1,20 @@
1import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
2
3declare namespace resolver = 'http://www.zorba-xquery.com/modules/xqxq/url-resolver';
4declare namespace op = "http://www.zorba-xquery.com/options/features";
5declare namespace f = "http://www.zorba-xquery.com/features";
6
7declare function resolver:url-resolver($namespace as xs:string, $entity as xs:string) {
8 if($namespace = 'http://test.xq')
9 then "module namespace test = 'http://test'; declare function test:foo(){'foo'};"
10 else ()
11};
12
13variable $queryID := xqxq:prepare-main-module(
14 "import module namespace test = 'http://test'; test:foo()",
15 resolver:url-resolver#2, ());
16
17
18variable $query-plan := xqxq:query-plan($queryID);
19variable $queryID2 := xqxq:load-from-query-plan($query-plan, resolver:url-resolver#2, ());
20xqxq:evaluate ($queryID2)
021
=== added file 'test/rbkt/Queries/zorba/xqxq/query-plan3.xq'
--- test/rbkt/Queries/zorba/xqxq/query-plan3.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/xqxq/query-plan3.xq 2013-04-09 23:43:20 +0000
@@ -0,0 +1,28 @@
1import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
2
3declare namespace resolver = 'http://www.zorba-xquery.com/modules/xqxq/url-resolver';
4declare namespace mapper = 'http://www.zorba-xquery.com/modules/xqxq/uri-mapper';
5declare namespace op = "http://www.zorba-xquery.com/options/features";
6declare namespace f = "http://www.zorba-xquery.com/features";
7
8declare function resolver:url-resolver($namespace as xs:string, $entity as xs:string) {
9 if($namespace = 'http://foo')
10 then "module namespace test = 'http://test'; declare function test:foo(){'foo'};"
11 else ()
12};
13
14declare function mapper:uri-mapper($namespace as xs:string, $entity as xs:string)
15{
16 if($namespace = 'http://test')
17 then 'http://foo'
18 else ()
19};
20
21variable $queryID := xqxq:prepare-main-module
22(
23 "import module namespace test = 'http://test'; test:foo()",
24 resolver:url-resolver#2, mapper:uri-mapper#2
25);
26variable $query-plan := xqxq:query-plan($queryID);
27variable $queryID2 := xqxq:load-from-query-plan($query-plan, resolver:url-resolver#2, mapper:uri-mapper#2);
28xqxq:evaluate ($queryID2)
029
=== added file 'test/rbkt/Queries/zorba/xqxq/query-plan4.spec'
--- test/rbkt/Queries/zorba/xqxq/query-plan4.spec 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/xqxq/query-plan4.spec 2013-04-09 23:43:20 +0000
@@ -0,0 +1,1 @@
1Error: http://www.zorba-xquery.com/errors:ZCSE0013
02
=== added file 'test/rbkt/Queries/zorba/xqxq/query-plan4.xq'
--- test/rbkt/Queries/zorba/xqxq/query-plan4.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/xqxq/query-plan4.xq 2013-04-09 23:43:20 +0000
@@ -0,0 +1,28 @@
1import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
2
3declare namespace resolver = 'http://www.zorba-xquery.com/modules/xqxq/url-resolver';
4declare namespace mapper = 'http://www.zorba-xquery.com/modules/xqxq/uri-mapper';
5declare namespace op = "http://www.zorba-xquery.com/options/features";
6declare namespace f = "http://www.zorba-xquery.com/features";
7
8declare function resolver:url-resolver($namespace as xs:string, $entity as xs:string) {
9 if($namespace = 'http://foo')
10 then "module namespace test = 'http://test'; declare function test:foo(){'foo'};"
11 else ()
12};
13
14declare function mapper:uri-mapper($namespace as xs:string, $entity as xs:string)
15{
16 if($namespace = 'http://test')
17 then 'http://foo'
18 else ()
19};
20
21variable $queryID := xqxq:prepare-main-module
22(
23 "import module namespace test = 'http://test'; test:foo()",
24 resolver:url-resolver#2, mapper:uri-mapper#2
25);
26variable $query-plan := xqxq:query-plan($queryID);
27variable $queryID2 := xqxq:load-from-query-plan($query-plan);
28xqxq:evaluate ($queryID2)

Subscribers

People subscribed via source and target branches