zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #17262
[Merge] lp:~zorba-coders/zorba/fots_driver into lp:zorba
Markos Zaharioudakis has proposed merging lp:~zorba-coders/zorba/fots_driver into lp:zorba.
Commit message:
minor improvements + comments + cosmetic changes in fots_driver
Requested reviews:
Markos Zaharioudakis (markos-za)
Related bugs:
Bug #918156 in Zorba: "fots driver for Zorba"
https://bugs.launchpad.net/zorba/+bug/918156
Bug #956460 in Zorba: "Zorba FOTS driver: assert-serialization aka assert-xml bug"
https://bugs.launchpad.net/zorba/+bug/956460
Bug #967173 in Zorba: "Zorba FOTS driver: assert-any-of bug"
https://bugs.launchpad.net/zorba/+bug/967173
Bug #973410 in Zorba: "Zorba FOTS driver: assert-deep-eq bug"
https://bugs.launchpad.net/zorba/+bug/973410
Bug #973412 in Zorba: "Zorba FOTS driver: assert-permutation bug"
https://bugs.launchpad.net/zorba/+bug/973412
Bug #973416 in Zorba: "Zorba FOTS driver: assert-assert bug"
https://bugs.launchpad.net/zorba/+bug/973416
Bug #973417 in Zorba: "Zorba FOTS driver: assert-serialization-error bug"
https://bugs.launchpad.net/zorba/+bug/973417
Bug #973434 in Zorba: "Zorba FOTS driver: assert-error bug"
https://bugs.launchpad.net/zorba/+bug/973434
Bug #1017386 in Zorba: "Zorba FOTS driver: improve debugging support"
https://bugs.launchpad.net/zorba/+bug/1017386
Bug #1017389 in Zorba: "Zorba FOTS driver: improve statistics reporting"
https://bugs.launchpad.net/zorba/+bug/1017389
Bug #1052856 in Zorba: "URI resolvers in Zorba FOTS driver"
https://bugs.launchpad.net/zorba/+bug/1052856
Bug #1079033 in Zorba: "FOTS: correct misleading name for param for FOTS driver"
https://bugs.launchpad.net/zorba/+bug/1079033
For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/fots_driver/+merge/144209
minor improvements + comments + cosmetic changes in fots_driver
--
https://code.launchpad.net/~zorba-coders/zorba/fots_driver/+merge/144209
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'test/fots_driver/cli.xq'
--- test/fots_driver/cli.xq 2012-12-12 08:18:55 +0000
+++ test/fots_driver/cli.xq 2013-01-22 03:57:22 +0000
@@ -21,60 +21,137 @@
import module namespace d =
"http://www.zorba-xquery.com/fots-driver"; at "fots-driver.xq";
+
import module namespace r =
"http://www.zorba-xquery.com/fots-driver/reporting"; at "reporting.xq";
-(:~ path to the place where FOTS can be found :)
+
+(:~
+ Path to the FOTS catalog.xml file. If the path is relative, it will be
+ resolved relative to the directory containing this cli.xq file.
+:)
declare variable $fotsPath as xs:string external := "";
-(:~ path to the place where the FOTS Zorba manifest can be found :)
+
+(:~
+ Path to the FOTSZorbaManifest.xml file. If the path is relative, it will be
+ resolved relative to the diractory containing this cli.xq file
+:)
declare variable $fotsZorbaManifestPath as xs:string external :=
"FOTSZorbaManifest.xml";
-(:~ Path to the results from a previous run :)
+
+(:~
+ Path to the results from a previous run. Used when we just want to generate
+ a report based on some previous run, i.e., without running the tests again.
+:)
declare variable $failuresFilePath as xs:string external := "";
-(:~ choose the CLI option you want to run :)
+
+(:~
+ Path to the ExpectedFailures file.
+:)
+declare variable $expectedFailuresPath as xs:string external :="";
+
+
+(:~
+ The CLI command you want to run.
+:)
declare variable $mode as xs:string external := "";
-(:~ name/criteria for the test sets :)
+
+(:~
+ A list of comma-seperated prefixes. Only test-sets whose name starts with
+ a prefix in this list are going to be proccesed. An empty string means no
+ filtering of test-sets.
+:)
declare variable $testSetPrefixes as xs:string external := "";
-(:~ name/criteria for the test cases :)
+
+(:~
+ A list of comma-seperated prefixes. Only test-cases whose name starts with
+ a prefix in this list are going to be proccesed. An empty string means no
+ filtering of test-cases.
+:)
declare variable $testCasePrefixes as xs:string external := "";
-(:~ name for the test set :)
+
+(:~
+ : Name of the test-set containing a test-case to process. Used only for the
+ : "run-test-case" command.
+:)
declare variable $testSetName as xs:string external := "";
-(:~ name for the test case :)
+
+(:~
+ : Name of the test-case to process. Used only for the "run-test-case" command.
+:)
declare variable $testCaseName as xs:string external := "";
-(:~ Enable or disable verbose output :)
-declare variable $verbose as xs:string external := "true";
-
-(:~ assertion type :)
-declare variable $assertType as xs:string external := "";
-
-(:~ dependency: used in 'list-test-cases' and 'run-test-sets' modes:)
+
+(:~
+ A dependency used in the 'list-test-cases' and 'run-test-sets' commands to
+ filter the test-cases that will actually be listed/run. Only test-cases whose
+ applicable dependencies contain at least one dependency the matches this
+ user-specified dependency will be processed. The filtering dependency is
+ given as a string of the form "depValue_depSatisfied" (for example,
+ "XQ30+_true"), or just "depValue" (in which case "true" is assumed as the
+ value of the satisfied attribute). If $dependency is set to the empty string,
+ no filtering is done.
+:)
declare variable $dependency as xs:string external := "";
-(:~ regex for the tests in the 'list-matching-test-cases' option :)
+
+(:~
+ List of assertion types used in the 'list-test-cases' and 'run-test-sets'
+ commands to filter the test-cases that will actually be listed/run. A test
+ case qualifies if there is at least one element node under the <result>
+ node of the <test-case> whose local name is equal to one of the strings
+ in the filtering set. If $assrtType is set to the empty sequence, no
+ filtering is done.
+:)
+declare variable $assertType as xs:string* external := ();
+
+
+(:~
+ Regex to be used by the 'list-matching-test-cases' command.
+:)
declare variable $pattern as xs:string external := "";
-(:~ flags for the tests in the 'list-matching-test-cases' option :)
+
+(:~
+ Flags to be used by the 'list-matching-test-cases' command.
+:)
declare variable $flags as xs:string external := "";
-(:~ Path to the ExpectedFailures file :)
-declare variable $expectedFailuresPath as xs:string external :="";
-
-(:~ Tokenize comma or empty string :)
-declare %private function local:tokenize(
- $input as xs:string
-) as xs:string*
-{
- let $tokens := tokenize($input, ",")
- return if (exists($tokens)) then $tokens else ""
-};
+
+(:~
+ The test cases in this list have bugs assigned and should not be run.
+:)
+declare variable $exceptedTestCases := (
+ "cbcl-subsequence-011",
+ "cbcl-subsequence-012",
+ "cbcl-subsequence-013",
+ "cbcl-subsequence-014" (:see bug lp:1069794 :)
+, "re00975",
+ "re00976",
+ "re00976a" (:see bug lp:1070533 :)
+, "fn-unparsed-text-lines-052" (:see bug lp:1073175 :)
+);
+
+
+(:~
+ The test in this list have bugs assigned already and should not be run
+:)
+declare variable $exceptedTestSets := ();
+
+
+(:~
+ Enable or disable verbose output
+:)
+declare variable $verbose as xs:string external := "true";
+
+
declare function local:usage() as xs:string
{
@@ -109,88 +186,113 @@
), "
")
};
-(:~ The test cases in this list have bugs assigned and should not be run :)
-variable $exceptedTestCases := (
-"cbcl-subsequence-011", "cbcl-subsequence-012", "cbcl-subsequence-013",
-"cbcl-subsequence-014" (:see bug lp:1069794 :)
-, "re00975", "re00976", "re00976a" (:see bug lp:1070533 :)
-, "fn-unparsed-text-lines-052" (:see bug lp:1073175 :)
-);
-
-(:~ The test in this list have bugs assigned already and should not be run :)
-variable $exceptedTestSets := ();
+
+(:~
+ Tokenize comma or empty string
+:)
+declare %private function local:tokenize(
+ $input as xs:string
+) as xs:string*
+{
+ tokenize($input, ",")
+};
+
+
+variable $fotsPathMsg := "The path to FOTS catalog.xml was set to: ";
+
+variable $testSetPrefixesMsg := "'testSetPrefixes' was set to: ";
+
+variable $testCasePrefixesMsg := "'testCasePrefixes' was set to: ";
+
switch ($mode)
+
case "list-test-sets"
- return
- string-join(
- (d:list-test-sets(
- trace($fotsPath, "Path to FOTS catalog.xml set to: "),
- local:tokenize(trace($testSetPrefixes, "'testSetPrefixes' set to: ")))),
- "
")
+return
+ string-join
+ (
+ (
+ d:list-test-sets(trace($fotsPath, $fotsPathMsg),
+ local:tokenize(trace($testSetPrefixes, $testSetPrefixesMsg)))
+ ),
+ "
"
+ )
+
case "list-test-cases"
- return
- string-join(
- (d:list-test-cases( trace($fotsPath,
- "Path to FOTS catalog.xml set to: "),
- local:tokenize(trace($testSetPrefixes,
- "'testSetPrefixes' set to: ")),
- "",
- trace($dependency,
- "'dependency' set to:"),
- trace($assertType,
- "'assertType' set to: "))),
- "
")
+return
+ string-join
+ (
+ (
+ d:list-test-cases(trace($fotsPath, $fotsPathMsg),
+ local:tokenize(trace($testSetPrefixes, $testSetPrefixesMsg)),
+ trace($dependency, "'dependency' set to:"),
+ trace($assertType, "'assertType' set to: "))
+ ),
+ "
"
+ )
+
case "list-matching-test-cases"
- return string-join((d:list-matching-test-cases(
- trace($fotsPath,
- "Path to FOTS catalog.xml set to: "),
- trace($pattern,
- "pattern set to: "),
- trace($flags,
- "flags were set to: ")), ""),
- "
")
+return
+ string-join
+ (
+ (
+ d:list-matching-test-cases(trace($fotsPath, $fotsPathMsg),
+ trace($pattern, "pattern set to: "),
+ trace($flags, "flags were set to: ")), ""
+ ),
+ "
"
+ )
+
case "run-test-sets"
- return d:run-fots($fotsPath,
- $fotsZorbaManifestPath,
- d:list-test-sets($fotsPath,
- local:tokenize(trace($testSetPrefixes,
- "'testSetPrefixes' set to: "))),
- d:list-test-cases($fotsPath,
- local:tokenize($testSetPrefixes),
- local:tokenize(trace($testCasePrefixes,
- "'testCasePrefixes' set to: ")),
- trace($dependency,
- "'dependency' set to:"),
- trace($assertType,
- "'assertType' set to: ")),
- $exceptedTestCases,
- $exceptedTestSets,
- xs:boolean($verbose),
- $expectedFailuresPath)
+return
+ d:run-fots($fotsPath,
+ $fotsZorbaManifestPath,
+ d:list-test-sets($fotsPath,
+ local:tokenize(trace($testSetPrefixes,
+ $testSetPrefixesMsg))),
+ d:list-test-cases($fotsPath,
+ local:tokenize($testSetPrefixes),
+ local:tokenize(trace($testCasePrefixes,
+ $testCasePrefixesMsg)),
+ trace($dependency, "'dependency' set to:"),
+ trace($assertType, "'assertType' set to: ")),
+ $exceptedTestCases,
+ $exceptedTestSets,
+ xs:boolean($verbose),
+ $expectedFailuresPath)
+
case "run-test-case"
- return d:run-fots($fotsPath,
- $fotsZorbaManifestPath,
- trace($testSetName, "'testSetName' set to: "),
- trace($testCaseName,"'testCaseName' set to: "),
- $exceptedTestCases,
- $exceptedTestSets,
- xs:boolean($verbose),
- $expectedFailuresPath)
+return
+ d:run-fots($fotsPath,
+ $fotsZorbaManifestPath,
+ trace($testSetName, "'testSetName' set to: "),
+ trace($testCaseName,"'testCaseName' set to: "),
+ $exceptedTestCases,
+ $exceptedTestSets,
+ xs:boolean($verbose),
+ $expectedFailuresPath)
+
case "run-and-report"
- return r:run-and-report($fotsPath,
- $fotsZorbaManifestPath,
- $exceptedTestCases,
- $exceptedTestSets,
+return
+ r:run-and-report($fotsPath,
+ $fotsZorbaManifestPath,
+ $exceptedTestCases,
+ $exceptedTestSets,
(: the reports to W3C are always generated with verbose set to false:)
- fn:false())
+ fn:false())
+
case "report"
- return r:report($fotsPath,
- $failuresFilePath,
- $exceptedTestCases,
- $exceptedTestSets,
- xs:boolean($verbose))
+return
+ r:report($fotsPath,
+ $failuresFilePath,
+ $exceptedTestCases,
+ $exceptedTestSets,
+ xs:boolean($verbose))
+
case "generate-expected-failures"
- return r:generate-expected-failures($failuresFilePath)
+return
+ r:generate-expected-failures($failuresFilePath)
+
default
- return local:usage()
+return
+ local:usage()
=== modified file 'test/fots_driver/fots-driver.xq'
--- test/fots_driver/fots-driver.xq 2012-12-21 13:28:10 +0000
+++ test/fots_driver/fots-driver.xq 2013-01-22 03:57:22 +0000
@@ -27,23 +27,29 @@
import module namespace xqxq =
"http://www.zorba-xquery.com/modules/xqxq";;
+
import module namespace datetime =
"http://www.zorba-xquery.com/modules/datetime";;
import module namespace eval =
"http://www.zorba-xquery.com/fots-driver/evaluate"; at "evaluate.xq";
+
import module namespace feedback =
"http://www.zorba-xquery.com/fots-driver/feedback"; at "feedback.xq";
+
import module namespace env =
"http://www.zorba-xquery.com/fots-driver/environment"; at "environment.xq";
+
import module namespace util =
"http://www.zorba-xquery.com/fots-driver/util"; at "util.xq";
+
import module namespace fots-err =
"http://www.zorba-xquery.com/fots-driver/errors"; at "errors.xq";
declare namespace err =
"http://www.w3.org/2005/xqt-errors";;
+
declare namespace fots =
"http://www.w3.org/2010/09/qt-fots-catalog";;
@@ -51,186 +57,265 @@
"http://www.zorba-xquery.com/annotations";;
(:~
- : Loops through the FOTS catalog and returns all available test set names.
+ : Returns the names of all qualifying test sets.
+ :
+ : A test set qualifies if its name starts with one of the prefixes listed in
+ : $testSetPrefixes. If $testSetPrefixes is the empty sequence, then all test
+ : sets qualify.
+ :
: @param $fotsPath path to the FOTS catalog file.
- : @param $testSetPrefixes name/criteria for the test sets
- : (empty string means all).
- : @return available FOTS test sets.
+ : @param $testSetPrefixes name criteria for the test sets
+ : (empty sequence means all).
+ : @return names of qualifying FOTS test sets.
:)
declare %ann:nondeterministic function driver:list-test-sets(
$fotsPath as xs:string,
$testSetPrefixes as xs:string*
-) as xs:string* {
- let $doc := doc(resolve-uri($fotsPath))
- return
- if(string-join($testSetPrefixes,'') = '')
- then
- for $testSet in $doc/fots:catalog/fots:test-set
- return data($testSet/@name)
- else
- for $prefix in $testSetPrefixes
- for $testSet in $doc/fots:catalog/fots:test-set[starts-with(@name, $prefix)]
- return data($testSet/@name)
-};
-
+) as xs:string*
+{
+ let $doc := doc(resolve-uri($fotsPath))
+ return
+ if (empty($testSetPrefixes))
+ then
+ for $testSet in $doc/fots:catalog/fots:test-set
+ return data($testSet/@name)
+ else
+ for $prefix in $testSetPrefixes
+ for $testSet in $doc/fots:catalog/fots:test-set[starts-with(@name, $prefix)]
+ return data($testSet/@name)
+};
+
+
+(:~
+ : Returns the names of all qualifying test cases.
+ :
+ : A test case qualifies if (a) it belongs to a qualifing test set, and (b)
+ : its applicable dependencies include a user-provided dependency, or no
+ : dependency was provided by the user, and (c) its expected-result assertions
+ : include at least one of the assertions in a user-provided set of assertions,
+ : or no expected-result assertions were provided by the user.
+ :
+ : A test set qualifies if its name starts with one of the prefixes listed in
+ : $testSetPrefixes. If $testSetPrefixes is the empty sequence, then all test
+ : sets qualify.
+ :
+ : The filtering dependency is given as a string, which may be empty (signifying
+ : no dependency) or of the form "depValue_depSatisfied" (e.g., "XQ30+_true"),
+ : or just "depValue" (in which case "true" is assumed as the value of the
+ : satisfied attribute). A test-case qualifies if it has at least one dependency
+ : whose @value and @satisfied attributes are equal to the filtering depValue
+ : and depSatisfied.
+ :
+ : A filtering set of assertions is given as a sequence of strings. A test-case
+ : qualifies if there is at least one element node under the <result> node of
+ : the <test-case> whose local name is equal to one of the strings in the
+ : filtering set.
+ :
+ : @param $fotsPath path to the FOTS catalog file.
+ : @param $testSetPrefixes name criteria for the test sets
+ : (empty sequence means all test sets).
+ : @param $dependency dependency used to filter test-cases.
+ : (empty string means no filtering).
+ : @param $assert set of expected-result assertions used to filter test-cases.
+ : (empty sequence means no filtering).
+ : @return names of qualifying FOTS test cases.
+ :)
+declare %ann:nondeterministic function driver:list-test-cases(
+ $fotsPath as xs:string,
+ $testSetPrefixes as xs:string*,
+ $dependency as xs:string,
+ $assert as xs:string*
+) as xs:string*
+{
+ let $doc := doc(resolve-uri($fotsPath))
+ let $baseUri:= resolve-uri(util:parent-folder($fotsPath))
+ return
+ if (empty($testSetPrefixes))
+ then
+ for $testSet in $doc/fots:catalog/fots:test-set
+ let $testSetDoc := doc(resolve-uri($testSet/@file, $baseUri))
+ return driver:list-test-cases($testSetDoc, $dependency, $assert)
+ else
+ for $prefix in $testSetPrefixes
+ for $testSet in $doc/fots:catalog/fots:test-set[starts-with(@name, $prefix)]
+ let $testSetDoc := doc(resolve-uri($testSet/@file, $baseUri))
+ return driver:list-test-cases($testSetDoc, $dependency, $assert)
+};
+
+
+(:~
+ : Returns the names of all qualifying test cases.
+ :
+ : This function is similar to the driver:list-test-cases() defined above. It
+ : just adds the following condition to the list of condition that must be
+ : satisfied by each qualifying test case: (d) its name starts with one of the
+ : prefixes in $testCasePrefixes, or $testCasePrefixes is the empty sequence.
+ :
+ : @param $fotsPath path to the FOTS catalog file.
+ : @param $testSetPrefixes name criteria for the test sets
+ : (empty sequence means all test sets).
+ : @param $testCasePrefixes name criteria for the test cases
+ : (empty sequence means all test cases).
+ : @param $dependency dependency used to filter test-cases.
+ : (empty string means no filtering).
+ : @param $assert set of expected-result assertions used to filter test-cases.
+ : (empty sequence means no filtering).
+ : @return names of qualifying FOTS test cases.
+ :)
+declare %ann:nondeterministic function driver:list-test-cases(
+ $fotsPath as xs:string,
+ $testSetPrefixes as xs:string*,
+ $testCasePrefixes as xs:string*,
+ $dependency as xs:string ,
+ $assert as xs:string*
+) as xs:string*
+{
+ let $doc := doc(resolve-uri($fotsPath))
+ let $baseUri:= resolve-uri(util:parent-folder($fotsPath))
+ let $testCaseNames := driver:list-test-cases($fotsPath,
+ $testSetPrefixes,
+ $dependency,
+ $assert)
+ return
+ if (empty($testCasePrefixes)) then
+ $testCaseNames
+ else
+ for $prefix in $testCasePrefixes
+ return
+ for $name in $testCaseNames
+ where starts-with($name, $prefix)
+ return $name
+};
+
+
+(:~
+ : Helper function. Returns the names of all qualifying test cases within a
+ : given test set. A test case qualifies if (a) its applicable dependencies
+ : include a user-provided dependency, or no dependency was provided by the
+ : user, and (b) its expected-result assertions include at least one of the
+ : assertions in a user-provided set of assertions, or no expected-result
+ : assertions were provided b the user.
+ :
+ : @param $testSetDoc root node of the xml document the specifies the test set.
+ : @param $dependency dependency used to filter test-cases.
+ : (empty string means no filtering).
+ : @param $assert set of expected-result assertions used to filter test-cases.
+ : (empty sequence means no filtering).
+ : @return names of qualifying FOTS test cases.
+ :)
+declare %private function driver:list-test-cases(
+ $testSetDoc as document-node(),
+ $dependency as xs:string,
+ $assert as xs:string*
+) as xs:string*
+{
+ if ($dependency eq '' and empty($assert)) then
+ {
+ $testSetDoc//fots:test-case/@name
+ }
+ else if ($dependency eq '') then
+ {
+ for $testCase in $testSetDoc//fots:test-case
+ where functx:value-intersect(driver:list-assertions($testCase), $assert)
+ return $testCase/@name
+ }
+ else
+ {
+ for $testCase in $testSetDoc//fots:test-case
+
+ where
+ driver:matches-dependency(($testSetDoc/fots:test-set/fots:dependency,
+ $testCase/fots:dependency),
+ $dependency)
+ and
+ (empty($assert) or
+ functx:value-intersect(driver:list-assertions($testCase), $assert))
+
+ return $testCase/@name
+ }
+};
+
+
+(:~
+ : Helper function to check whether a user-specified dependency (given as an
+ : encoded string) "matches" at least one of the dependencies in a given list
+ : of dependecies (given as a sequence of <dependency> elements)
+ :)
declare %private function driver:matches-dependency(
$dependencies as element(fots:dependency)*,
$filter as xs:string
-) as xs:boolean {
- let $filter := tokenize($filter, '_')
- let $depValue := $filter[1]
- let $depSatisfied as xs:string := if(exists($filter[2]) and
- ($filter[2] = 'true' or $filter[2]='false'))
- then $filter[2]
- else 'true'
- return
- if(xs:boolean($depSatisfied))
-
- (: $depSatisfied = 'true' :)
- then (exists($dependencies[@value = $depValue and
- @satisfied = $depSatisfied]) or
- exists($dependencies[@value = $depValue and empty(@satisfied)]))
-
- (: $depSatisfied = 'false' :)
- else exists($dependencies[@value = $depValue and
- @satisfied = $depSatisfied])
+) as xs:boolean
+{
+ if ($filter eq '')
+ then
+ fn:true()
+ else
+ let $filter := tokenize($filter, '_')
+ let $depValue := $filter[1]
+ let $depSatisfied := if ($filter[2] eq 'true' or $filter[2] eq 'false')
+ then $filter[2]
+ else 'true'
+ return
+ if ($depSatisfied)
+ then
+ $dependencies[@value eq $depValue and @satisfied eq $depSatisfied] or
+ $dependencies[@value eq $depValue and empty(@satisfied)]
+ else
+ $dependencies[@value eq $depValue and @satisfied eq $depSatisfied]
};
+
+(:~
+ : Helper function to return the local names of all the nodes under a <result>
+ : child of a given <test-case>.
+ :)
declare %private function driver:list-assertions(
$case as element(fots:test-case)
-) as xs:string* {
+) as xs:string*
+{
distinct-values(for $assert in $case/fots:result/descendant-or-self::*
return local-name-from-QName(node-name($assert)))
};
-(:~
- : Loops through the given test set and returns the test cases that have the
- : given dependencies defined.
- : @param $testSet test set document.
- : @param $dependency defined dependency
- : (empty string means all test cases).
- : @param $assert lists of tests that contain a certain assert-type(empty
- : string means all tests).
- : @return matching test case names.
- :)
-declare %private function driver:list-test-cases(
- $testSetDoc as document-node(),
- $dependency as xs:string*,
- $assert as xs:string*
-) as xs:string* {
- if(string-join($dependency,'') = '')
- then $testSetDoc//fots:test-case/@name
- else for $testCase in $testSetDoc//fots:test-case
- let $matchDep := driver:matches-dependency(($testSetDoc/fots:test-set/fots:dependency,
- $testCase/fots:dependency),
- $dependency)
- let $matchAssert := (($assert = '') or
- exists(functx:value-intersect(
- driver:list-assertions($testCase),
- $assert)))
- where ($matchDep and $matchAssert)
- return $testCase/@name
-
-};
-
-(:~
- : Loops through the given test sets and returns the corresponding test cases.
- : @param $fotsPath path to the FOTS catalog file.
- : @param $testSetPrefixes name/criteria for the test sets
- : (empty string means all test cases).
- : @param $dependency type of dependency that has to be met
- : (empty string means all test cases).
- : @param $assert lists of tests that contain a certain assert-type(empty
- : string means all tests).
- : @return available FOTS test cases.
- :)
-declare %ann:nondeterministic function driver:list-test-cases(
- $fotsPath as xs:string,
- $testSetPrefixes as xs:string*,
- $dependency as xs:string*,
- $assert as xs:string*
-) as xs:string* {
- let $doc := doc(resolve-uri($fotsPath)),
- $baseUri:= resolve-uri(util:parent-folder($fotsPath))
- return
- if(string-join($testSetPrefixes,'') = '')
- then
- for $testSet in $doc/fots:catalog/fots:test-set
- let $testSetDoc := doc(resolve-uri($testSet/@file, $baseUri))
- return driver:list-test-cases($testSetDoc, $dependency, $assert)
- else
- for $prefix in $testSetPrefixes
- for $testSet in $doc/fots:catalog/fots:test-set[starts-with(@name, $prefix)]
- let $testSetDoc := doc(resolve-uri($testSet/@file, $baseUri))
- return driver:list-test-cases($testSetDoc, $dependency, $assert)
-};
-
-(:~
- : Loops through the given test sets and returns the corresponding test cases.
- : @param $fotsPath path to the FOTS catalog file.
- : @param $testSetPrefixes name/criteria for the test sets
- : (empty string means all test cases).
- : @param $testCasePrefixes name/criteria for the test cases
- : (empty string means all test cases).
- : @param $dependency type of dependency that has to be met
- : (empty string means all test cases).
- : @param $assert lists of tests that contain a certain assert-type(empty
- : string means all tests).
- : @return available FOTS test cases.
- :)
-declare %ann:nondeterministic function driver:list-test-cases(
- $fotsPath as xs:string,
- $testSetPrefixes as xs:string*,
- $testCasePrefixes as xs:string*,
- $dependency as xs:string*,
- $assert as xs:string*
-) as xs:string* {
- let $doc := doc(resolve-uri($fotsPath)),
- $baseUri:= resolve-uri(util:parent-folder($fotsPath)),
- $testCaseNames := driver:list-test-cases($fotsPath,
- $testSetPrefixes,
- $dependency,
- $assert)
- return
- for $prefix in $testCasePrefixes
- return
- for $name in $testCaseNames
- where starts-with($name,
- $prefix)
- return $name
-};
-
-(:~
- : Loops through all the test cases and returns those that have a 'test' node
- : that matches given pattern using given flags.
+
+(:~
+ : For each qualifying test case, this functions returns its name and the full
+ : filepath of its associated test-set file..
+ :
+ : A test case qualifies if its <test> node (which contains the query text)
+ : matches the given pattern using given flags.
+ :
: @param $fotsPath path to the FOTS catalog file.
: @param $pattern pattern.
: @param $flags flags.
- : @return available FOTS test cases matching given pattern and flags.
+ : @return names of qualifying FOTS test case and the filepaths of their
+ : containing test-set files.
:)
declare %ann:nondeterministic function driver:list-matching-test-cases(
$fotsPath as xs:string,
$pattern as xs:string,
$flags as xs:string?
-) as xs:string* {
- let $doc := doc(resolve-uri($fotsPath)),
- $baseUri:= resolve-uri(util:parent-folder($fotsPath))
+) as xs:string*
+{
+ let $doc := doc(resolve-uri($fotsPath))
+ let $baseUri:= resolve-uri(util:parent-folder($fotsPath))
return
for $testSet in $doc/fots:catalog/fots:test-set
- let $uri := resolve-uri($testSet/@file, $baseUri),
- $testSetDoc := doc($uri)
- for $testCase in $testSetDoc//fots:test-case
- where matches(util:get-value($testCase,
- util:parent-folder($uri),
- "test"),
- $pattern,
- $flags)
- return
- concat(resolve-uri($testSet/@file, $baseUri),
- ", test name:",
- data($testCase/@name))
+ let $uri := resolve-uri($testSet/@file, $baseUri)
+ let $testSetDoc := doc($uri)
+ for $testCase in $testSetDoc//fots:test-case
+ where matches(util:get-value($testCase,
+ util:parent-folder($uri),
+ "test"),
+ $pattern,
+ $flags)
+ return
+ concat(resolve-uri($testSet/@file, $baseUri),
+ ", test name:",
+ data($testCase/@name))
};
+
(:~
: Loops through the FOTS catalog and evaluates all test cases that have
: a certain assert-type.
@@ -257,8 +342,10 @@
$exceptedTestSets as xs:string*,
$verbose as xs:boolean,
$expectedFailuresPath as xs:string
-) as element(fots:test-cases) {
- try {
+) as element(fots:test-cases)
+{
+ try
+ {
let $FOTSCatalog := doc(trace(resolve-uri($FOTSCatalogFilePath),
"Path to FOTS catalog.xml set to: ")),
$FOTSZorbaManifest := doc(trace(resolve-uri($FOTSZorbaManifestPath),
@@ -277,7 +364,8 @@
trace($verbose, "'Verbose' parameter set to: "),
$expectedFailures)
}
- catch * {
+ catch *
+ {
error($err:code,
concat("
Please make sure the passed 'fotsPath' points to the",
" exact location of the FOTS catalog.xml:
",
@@ -291,6 +379,7 @@
}
};
+
(:~
: Loops through the FOTS catalog and evaluates all test cases
:
@@ -317,7 +406,8 @@
$exceptedTestSets as xs:string*,
$verbose as xs:boolean,
$expectedFailures as document-node()?
-) as element(fots:test-cases) {
+) as element(fots:test-cases)
+{
<fots:test-cases>{
let $catalogTestSetNames := $FOTSCatalog//fots:test-set/@name,
$testSetNames := if ($testSetNames = '')
@@ -418,6 +508,7 @@
}</fots:test-cases>
};
+
(:~
: Creates the complete query that will be evaluated by adding the necessary
: XQXQ URL resolvers.
@@ -435,7 +526,8 @@
$env as element(fots:environment)?,
$envBaseURI as xs:anyURI?,
$testSetBaseURI as xs:anyURI
-) as xs:string {
+) as xs:string
+{
let $resolver as xs:string? := env:resolver($case,
$env,
$envBaseURI,
@@ -465,6 +557,7 @@
"
")
};
+
(:~
: XQXQ invoke.
: @param $xqxqQueryText the query that will be run.
@@ -478,7 +571,8 @@
$case as element(fots:test-case),
$verbose as xs:boolean?,
$testSetBaseURI as xs:anyURI
-) {
+)
+{
try {
{
variable $queryKey := xqxq:prepare-main-module($xqxqQueryText);
=== modified file 'test/fots_driver/util.xq'
--- test/fots_driver/util.xq 2012-11-14 14:02:58 +0000
+++ test/fots_driver/util.xq 2013-01-22 03:57:22 +0000
@@ -33,6 +33,7 @@
declare namespace err =
"http://www.w3.org/2005/xqt-errors";;
+
declare namespace fots =
"http://www.w3.org/2010/09/qt-fots-catalog";;
@@ -59,61 +60,73 @@
<output:indent value="yes" />
<output:omit-xml-declaration value="no" />
</output:serialization-parameters>;
-
+
+
(:~
- : Retrieve the value of from the given node that is either given as text node
- : or in a file attribute.
+ : Search within a given test-case for all element nodes with a given node name.
+ : For each such element node return:
+ : (a) if the node has a @file attr, the content of that file as unparsed text,
+ : or
+ : (b) the typed value of the node (assuming it is promotable to string).
:
: @param $case test-case element.
- : @param $path the path of the test-set.
+ : @param $node-name
+ : @param $envBaseURI
: @return the query text.
:)
declare %ann:nondeterministic function util:get-value(
$case as element(fots:test-case),
$envBaseURI as xs:anyURI,
$node-name as xs:string
-) as xs:string {
- try {
+) as xs:string
+{
+ try
+ {
for $node in $case/descendant-or-self::*
- where (fn:local-name-from-QName(fn:node-name($node)) = $node-name)
+ where (fn:local-name-from-QName(fn:node-name($node)) eq $node-name)
return
- if(exists($node/@file))
+ if ($node/@file)
then fn:unparsed-text(resolve-uri($node/@file, $envBaseURI))
else fn:data($node)
- } catch * {
+ }
+ catch *
+ {
fn:error($fots-err:errNA, $err:description)
}
};
+
(:~
- : returns the parent folder of the given file path.
- : example: util:parent-folder('/home/user/file.ext') returns '/home/user'.
+ : Returns the parent folder of the given file path.
+ : example: util:parent-folder('/home/user/file.ext') returns '/home/user'.
+ :
: @param $path Path.
: @return the parent folder of the given file.
:)
-
declare function util:parent-folder(
- $path as xs:string
-) as xs:anyURI {
- xs:anyURI(fn:substring-before($path,
- file:base-name($path)))
-};
-
-declare function util:serialize-result(
- $result as item()*
-) as xs:string* {
-util:serialize-result($result,
- $util:serParamXml)
-};
-
-declare function util:serialize-result(
- $result as item()*,
+ $path as xs:string
+) as xs:anyURI
+{
+ xs:anyURI(fn:substring-before($path, file:base-name($path)))
+};
+
+
+declare function util:serialize-result(
+ $result as item()*
+) as xs:string*
+{
+ util:serialize-result($result, $util:serParamXml)
+};
+
+
+declare function util:serialize-result(
+ $result as item()*,
$SerParams
-) as xs:string* {
+) as xs:string*
+{
for $res in $result
return
- if($res instance of node())
- then fn:serialize($res,
- $SerParams)
+ if ($res instance of node())
+ then fn:serialize($res, $SerParams)
else fn:string($res)
};
Follow ups