The test:suite function from the xqsuite.xql module takes a sequence of function items, typically supplied via the inspect:module-functions function. However, with a current build of develop, the inspect:module-functions function fails, returning 0 items.
I expected the inspect:module-functions function to be able to access modules and return function items for each function within the module.
Upload an xqsuite test such as https://github.com/eXist-db/exist/blob/develop/extensions/indexes/lucene/test/src/xquery/lucene/analyzers.xql to the database, storing it as /db/analyzers.xql.
Run the following query (in eXide or your query environment of choice):
xquery version "3.1";
import module namespace test="http://exist-db.org/xquery/xqsuite" at "resource:org/exist/xquery/lib/xqsuite/xqsuite.xql";
let $source := "/db/analyzers.xql"
return
try {
test:suite(inspect:module-functions(xs:anyURI("xmldb:exist://" || $source)))
} catch * {
map {
"code": $err:code,
"description": $err:description,
"value": $err:value,
"module": $err:module,
"line-number": $err:line-number,
"column-number": $err:column-number,
"additional": $err:additional
}
}
The query will return the following error:
map {
"column-number": 20,
"line-number": 8,
"additional": (),
"module": "String",
"code": Q{http://exist.sourceforge.net/NS/exist/java-binding}org.exist.xquery.XPathException,
"value": (),
"description": "exerr:ERROR XPTY0004: The actual cardinality for parameter 1 does not match the cardinality declared in the function's signature: test:suite($functions as function(*)+) item()*. Expected cardinality: one or more, got 0. [at line 8, column 20...]"
}
A more direct test is as follows:
xquery version "3.1";
import module namespace test="http://exist-db.org/xquery/xqsuite" at "resource:org/exist/xquery/lib/xqsuite/xqsuite.xql";
let $source := "/db/analyzers.xql"
return
(
util:binary-doc-available($source),
empty(inspect:module-functions(xs:anyURI("xmldb:exist://" || $source)))
)
The query returns two true() - meaning that the module is in the database and that inspect:module-functions is returning the empty sequence.
@adamretter Possibly related to https://github.com/eXist-db/exist/commit/f5b1b89022df5afc4d01dd9993d65ed0054e9ebe?
I can confirm that reverting to https://github.com/eXist-db/exist/commit/0d84f9f16075ad4a40b81b6b953cbe7c6d88c60f (the parent commit before https://github.com/eXist-db/exist/pull/1747 was merged) allows xqsuite tests to run without this error.
I would need to investigate. The xqsuite tests are run by and seem to pass on Travis and AppVeyor. So I am sceptical ;-)
How are you running your test suite?
Running both of your examples above in the Java Admin Client on the latest HEAD of develop gives me:
(true, true).I see the problem. Frustratingly the errors that are happening in inspect/ModuleFunctions.java are thrown away unless you have debug level logging enabled :-/ So there is the first bug!
yeas I addressed that a long time ago, but my remarks were blshtted away by then :-) e.g. in a scenario where there is a syntax error in the xquery code
@adamretter @dizzzz Is the underlying issue the one that this PR addresses? https://github.com/eXist-db/exist/pull/1285. I also wonder if this one is related: https://github.com/eXist-db/exist/issues/1754.
yes these are related.
@joewiz I think they are different but similar issues.
@adamretter I can confirm this fixes the problem running xqsuite tests for me. Many thanks!
Most helpful comment
@adamretter I can confirm this fixes the problem running xqsuite tests for me. Many thanks!