← Back to team overview

zorba-coders team mailing list archive

[Merge] lp:~zorba-coders/zorba/fix_bug_1080616 into lp:zorba

 

Sorin Marian Nasoi has proposed merging lp:~zorba-coders/zorba/fix_bug_1080616 into lp:zorba.

Commit message:
Added 'process.xq' script in order to help run a subset of test cases with process module.
The test cases may be filtered depending on test set name and/or dependency.

Requested reviews:
  Nicolae Brinza (nbrinza)
  Sorin Marian Nasoi (sorin.marian.nasoi)
Related bugs:
  Bug #1080616 in Zorba: "FOTS: running the CLI in a separate process"
  https://bugs.launchpad.net/zorba/+bug/1080616

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/fix_bug_1080616/+merge/139468

Added 'process.xq' script in order to help run a subset of test cases with process module.
The test cases may be filtered depending on test set name and/or dependency.
-- 
https://code.launchpad.net/~zorba-coders/zorba/fix_bug_1080616/+merge/139468
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'test/fots_driver/fots-driver.xq'
--- test/fots_driver/fots-driver.xq	2012-11-27 10:54:05 +0000
+++ test/fots_driver/fots-driver.xq	2012-12-12 13:54:24 +0000
@@ -103,7 +103,7 @@
  : (empty string means all test cases).
  : @return matching test case names.
  :)
-declare %private function driver:list-test-cases(
+declare function driver:list-test-cases(
   $testSetDoc as document-node(),
   $dependency as xs:string*
 ) as xs:string* {

=== added file 'test/fots_driver/tools/process.xq'
--- test/fots_driver/tools/process.xq	1970-01-01 00:00:00 +0000
+++ test/fots_driver/tools/process.xq	2012-12-12 13:54:24 +0000
@@ -0,0 +1,127 @@
+(:
+ : Copyright 2006-2011 The FLWOR Foundation.
+ :
+ : Licensed under the Apache License, Version 2.0 (the "License");
+ : you may not use this file except in compliance with the License.
+ : You may obtain a copy of the License at
+ :
+ : http://www.apache.org/licenses/LICENSE-2.0
+ :
+ : Unless required by applicable law or agreed to in writing, software
+ : distributed under the License is distributed on an "AS IS" BASIS,
+ : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ : See the License for the specific language governing permissions and
+ : limitations under the License.
+ :)
+ 
+(:~
+ : Run every test case that matches a given criterion in a different process
+ : and report every test case that HANGS or ends in a SEG FAULT.
+ :
+ : @author Sorin Nasoi
+ :)
+
+
+import module namespace proc =
+  "http://www.zorba-xquery.com/modules/process";;
+import module namespace util =
+  "http://www.zorba-xquery.com/fots-driver/util"; at "../util.xq";
+import module namespace d =
+  "http://www.zorba-xquery.com/fots-driver"; at "../fots-driver.xq";
+import module namespace fots-err =
+  "http://www.zorba-xquery.com/fots-driver/errors"; at "../errors.xq";
+  
+declare namespace ann =
+  "http://www.zorba-xquery.com/annotations";;
+declare namespace fots =
+  "http://www.w3.org/2010/09/qt-fots-catalog";;
+
+declare variable $pathFOTS as xs:string external :="";
+
+(:~
+ : Return the exit-code after invoking the FOTS driver with given $params.
+ :
+ : @param $params additional params.
+ : @return the exit-code returned by the invoked application.
+ :)
+declare %ann:sequential function local:exec(
+  $params as xs:string*
+) as xs:string {
+  variable $pathZorba := normalize-space(xs:string(proc:exec("pwd")/proc:stdout));
+
+  proc:exec(string-join(($pathZorba, "/zorba"),''),
+            ("-f", "-q", concat($pathZorba, "/../../test/fots_driver/cli.xq"),
+             "-e", concat("fotsPath:=", $pathFOTS),
+             "-e", "verbose:=false",
+             $params
+            )
+           )/proc:exit-code
+};
+
+declare %private %ann:sequential function local:invoke-exec(
+  $testSets   as element(fots:test-set)*,
+  $baseUri    as xs:anyURI,
+  $dependency as xs:string*
+) as xs:string* {
+  for $testSet in $testSets
+    let $testSetDoc := doc(resolve-uri($testSet/@file, $baseUri))
+    let $testSetName := xs:string($testSet/@name)
+    let $testCaseNames as xs:string* := d:list-test-cases($testSetDoc,
+                                                          $dependency)
+    return
+      for $testCaseName in $testCaseNames
+      let $exit-code := 
+          trace(local:exec(("-e", "mode:=run-test-case",
+                      "-e", concat("testSetName:=",  $testSetName),
+                      "-e", concat("testCaseName:=", trace($testCaseName, "processing test case :"))
+                     )
+                    ),"exit-code")
+      where (xs:integer($exit-code) gt xs:integer(134))
+      return $testCaseName
+};
+  
+(:~
+ : Return the name of the test cases that return an exit-code > 128.
+ :
+ : @param $fotsPath path to the FOTS catalog file.
+ : @param $testSetPrefixes name/criteria for the test sets.
+ : @param $dependency defined dependency.
+ : @return the exit-codes returned by the invoked applications.
+ :)
+declare %ann:sequential function local:list-test-cases(
+  $fotsPath         as xs:string,
+  $testSetPrefixes  as xs:string*,
+  $dependency       as xs:string*
+) as xs:string* {
+  variable  $doc := doc(resolve-uri($fotsPath)),
+            $baseUri:= resolve-uri(util:parent-folder($fotsPath));
+ 
+  if(string-join($testSetPrefixes,'') = '')
+  then local:invoke-exec($doc/fots:catalog/fots:test-set,
+                         $baseUri,
+                         $dependency)
+  else
+    for $prefix in $testSetPrefixes
+    return
+      local:invoke-exec($doc/fots:catalog/fots:test-set[starts-with(@name, $prefix)],
+                        $baseUri,
+                        $dependency)
+};
+
+if( $pathFOTS = '')
+then fn:error($fots-err:errNA, 
+              "please set the external variable $pathFOTS to point to FOTS catalog.xml file.")
+else
+concat("'",
+       string-join(local:list-test-cases($pathFOTS, '', 'higherOrderFunctions'),"', '"),
+       "'")
+
+
+(:
+local:exec(
+            ("-e", "mode:=run-test-case",
+             "-e", concat("testSetName:=",  "misc-HigherOrderFunctions"),
+             "-e", concat("testCaseName:=", "xqhof2")
+            )
+          )
+:)
\ No newline at end of file


Follow ups