~zorba-coders/zorba/bug1151967

« back to all changes in this revision

Viewing changes to test/fots_driver/fots-driver.xq

  • Committer: Paul J. Lucas
  • Date: 2013-08-15 00:14:17 UTC
  • mfrom: (11597 lp_zorba)
  • mto: This revision was merged to the branch mainline in revision 11598.
  • Revision ID: paul@lucasmail.org-20130815001417-g22x9plxc8fv73zd
MergeĀ fromĀ trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
886
886
      "
"
887
887
      );
888
888
 
889
 
    variable $xqxqQuery := driver:create-XQXQ-query($query,
 
889
    variable $zqQuery := driver:create-ZQ-query($query,
890
890
                                                    $case,
891
891
                                                    $env,
892
892
                                                    $envBaseURI,
896
896
    (:if $verbose then print the query to a file:)
897
897
    if ($verbose and
898
898
        ($cliMode eq "run-test-case"))
899
 
    then util:write-query-to-file($xqxqQuery, $queryName);
 
899
    then util:write-query-to-file($zqQuery, $queryName);
900
900
    else ();
901
901
 
902
902
    variable $startDateTime := datetime:current-dateTime();
903
903
 
904
 
    variable $result := execute:xqxq-invoke($xqxqQuery,
 
904
    variable $result := execute:zq-invoke($zqQuery,
905
905
                                            $case,
906
906
                                            $verbose,
907
907
                                            $testSetURI,
914
914
    if ($checkPass) then
915
915
      feedback:pass($case,
916
916
                    $result,
917
 
                    $xqxqQuery,
 
917
                    $zqQuery,
918
918
                    $env,
919
919
                    $duration,
920
920
                    $verbose,
927
927
    else
928
928
     feedback:fail($case,
929
929
                   $result,
930
 
                   $xqxqQuery,
 
930
                   $zqQuery,
931
931
                   $testSetName,
932
932
                   $env,
933
933
                   $duration,
956
956
 
957
957
 
958
958
(:~
959
 
 : Creates the text for the complete query FQ that will be evaluated via XQXQ
 
959
 : Creates the text for the complete query FQ that will be evaluated via ZQ
960
960
 : by the fots test driver. The actual test-case query TQ will be evaluated as
961
 
 : a nested XQXQ query within FQ. FQ may contain additional nested XQXQ queries,
 
961
 : a nested ZQ query within FQ. FQ may contain additional nested zorba-query queries,
962
962
 : for example to compute values for external variables declared in TQ.
963
963
 :
964
964
 : @param $queryText the text for the test-case query TQ. It is content of
972
972
 :        These may be defined at test-set level and/or test-case level.
973
973
 : @return the query that will be evaluated.
974
974
 :)
975
 
declare %private function driver:create-XQXQ-query(
 
975
declare %private function driver:create-ZQ-query(
976
976
  $queryText          as xs:string,
977
977
  $case               as element(fots:test-case),
978
978
  $env                as element(fots:environment)?,
995
995
    (
996
996
    (
997
997
    "",
998
 
    "import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';",
 
998
    "import module namespace zq = 'http://zorba.io/modules/zorba-query';",
999
999
   
1000
1000
    if ($needsDTDValidation) then
1001
1001
      ("import module namespace zorba-xml = 'http://zorba.io/modules/xml';",
1003
1003
    else (),
1004
1004
   
1005
1005
    if (exists($resolver))
1006
 
    then "declare namespace resolver = 'http://www.zorba-xquery.com/modules/xqxq/url-resolver';"
 
1006
    then "declare namespace resolver = 'http://zorba.io/modules/zorba-query/url-resolver';"
1007
1007
    else (),
1008
1008
 
1009
1009
    if (exists($mapper))
1010
 
    then "declare namespace mapper = 'http://www.zorba-xquery.com/modules/xqxq/uri-mapper';"
 
1010
    then "declare namespace mapper = 'http://zorba.io/modules/zorba-query/uri-mapper';"
1011
1011
    else (),
1012
1012
 
1013
1013
    "",
1037
1037
    let $escAposQueryText := replace($queryText,"'","''")
1038
1038
    let $escAmpQueryText  := replace($escAposQueryText, '&', '&')
1039
1039
    return concat(
1040
 
           "variable $queryID := xqxq:prepare-main-module
(",
 
1040
           "variable $queryID := zq:prepare-main-module
(",
1041
1041
           "
",
1042
1042
           "'",
1043
1043
           "
",
1058
1058
    env:set-variables($env, $envBaseURI),
1059
1059
    env:set-variables($case/fots:environment, $testSetURI),
1060
1060
 
1061
 
    "xqxq:evaluate($queryID),",
 
1061
    "zq:evaluate($queryID),",
1062
1062
    "",
1063
 
    "xqxq:delete-query($queryID)",
 
1063
    "zq:delete-query($queryID)",
1064
1064
    "        "
1065
1065
    ),
1066
1066
    "
"