Skip to content
Browse files

Split test suites to rule out side effects.

  • Loading branch information...
1 parent 16cbe8e commit d37d4e47fbe87e7b27180ccc63e711a9d1ba2f0e @wolfgangmm wolfgangmm committed
View
1 extensions/indexes/range/test/src/xquery/range.xql
@@ -2,7 +2,6 @@ xquery version "3.0";
module namespace rt="http://exist-db.org/xquery/range/test";
-import module namespace range="http://exist-db.org/xquery/range" at "java:org.exist.xquery.modules.range.RangeIndexModule";
import module namespace test="http://exist-db.org/xquery/xqsuite" at "resource:org/exist/xquery/lib/xqsuite/xqsuite.xql";
declare variable $rt:COLLECTION_CONFIG :=
View
8 extensions/indexes/range/test/src/xquery/suite-fields.xql
@@ -0,0 +1,8 @@
+xquery version "3.0";
+
+import module namespace test="http://exist-db.org/xquery/xqsuite"
+at "resource:org/exist/xquery/lib/xqsuite/xqsuite.xql";
+
+import module namespace rt="http://exist-db.org/xquery/range/test/fields" at "file:extensions/indexes/range/test/src/xquery/fields.xql";
+
+test:suite(util:list-functions(xs:anyURI("http://exist-db.org/xquery/range/test/fields")))
View
8 extensions/indexes/range/test/src/xquery/suite-optimizer.xql
@@ -0,0 +1,8 @@
+xquery version "3.0";
+
+import module namespace test="http://exist-db.org/xquery/xqsuite"
+at "resource:org/exist/xquery/lib/xqsuite/xqsuite.xql";
+
+import module namespace ot="http://exist-db.org/xquery/range/optimizer/test" at "file:extensions/indexes/range/test/src/xquery/optimizer.xql";
+
+test:suite(util:list-functions(xs:anyURI("http://exist-db.org/xquery/range/optimizer/test")))
View
9 extensions/indexes/range/test/src/xquery/suite.xql
@@ -2,12 +2,7 @@ xquery version "3.0";
import module namespace test="http://exist-db.org/xquery/xqsuite"
at "resource:org/exist/xquery/lib/xqsuite/xqsuite.xql";
-import module namespace rt="http://exist-db.org/xquery/range/test/fields" at "file:extensions/indexes/range/test/src/xquery/fields.xql";
-import module namespace ot="http://exist-db.org/xquery/range/optimizer/test" at "file:extensions/indexes/range/test/src/xquery/optimizer.xql";
+
import module namespace rtt="http://exist-db.org/xquery/range/test" at "file:extensions/indexes/range/test/src/xquery/range.xql";
-test:suite((
- util:list-functions(xs:anyURI("http://exist-db.org/xquery/range/test")),
- util:list-functions(xs:anyURI("http://exist-db.org/xquery/range/test/fields")),
- util:list-functions(xs:anyURI("http://exist-db.org/xquery/range/optimizer/test"))
-))
+test:suite(util:list-functions(xs:anyURI("http://exist-db.org/xquery/range/test")))
View
82 test/src/xquery/TestRunner.java
@@ -45,6 +45,7 @@
import org.xmldb.api.modules.XMLResource;
import java.io.File;
+import java.io.FileFilter;
import java.io.IOException;
import javax.xml.parsers.ParserConfigurationException;
@@ -118,48 +119,53 @@ else if (filter.accept(dir.getParentFile(), dir.getName()))
@Test
public void runXQueryBasedTests() {
File dir = new File(getDirectory());
- File xquery = new File(dir, "suite.xql");
- if (!(xquery.exists() && xquery.canRead()))
- return;
- try {
- StringBuilder fails = new StringBuilder();
- StringBuilder results = new StringBuilder();
- XQueryService xqs = (XQueryService) rootCollection.getService("XQueryService", "1.0");
- xqs.setModuleLoadPath(getDirectory());
- Source query = new FileSource(xquery, "UTF-8", false);
-
- ResourceSet result = xqs.execute(query);
- XMLResource resource = (XMLResource) result.getResource(0);
- results.append(resource.getContent()).append('\n');
-
- Element root = (Element) resource.getContentAsDOM();
- NodeList testsuites = root.getElementsByTagName("testsuite");
- for (int i = 0; i < testsuites.getLength(); i++) {
- Element testsuite = (Element) testsuites.item(i);
- NodeList tests = testsuite.getElementsByTagName("testcase");
- for (int j = 0; j < tests.getLength(); j++) {
- Element test = (Element) tests.item(j);
- NodeList failures = test.getElementsByTagName("failure");
- if (failures.getLength() > 0) {
- fails.append("Test '" + test.getAttribute("name") + "' in module '" +
- testsuite.getAttribute("package") + "' failed.\n");
- }
+ File[] suites = dir.listFiles(new FileFilter() {
+ @Override
+ public boolean accept(File file) {
+ return (file.canRead() && file.getName().startsWith("suite") && file.getName().endsWith(".xql"));
+ }
+ });
+ for (File suite: suites) {
+ try {
+ StringBuilder fails = new StringBuilder();
+ StringBuilder results = new StringBuilder();
+ XQueryService xqs = (XQueryService) rootCollection.getService("XQueryService", "1.0");
+ xqs.setModuleLoadPath(getDirectory());
+ Source query = new FileSource(suite, "UTF-8", false);
+
+ ResourceSet result = xqs.execute(query);
+ XMLResource resource = (XMLResource) result.getResource(0);
+ results.append(resource.getContent()).append('\n');
- NodeList errors = test.getElementsByTagName("error");
- if (errors.getLength() > 0) {
- fails.append("Test '" + test.getAttribute("name") + "' in module '" +
- testsuite.getAttribute("package") + "' failed with an error.\n");
+ Element root = (Element) resource.getContentAsDOM();
+ NodeList testsuites = root.getElementsByTagName("testsuite");
+ for (int i = 0; i < testsuites.getLength(); i++) {
+ Element testsuite = (Element) testsuites.item(i);
+ NodeList tests = testsuite.getElementsByTagName("testcase");
+ for (int j = 0; j < tests.getLength(); j++) {
+ Element test = (Element) tests.item(j);
+ NodeList failures = test.getElementsByTagName("failure");
+ if (failures.getLength() > 0) {
+ fails.append("Test '" + test.getAttribute("name") + "' in module '" +
+ testsuite.getAttribute("package") + "' failed.\n");
+ }
+
+ NodeList errors = test.getElementsByTagName("error");
+ if (errors.getLength() > 0) {
+ fails.append("Test '" + test.getAttribute("name") + "' in module '" +
+ testsuite.getAttribute("package") + "' failed with an error.\n");
+ }
}
}
+ if (fails.length() > 0) {
+ System.err.print(results);
+ fail(fails.toString());
+ }
+ System.out.println(results);
+ } catch (XMLDBException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
}
- if (fails.length() > 0) {
- System.err.print(results);
- fail(fails.toString());
- }
- System.out.println(results);
- } catch (XMLDBException e) {
- e.printStackTrace();
- fail(e.getMessage());
}
}

0 comments on commit d37d4e4

Please sign in to comment.
Something went wrong with that request. Please try again.