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