Skip to content

Commit d3cc1e7

Browse files
authored
Merge pull request #4622 from evolvedbinary/hotfix/xqsuite-non-error-reported-as-error
Fix bugs in XQSuite and XQuery tests written for XQSuite
2 parents e007686 + 0c66292 commit d3cc1e7

File tree

33 files changed

+865
-123
lines changed

33 files changed

+865
-123
lines changed

.github/workflows/ci-deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
- name: Install bats
3030
run: sudo apt-get install bats
3131
- name: Build images
32-
run: mvn -V -B -q -Pdocker -DskipTests -Ddependency-check.skip=true clean package
32+
run: mvn -V -B -q -Pdocker -DskipTests -Ddependency-check.skip=true -P !mac-dmg-on-unix,!installer,!concurrency-stress-tests,!micro-benchmarks,skip-build-dist-archives clean package
3333
- name: Check local images
3434
run: docker image ls
3535
- name: Check license headers

exist-core/pom.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,10 @@
757757
<exclude>src/test/java/org/exist/xquery/value/SubSequenceTest.java</exclude>
758758
<exclude>src/test/xquery/binary-value.xqm</exclude>
759759
<exclude>src/test/xquery/order.xqm</exclude>
760+
<exclude>src/test/xquery/type-promotion.xqm</exclude>
761+
<exclude>src/test/xquery/xqsuite/xqsuite-assertions-dynamic.xqm</exclude>
762+
<exclude>src/test/xquery/xqsuite/xqsuite-assertions-inline.xqm</exclude>
763+
<exclude>src/test/xquery/xqsuite/xqsuite-assertions.resources.xqm.ignore</exclude>
760764

761765
<!--
762766
Derivative work licensed under dbXML 1.0 and LGPL 2.1
@@ -913,6 +917,10 @@ The original license statement is also included below.]]></preamble>
913917
<include>src/test/java/org/exist/xquery/value/SubSequenceTest.java</include>
914918
<include>src/test/xquery/binary-value.xqm</include>
915919
<include>src/test/xquery/order.xqm</include>
920+
<include>src/test/xquery/type-promotion.xqm</include>
921+
<include>src/test/xquery/xqsuite/xqsuite-assertions-dynamic.xqm</include>
922+
<include>src/test/xquery/xqsuite/xqsuite-assertions-inline.xqm</include>
923+
<include>src/test/xquery/xqsuite/xqsuite-assertions.resources.xqm.ignore</include>
916924
</includes>
917925

918926
</licenseSet>

exist-core/src/main/java/org/exist/xquery/UntypedValueCheck.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public UntypedValueCheck(XQueryContext context, int requiredType, Error error) {
5555
public UntypedValueCheck(XQueryContext context, int requiredType, final Expression expression, Error error) {
5656
super(context);
5757
this.requiredType = requiredType;
58-
if (expression instanceof Atomize && requiredType != Type.ATOMIC) {
58+
if (expression instanceof Atomize && !Type.subTypeOf(requiredType, Type.ATOMIC)) {
5959
this.expression = ((Atomize)expression).getExpression();
6060
this.atomize = true;
6161
} else {
@@ -109,7 +109,7 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc
109109
}
110110

111111
private Item convert(Item item) throws XPathException {
112-
if (atomize || item.getType() == Type.UNTYPED_ATOMIC || Type.subTypeOfUnion(requiredType, Type.NUMBER) && Type.subTypeOfUnion(item.getType(), Type.NUMBER)) {
112+
if (atomize || item.getType() == Type.UNTYPED_ATOMIC || Type.hasMember(Type.NUMBER, requiredType) && Type.subTypeOfUnion(item.getType(), Type.NUMBER)) {
113113
try {
114114
if (Type.subTypeOf(item.getType(), requiredType)) {
115115
return item;

exist-core/src/main/java/org/exist/xquery/XQueryContext.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2625,7 +2625,15 @@ private Module importModuleFromLocation(final String namespaceURI, @Nullable fin
26252625
final Source moduleSource;
26262626
try {
26272627
//TODO: use URIs to ensure proper resolution of relative locations
2628-
moduleSource = SourceFactory.getSource(getBroker(), moduleLoadPath, location, true);
2628+
final String contextPath;
2629+
if (source instanceof FileSource) {
2630+
final Path sourcePath = ((FileSource)source).getPath();
2631+
contextPath = sourcePath.resolveSibling(moduleLoadPath).normalize().toString();
2632+
} else {
2633+
contextPath = moduleLoadPath;
2634+
}
2635+
2636+
moduleSource = SourceFactory.getSource(getBroker(), contextPath, location, true);
26292637
if (moduleSource == null) {
26302638
throw moduleLoadException("Source for module '" + namespaceURI + "' not found module location hint URI '" + location + "'.", location);
26312639
}

exist-core/src/main/java/org/exist/xquery/functions/inspect/InspectFunctionHelper.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ private static void writeParameters(final FunctionSignature sig, final MemTreeBu
125125
}
126126

127127
private static void writeAnnotations(final FunctionSignature signature, final MemTreeBuilder builder) throws XPathException {
128-
final AttributesImpl attribs = new AttributesImpl();
129128
final Annotation[] annots = signature.getAnnotations();
130129
if (annots != null) {
130+
final AttributesImpl attribs = new AttributesImpl();
131131
for (final Annotation annot : annots) {
132132
attribs.clear();
133133
attribs.addAttribute(null, "name", "name", "CDATA", annot.getName().toString());
@@ -136,7 +136,9 @@ private static void writeAnnotations(final FunctionSignature signature, final Me
136136
final LiteralValue[] value = annot.getValue();
137137
if (value != null) {
138138
for (final LiteralValue literal : value) {
139-
builder.startElement(ANNOTATION_VALUE_QNAME, null);
139+
attribs.clear();
140+
attribs.addAttribute(null, "type", "type", "CDATA", Type.getTypeName(literal.returnsType()));
141+
builder.startElement(ANNOTATION_VALUE_QNAME, attribs);
140142
builder.characters(literal.getValue().getStringValue());
141143
builder.endElement();
142144
}

exist-core/src/main/java/org/exist/xquery/functions/util/IndexKeys.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public class IndexKeys extends BasicFunction {
6262
"containing three int values: a) the overall frequency of the key within the node set, " +
6363
"b) the number of distinct documents in the node set the key occurs in, " +
6464
"c) the current position of the key in the whole list of keys returned."),
65-
new FunctionParameterSequenceType("max-number-returned", Type.INT, Cardinality.ZERO_OR_ONE, "The maximum number of returned keys")
65+
new FunctionParameterSequenceType("max-number-returned", Type.INTEGER, Cardinality.ZERO_OR_ONE, "The maximum number of returned keys")
6666
},
6767
new FunctionReturnSequenceType(Type.ITEM, Cardinality.ZERO_OR_MORE, "the results of the eval of the $function-reference")),
6868
new FunctionSignature(
@@ -79,7 +79,7 @@ public class IndexKeys extends BasicFunction {
7979
"containing three int values: a) the overall frequency of the key within the node set, " +
8080
"b) the number of distinct documents in the node set the key occurs in, " +
8181
"c) the current position of the key in the whole list of keys returned."),
82-
new FunctionParameterSequenceType("max-number-returned", Type.INT, Cardinality.ZERO_OR_ONE , "The maximum number of returned keys"),
82+
new FunctionParameterSequenceType("max-number-returned", Type.INTEGER, Cardinality.ZERO_OR_ONE , "The maximum number of returned keys"),
8383
new FunctionParameterSequenceType("index", Type.STRING, Cardinality.EXACTLY_ONE, "The index in which the search is made")
8484
},
8585
new FunctionReturnSequenceType(Type.ITEM, Cardinality.ZERO_OR_MORE, "the results of the eval of the $function-reference")),
@@ -97,7 +97,7 @@ public class IndexKeys extends BasicFunction {
9797
"containing three int values: a) the overall frequency of the key within the node set, " +
9898
"b) the number of distinct documents in the node set the key occurs in, " +
9999
"c) the current position of the key in the whole list of keys returned."),
100-
new FunctionParameterSequenceType("max-number-returned", Type.INT, Cardinality.ZERO_OR_ONE, "The maximum number of returned keys"),
100+
new FunctionParameterSequenceType("max-number-returned", Type.INTEGER, Cardinality.ZERO_OR_ONE, "The maximum number of returned keys"),
101101
new FunctionParameterSequenceType("index", Type.STRING, Cardinality.EXACTLY_ONE, "The index in which the search is made")
102102
},
103103
new FunctionReturnSequenceType(Type.ITEM, Cardinality.ZERO_OR_MORE, "the results of the eval of the $function-reference")),

exist-core/src/main/java/org/exist/xquery/functions/xmldb/XMLDBGetMimeType.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ public class XMLDBGetMimeType extends BasicFunction {
5050
new FunctionSignature(
5151
new QName("get-mime-type", XMLDBModule.NAMESPACE_URI, XMLDBModule.PREFIX),
5252
"Returns the MIME type if available of the resource $resource-uri, otherwise the empty sequence. " +
53-
XMLDBModule.ANY_URI,
53+
XMLDBModule.ANY_URI,
5454
new SequenceType[] {
55-
new FunctionParameterSequenceType("resource-uri", Type.ANY_URI, Cardinality.EXACTLY_ONE, "The resource URI")
55+
new FunctionParameterSequenceType("resource-uri", Type.STRING, Cardinality.EXACTLY_ONE, "The resource URI")
5656
},
5757
new FunctionReturnSequenceType(Type.STRING, Cardinality.ZERO_OR_ONE, "the mime-type if available, otherwise the empty sequence")
5858
);

exist-core/src/main/java/org/exist/xquery/value/Type.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ public class Type {
317317
}
318318

319319
static {
320-
defineUnionType(NUMBER, new int[]{ INTEGER, DECIMAL, FLOAT, DOUBLE });
320+
defineUnionType(NUMBER, new int[]{ DECIMAL, FLOAT, DOUBLE });
321321
}
322322

323323
// https://www.w3.org/TR/xmlschema-2/#built-in-primitive-datatypes

0 commit comments

Comments
 (0)