http://git-wip-us.apache.org/repos/asf/vxquery/blob/fccce23d/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/AbstractTestCaseFactory.java ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/AbstractTestCaseFactory.java b/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/AbstractTestCaseFactory.java index 77400e9..31e45d7 100644 --- a/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/AbstractTestCaseFactory.java +++ b/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/AbstractTestCaseFactory.java @@ -14,10 +14,16 @@ */ package org.apache.vxquery.xtest; +import java.io.BufferedReader; import java.io.File; +import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.net.URL; +import java.util.Arrays; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; import java.util.regex.Pattern; import javax.xml.namespace.QName; @@ -38,6 +44,7 @@ public abstract class AbstractTestCaseFactory { public TestCase tc; public Pattern include; public Pattern exclude; + public Set<String> previousTestResults; public XTestOptions opts; public String nextVariable; public boolean expectedError; @@ -45,6 +52,11 @@ public abstract class AbstractTestCaseFactory { public int currPathLen; public int count; + static int TEST_NAME_INDEX = 0; + static int TEST_RESULT_INDEX = 1; + static List<String> PASSING_TESTS = Arrays.asList("EXPECTED_RESULT_GOT_SAME_RESULT", + "EXPECTED_ERROR_GOT_SAME_ERROR"); + public AbstractTestCaseFactory(XTestOptions opts) { System.err.println("opts.catalog: " + opts.catalog); this.catalog = new File(opts.catalog); @@ -58,6 +70,11 @@ public abstract class AbstractTestCaseFactory { if (opts.exclude != null) { this.exclude = Pattern.compile(opts.exclude); } + if (opts.previousTestResults != null) { + this.previousTestResults = getPreviousTests(opts.previousTestResults); + } else { + this.previousTestResults = null; + } try { currPathLen = new File(".").getCanonicalPath().length(); } catch (IOException e) { @@ -65,6 +82,27 @@ public abstract class AbstractTestCaseFactory { } } + private static Set<String> getPreviousTests(String previousTestResults) { + Set<String> tests = new LinkedHashSet<String>(); + try { + BufferedReader br = new BufferedReader(new FileReader(previousTestResults)); + String line; + String[] resultRow; + while ((line = br.readLine()) != null) { + resultRow = line.split(","); + if (PASSING_TESTS.contains(resultRow[TEST_RESULT_INDEX].trim())) { + tests.add(resultRow[TEST_NAME_INDEX].trim()); + } + } + br.close(); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + return tests; + } + public int process() throws Exception { count = 0; XMLReader parser = XMLReaderFactory.createXMLReader(); @@ -79,10 +117,21 @@ public abstract class AbstractTestCaseFactory { + new File(url.getFile()).getCanonicalPath().substring(currPathLen)); } }); - parser.parse(new InputSource(new FileReader(catalog))); + FileReader characterStream = new FileReader(catalog); + parser.parse(new InputSource(characterStream)); + characterStream.close(); return count; } + protected boolean submitTestCase(TestCase tc) { + boolean toSubmit = include == null || include.matcher(tc.getXQueryDisplayName()).find(); + toSubmit = toSubmit && (exclude == null || !exclude.matcher(tc.getXQueryDisplayName()).find()); + if (previousTestResults != null) { + toSubmit = previousTestResults.contains(tc.getXQueryDisplayName()); + } + return toSubmit; + } + protected abstract void submit(TestCase tc); protected class Handler implements ContentHandler {
http://git-wip-us.apache.org/repos/asf/vxquery/blob/fccce23d/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/HTMLFileReporterImpl.java ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/HTMLFileReporterImpl.java b/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/HTMLFileReporterImpl.java index 758a219..bc17bba 100644 --- a/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/HTMLFileReporterImpl.java +++ b/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/HTMLFileReporterImpl.java @@ -101,7 +101,6 @@ public class HTMLFileReporterImpl implements ResultReporter { writeHTML(out, createResultDir(reportFile)); out.flush(); } catch (IOException e) { - // TODO Auto-generated catch block e.printStackTrace(); } } http://git-wip-us.apache.org/repos/asf/vxquery/blob/fccce23d/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/ServletReporterImpl.java ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/ServletReporterImpl.java b/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/ServletReporterImpl.java index 96fdc0e..df18b53 100644 --- a/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/ServletReporterImpl.java +++ b/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/ServletReporterImpl.java @@ -51,6 +51,6 @@ public class ServletReporterImpl extends AbstractHandler implements ResultReport @Override public void close() { - + reporter.close(); } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/vxquery/blob/fccce23d/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestCaseFactory.java ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestCaseFactory.java b/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestCaseFactory.java index f3980db..d168185 100644 --- a/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestCaseFactory.java +++ b/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestCaseFactory.java @@ -26,11 +26,9 @@ public class TestCaseFactory extends AbstractTestCaseFactory { this.trf = trf; this.eSvc = eSvc; } - + protected void submit(TestCase tc) { - boolean toSubmit = include == null || include.matcher(tc.getXQueryDisplayName()).find(); - toSubmit = toSubmit && (exclude == null || !exclude.matcher(tc.getXQueryDisplayName()).find()); - if (toSubmit) { + if (submitTestCase(tc)) { if (opts.verbose) { System.err.println(tc); } http://git-wip-us.apache.org/repos/asf/vxquery/blob/fccce23d/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestRunner.java ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestRunner.java b/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestRunner.java index 9c0bc64..146f277 100644 --- a/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestRunner.java +++ b/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestRunner.java @@ -111,6 +111,7 @@ public class TestRunner { testCase.getSourceFileMap()); compiler.compile(testCase.getXQueryDisplayName(), in, ccb, opts.optimizationLevel); JobSpecification spec = compiler.getModule().getHyracksJobSpecification(); + in.close(); DynamicContext dCtx = new DynamicContextImpl(compiler.getModule().getModuleContext()); spec.setGlobalJobDataFactory(new VXQueryGlobalDataFactory(dCtx.createFactory())); http://git-wip-us.apache.org/repos/asf/vxquery/blob/fccce23d/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/XTestOptions.java ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/XTestOptions.java b/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/XTestOptions.java index 4788b6e..2b7b508 100644 --- a/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/XTestOptions.java +++ b/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/XTestOptions.java @@ -35,6 +35,9 @@ public class XTestOptions { @Option(name = "-exclude", required = false, usage = "Exclude filter regular expression") String exclude; + @Option(name = "-previous-test-results", required = false, usage = "File path to previous test results (text report output file)") + String previousTestResults; + @Option(name = "-v", required = false, usage = "Verbose") boolean verbose; http://git-wip-us.apache.org/repos/asf/vxquery/blob/fccce23d/vxquery-xtest/src/test/java/org/apache/vxquery/xtest/JUnitTestCaseFactory.java ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/test/java/org/apache/vxquery/xtest/JUnitTestCaseFactory.java b/vxquery-xtest/src/test/java/org/apache/vxquery/xtest/JUnitTestCaseFactory.java index 337fbd2..e1ea215 100644 --- a/vxquery-xtest/src/test/java/org/apache/vxquery/xtest/JUnitTestCaseFactory.java +++ b/vxquery-xtest/src/test/java/org/apache/vxquery/xtest/JUnitTestCaseFactory.java @@ -26,9 +26,10 @@ public class JUnitTestCaseFactory extends AbstractTestCaseFactory { } protected void submit(TestCase tc) { - boolean toSubmit = include == null || include.matcher(tc.getXQueryDisplayName()).find(); - toSubmit = toSubmit && (exclude == null || !exclude.matcher(tc.getXQueryDisplayName()).find()); - if (toSubmit) { + if (submitTestCase(tc)) { + if (opts.verbose) { + System.err.println(tc); + } testCases.add(new Object[] { tc }); ++count; } http://git-wip-us.apache.org/repos/asf/vxquery/blob/fccce23d/vxquery-xtest/src/test/java/org/apache/vxquery/xtest/VXQueryTest.java ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/test/java/org/apache/vxquery/xtest/VXQueryTest.java b/vxquery-xtest/src/test/java/org/apache/vxquery/xtest/VXQueryTest.java index 28d7735..f772dc8 100644 --- a/vxquery-xtest/src/test/java/org/apache/vxquery/xtest/VXQueryTest.java +++ b/vxquery-xtest/src/test/java/org/apache/vxquery/xtest/VXQueryTest.java @@ -32,11 +32,27 @@ public class VXQueryTest { private TestCase tc; private TestRunner tr; - private static String CATALOG = "VXQueryCatalog.xml"; + private static String VXQUERY_CATALOG = StringUtils.join(new String[] { "src", "test", "resources", + "VXQueryCatalog.xml" }, File.separator); + private static String XQTS_CATALOG = StringUtils.join(new String[] { "test-suites", "xqts", "XQTSCatalog.xml" }, + File.separator); - private static XTestOptions getOptions() { + private static boolean includeXqtsTests() { + return new File(XQTS_CATALOG).isFile(); + } + + private static XTestOptions getVXQueryOptions() { + XTestOptions opts = new XTestOptions(); + opts.catalog = VXQUERY_CATALOG; + opts.verbose = false; + opts.threads = 1; + return opts; + } + + private static XTestOptions getPreviousTestOptions() { XTestOptions opts = new XTestOptions(); - opts.catalog = StringUtils.join(new String[] { "src", "test", "resources", CATALOG }, File.separator); + opts.catalog = XQTS_CATALOG; + opts.previousTestResults = StringUtils.join(new String[] { "results", "xqts.txt" }, File.separator); opts.verbose = false; opts.threads = 1; return opts; @@ -44,13 +60,19 @@ public class VXQueryTest { @Parameters public static Collection<Object[]> tests() throws Exception { - JUnitTestCaseFactory jtcf = new JUnitTestCaseFactory(getOptions()); - return jtcf.getList(); + JUnitTestCaseFactory jtcf_vxquery = new JUnitTestCaseFactory(getVXQueryOptions()); + Collection<Object[]> tests = jtcf_vxquery.getList(); + if (includeXqtsTests()) { + JUnitTestCaseFactory jtcf_previous = new JUnitTestCaseFactory(getPreviousTestOptions()); + tests.addAll(jtcf_previous.getList()); + } + + return tests; } public VXQueryTest(TestCase tc) throws Exception { this.tc = tc; - tr = new TestRunner(getOptions()); + tr = new TestRunner(getVXQueryOptions()); } @Test http://git-wip-us.apache.org/repos/asf/vxquery/blob/fccce23d/vxquery-xtest/src/test/resources/ExpectedTestResults/Numerics/fn:abs.txt ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/Numerics/fn:abs.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/Numerics/fn:abs.txt deleted file mode 100644 index 77fbb52..0000000 --- a/vxquery-xtest/src/test/resources/ExpectedTestResults/Numerics/fn:abs.txt +++ /dev/null @@ -1,8 +0,0 @@ -5.5 -5 -5.5 -5.5 -5.5 -5 -5.5 -5.5 \ No newline at end of file http://git-wip-us.apache.org/repos/asf/vxquery/blob/fccce23d/vxquery-xtest/src/test/resources/ExpectedTestResults/Numerics/fn:ceiling.txt ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/Numerics/fn:ceiling.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/Numerics/fn:ceiling.txt deleted file mode 100644 index 1c95747..0000000 --- a/vxquery-xtest/src/test/resources/ExpectedTestResults/Numerics/fn:ceiling.txt +++ /dev/null @@ -1,8 +0,0 @@ -6 -5 -6 -6 --5 --5 --5 --5 \ No newline at end of file http://git-wip-us.apache.org/repos/asf/vxquery/blob/fccce23d/vxquery-xtest/src/test/resources/ExpectedTestResults/Numerics/fn_abs.txt ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/Numerics/fn_abs.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/Numerics/fn_abs.txt new file mode 100644 index 0000000..77fbb52 --- /dev/null +++ b/vxquery-xtest/src/test/resources/ExpectedTestResults/Numerics/fn_abs.txt @@ -0,0 +1,8 @@ +5.5 +5 +5.5 +5.5 +5.5 +5 +5.5 +5.5 \ No newline at end of file http://git-wip-us.apache.org/repos/asf/vxquery/blob/fccce23d/vxquery-xtest/src/test/resources/ExpectedTestResults/Numerics/fn_ceiling.txt ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/Numerics/fn_ceiling.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/Numerics/fn_ceiling.txt new file mode 100644 index 0000000..1c95747 --- /dev/null +++ b/vxquery-xtest/src/test/resources/ExpectedTestResults/Numerics/fn_ceiling.txt @@ -0,0 +1,8 @@ +6 +5 +6 +6 +-5 +-5 +-5 +-5 \ No newline at end of file http://git-wip-us.apache.org/repos/asf/vxquery/blob/fccce23d/vxquery-xtest/src/test/resources/Queries/XQuery/Numerics/fn:abs.xq ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Numerics/fn:abs.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Numerics/fn:abs.xq deleted file mode 100644 index 44bd08e..0000000 --- a/vxquery-xtest/src/test/resources/Queries/XQuery/Numerics/fn:abs.xq +++ /dev/null @@ -1,22 +0,0 @@ -(: Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. :) - -(: XQuery fn:abs :) -( - fn:abs(xs:decimal(5.5)), fn:abs(xs:integer(5)), fn:abs(xs:float(5.5)), fn:abs(xs:double(5.5)), - fn:abs(xs:decimal(-5.5)), fn:abs(xs:integer(-5)), fn:abs(xs:float(-5.5)), fn:abs(xs:double(-5.5)) -) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/vxquery/blob/fccce23d/vxquery-xtest/src/test/resources/Queries/XQuery/Numerics/fn:ceiling.xq ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Numerics/fn:ceiling.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Numerics/fn:ceiling.xq deleted file mode 100644 index 6a14197..0000000 --- a/vxquery-xtest/src/test/resources/Queries/XQuery/Numerics/fn:ceiling.xq +++ /dev/null @@ -1,22 +0,0 @@ -(: Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. :) - -(: XQuery fn:ceiling :) -( - fn:ceiling(xs:decimal(5.5)), fn:ceiling(xs:integer(5)), fn:ceiling(xs:float(5.5)), fn:ceiling(xs:double(5.5)), - fn:ceiling(xs:decimal(-5.5)), fn:ceiling(xs:integer(-5)), fn:ceiling(xs:float(-5.5)), fn:ceiling(xs:double(-5.5)) -) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/vxquery/blob/fccce23d/vxquery-xtest/src/test/resources/Queries/XQuery/Numerics/fn_abs.xq ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Numerics/fn_abs.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Numerics/fn_abs.xq new file mode 100644 index 0000000..44bd08e --- /dev/null +++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Numerics/fn_abs.xq @@ -0,0 +1,22 @@ +(: Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. :) + +(: XQuery fn:abs :) +( + fn:abs(xs:decimal(5.5)), fn:abs(xs:integer(5)), fn:abs(xs:float(5.5)), fn:abs(xs:double(5.5)), + fn:abs(xs:decimal(-5.5)), fn:abs(xs:integer(-5)), fn:abs(xs:float(-5.5)), fn:abs(xs:double(-5.5)) +) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/vxquery/blob/fccce23d/vxquery-xtest/src/test/resources/Queries/XQuery/Numerics/fn_ceiling.xq ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Numerics/fn_ceiling.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Numerics/fn_ceiling.xq new file mode 100644 index 0000000..6a14197 --- /dev/null +++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Numerics/fn_ceiling.xq @@ -0,0 +1,22 @@ +(: Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. :) + +(: XQuery fn:ceiling :) +( + fn:ceiling(xs:decimal(5.5)), fn:ceiling(xs:integer(5)), fn:ceiling(xs:float(5.5)), fn:ceiling(xs:double(5.5)), + fn:ceiling(xs:decimal(-5.5)), fn:ceiling(xs:integer(-5)), fn:ceiling(xs:float(-5.5)), fn:ceiling(xs:double(-5.5)) +) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/vxquery/blob/fccce23d/vxquery-xtest/src/test/resources/cat/FunctionsAndOperatorsOnNumericsQueries.xml ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/test/resources/cat/FunctionsAndOperatorsOnNumericsQueries.xml b/vxquery-xtest/src/test/resources/cat/FunctionsAndOperatorsOnNumericsQueries.xml index e79c514..4b6555d 100644 --- a/vxquery-xtest/src/test/resources/cat/FunctionsAndOperatorsOnNumericsQueries.xml +++ b/vxquery-xtest/src/test/resources/cat/FunctionsAndOperatorsOnNumericsQueries.xml @@ -20,14 +20,14 @@ <title>Function and Operators on Numerics</title> <description/> </GroupInfo> - <test-case name="functions-and-operators-on-numerics-fn:abs" FilePath="Numerics/" Creator="Preston Carman"> + <test-case name="functions-and-operators-on-numerics-fn_abs" FilePath="Numerics/" Creator="Preston Carman"> <description>Query for fn:abs with all numeric types.</description> - <query name="fn:abs" date="2015-01-05"/> - <output-file compare="Text">fn:abs.txt</output-file> + <query name="fn_abs" date="2015-01-05"/> + <output-file compare="Text">fn_abs.txt</output-file> </test-case> - <test-case name="functions-and-operators-on-numerics-fn:ceiling" FilePath="Numerics/" Creator="Preston Carman"> + <test-case name="functions-and-operators-on-numerics-fn_ceiling" FilePath="Numerics/" Creator="Preston Carman"> <description>Query for fn:ceiling with all numeric types.</description> - <query name="fn:ceiling" date="2015-01-05"/> - <output-file compare="Text">fn:ceiling.txt</output-file> + <query name="fn_ceiling" date="2015-01-05"/> + <output-file compare="Text">fn_ceiling.txt</output-file> </test-case> </test-group> \ No newline at end of file
