Exist: Error preventing xqsuite tests from running

Created on 14 Apr 2018  路  10Comments  路  Source: eXist-db/exist

What is the problem

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.

What did you expect

I expected the inspect:module-functions function to be able to access modules and return function items for each function within the module.

Describe how to reproduce or add a test

  1. 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.

  2. 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.

Context information

  • eXist-db version + Git Revision hash e.g. eXist-db 4.1.0-SNAPSHOT+201804141256 / 7db6f7ca0
  • Java version: Oracle JDK 1.8.0_162
  • Operating system: macOS 10.13.4
  • 32 or 64 bit: 64 bit
  • Any custom changes in e.g. conf.xml: none
regression

Most helpful comment

@adamretter I can confirm this fixes the problem running xqsuite tests for me. Many thanks!

All 10 comments

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:

  1. The first query returns a single item and not an error.
  2. The second still returns (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!

Was this page helpful?
0 / 5 - 0 ratings