You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by mu...@apache.org on 2023/01/23 17:37:38 UTC

[xalan-test] branch master updated: committing improvements to xalanj tests configuration

This is an automated email from the ASF dual-hosted git repository.

mukulg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/xalan-test.git


The following commit(s) were added to refs/heads/master by this push:
     new 7c2c16b2 committing improvements to xalanj tests configuration
7c2c16b2 is described below

commit 7c2c16b2ec8c5861821eed7e3f2d7e25ff80950f
Author: Mukul Gandhi <ga...@gmail.com>
AuthorDate: Mon Jan 23 23:07:23 2023 +0530

    committing improvements to xalanj tests configuration
---
 build.xml                                          |  93 ++++++++++++++-------
 .../apache/qetest/xsl/XSLApiTestsResultTask.class  | Bin 0 -> 3650 bytes
 .../apache/qetest/xsl/XSLApiTestsResultTask.java   |  82 ++++++++++++++++++
 3 files changed, 144 insertions(+), 31 deletions(-)

diff --git a/build.xml b/build.xml
index e7b93d00..aeb68fbc 100644
--- a/build.xml
+++ b/build.xml
@@ -262,6 +262,16 @@ dependencies - users must manually 'build jar' first.
         </classpath>
     </taskdef>
 
+    <!-- This Ant task checks, the 'api' tests pass or fail status, by inspecting 
+         content within test result XML documents. -->
+    <taskdef name="apiTestsResultTask" classname="org.apache.qetest.xsl.XSLApiTestsResultTask">
+       <classpath>
+           <pathelement location="${test.src.dir}" />
+           <pathelement location="${test.build.dir}" />
+           <pathelement location="${testxsl.jar}" />
+        </classpath>
+    </taskdef>
+
     <!-- ================================================================== -->
     <!-- Base target for running tests with specified properties.  Actual   -->
     <!-- work is handled by dependent tasks, at most one of which should be -->
@@ -398,15 +408,18 @@ dependencies - users must manually 'build jar' first.
     <!-- Run tests: the normal StylesheetTestletDriver on the conf suite    -->
     <!-- ================================================================== -->
     <target name="conf" description="Run TestletDriver over the conf tree"
-        depends="init.test">
+                             depends="init.test">
         <!-- Set the default conformance test driver, user may override -->
         <property name="testClass" value="org.apache.qetest.xsl.StylesheetTestletDriver" />
         <echo message="Executing Xalan conf test: ${testClass}" />
         <property name="testType" value="conf." />
+
         <mkdir dir="results-conf"/>
+
         <antcall target="run.xalantest">
             <param name="xalantest.classpathref" value="conf.class.path" />
         </antcall>
+
         <!--<property name="scan.outputDir" value="${conf.outputDir}"/>-->
         <property name="scan.outputDir" value="results-conf"/>
         <antcall target="scan"/>
@@ -482,11 +495,23 @@ dependencies - users must manually 'build jar' first.
     <!-- Run tests: the normal StylesheetTestletDriver on the accept suite  -->
     <!-- ================================================================== -->
     <target name="accept" description="Run TestletDriver over the accept tree">
-        <echo message="Executing Xalan accept test." />
+        <!--<echo message="Executing Xalan accept test." />-->
+        
+        <property name="testClass" value="org.apache.qetest.xsl.StylesheetTestletDriver" />
+        <echo message="Executing Xalan conf test: ${testClass}" />
+
         <property name="qetest.summaryFile" value="Accept.xml" />
         <property name="testType" value="accept." />
-        <property name="scan.outputDir" value="${accept.outputDir}"/>
-        <antcall target="conf"/>
+
+        <mkdir dir="results-accept"/>
+
+        <!--<antcall target="conf"/>-->
+        <antcall target="run.xalantest">
+           <param name="xalantest.classpathref" value="conf.class.path" />
+        </antcall>
+
+        <property name="scan.outputDir" value="results-accept"/>
+        <antcall target="scan"/>
     </target>
 
     <target name="accept.xsltc" description="Run TestletDriver over the accept tree">
@@ -586,19 +611,21 @@ dependencies - users must manually 'build jar' first.
 
 
     <!-- ================================================================== -->
-    <!-- Run tests: a specific named API test                               -->
+    <!-- Run tests: specific named API tests                               -->
     <!-- ================================================================== -->
-    <target name="api" description="Run a specific API test"
-        depends="init.test">
+    <target name="api" description="Run specific API tests" depends="init.test">
         <!-- Note no default is set; also testClass is not prefixed! -->
         <!--<echo message="Executing Xalan api test: ${testClass}" />-->
         <property name="testClass" value="org.apache.qetest.xsl.XSLTestHarness" />
         <property name="testType" value="api." />
+        
         <mkdir dir="results-api"/>
+        
         <antcall target="run.xalantest">
             <param name="xalantest.classpathref" value="api.class.path" />
         </antcall>
-        <condition property="apitest-passed">
+
+        <condition property="apitest-file-check-passed">
             <and>
                <available file="results-api/Pass-DOMResultAPITest.xml" />
                <available file="results-api/Pass-DOMSourceAPITest.xml" />
@@ -636,12 +663,18 @@ dependencies - users must manually 'build jar' first.
                <available file="results-api/Pass-TransformStateTest.xml" />
                <available file="results-api/Pass-URIResolverTest.xml" />
             </and>
-        </condition>       
+        </condition>
+
         <antcall target="scan">
             <!--<param name="scan.outputDir" value="${api.outputDir}"/>-->
             <param name="scan.outputDir" value="results-api"/>
         </antcall>
-        <antcall target="apitest-pass"/>
+        
+        <antcall target="apitest-pass-file-check"/>
+
+        <apiTestsResultTask resultDir="results-api" fileNamePrefix="Pass-"/>
+
+        <echo message=" [minitest] CONGRATULATIONS! The api tests passed!" />
     </target>
 
     <!-- ================================================================== -->
@@ -687,11 +720,14 @@ dependencies - users must manually 'build jar' first.
         -->
         <property name="testClass" value="org.apache.qetest.xsl.StylesheetTestletDriver" />
         <property name="testType" value="extensions." />
+
+        <mkdir dir="results-extensions"/>
+        
         <antcall target="run.xalan-extension-test">
             <param name="xalantest.classpathref" value="extensions.class.path" />
             <param name="sysprop.BSFManager" value="org.apache.bsf.BSFManager" />
         </antcall>
-        <property name="scan.outputDir" value="${extensions.outputDir}"/>
+        <property name="scan.outputDir" value="results-extensions"/>
         <antcall target="scan"/>
         <echo message="If you got ClassNotFound, did you 'build extensions.classes' first?" />
     </target>
@@ -820,33 +856,26 @@ dependencies - users must manually 'build jar' first.
     </target>    
 
     <target name="smoketest-execute">
+        <echo message="About to execute XalanJ2 extensions tests..." />
+        <antcall target="extensions">
+            <param name="testType" value="smoketest.extensions."/>
+        </antcall>
+
         <echo message="About to execute Conformance tests..." />
         <antcall target="conf">
             <param name="testType" value="smoketest.conf."/>
         </antcall>
 
-        <!--<echo message="About to execute Accept tests..." />
+        <echo message="About to execute Accept tests..." />
         <antcall target="accept">
             <param name="testType" value="smoketest.accept."/>
-        </antcall>-->
-
-        <!--<echo message="About to execute other API tests..." />
-        <antcall target="api">
-            <param name="testClass" value="org.apache.qetest.xsl.XSLTestHarness"/>
-            <param name="testType" value="smoketest.api."/>
-        </antcall>-->
-
-        <!--<echo message="About to execute XalanJ2 extensions tests..." />
-        <antcall target="extensions">
-            <param name="testType" value="smoketest.extensions."/>
-        </antcall>-->
+        </antcall>
 
         <condition property="smoketest-passed">
             <and>
-                <available file="${smoketest.conf.passFile}" />
-                <!--<available file="${smoketest.accept.passFile}" />-->
-                <!--<available file="${smoketest.api.passFile}" />-->
-                <!--<available file="${smoketest.extensions.passFile}" />-->
+               <available file="${smoketest.extensions.passFile}" />
+               <available file="${smoketest.conf.passFile}" />
+               <available file="${smoketest.accept.passFile}" />              
             </and>
         </condition>
         <antcall target="scan">
@@ -886,13 +915,15 @@ dependencies - users must manually 'build jar' first.
     </target>
     <target name="smoketest-pass" if="smoketest-passed">
         <echo message=" [minitest] CONGRATULATIONS! The Smoketest passed!" />
+        <!-- below echo messages, TBD -->
         <!--<echo message=" [minitest] Details are in ${smoketest.conf.logFile}, ${smoketest.api.logFile}, ${smoketest.extensions.logFile}" />
         -->
-        <echo message=" [minitest] Details are in ${smoketest.conf.logFile}" />
+        <!--<echo message=" [minitest] Details are in ${smoketest.conf.logFile}" />-->
     </target>
 
-    <target name="apitest-pass" if="apitest-passed">
-        <echo message=" [minitest] CONGRATULATIONS! The api tests passed!" />
+    <target name="apitest-pass-file-check" unless="apitest-file-check-passed">
+       <echo message=" [minitest] ERROR! The api tests failed!" />
+       <fail message="Please fix any api tests problems before checking in!" />       
     </target>
 
     <target name="smoketest.xsltc-notpass" unless="smoketest.xsltc-passed">
diff --git a/java/src/org/apache/qetest/xsl/XSLApiTestsResultTask.class b/java/src/org/apache/qetest/xsl/XSLApiTestsResultTask.class
new file mode 100644
index 00000000..8688417f
Binary files /dev/null and b/java/src/org/apache/qetest/xsl/XSLApiTestsResultTask.class differ
diff --git a/java/src/org/apache/qetest/xsl/XSLApiTestsResultTask.java b/java/src/org/apache/qetest/xsl/XSLApiTestsResultTask.java
new file mode 100644
index 00000000..680e75af
--- /dev/null
+++ b/java/src/org/apache/qetest/xsl/XSLApiTestsResultTask.java
@@ -0,0 +1,82 @@
+package org.apache.qetest.xsl;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+
+import java.io.File;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathFactory;
+
+import org.w3c.dom.Document;
+
+/*
+   This ant task checks, whether ant target "api"'s result 
+   is pass or fail, by inspecting content within test results 
+   XML documents.
+
+   @author <a href="mailto:mukulg@apache.org">Mukul Gandhi</a>
+*/
+public class XSLApiTestsResultTask extends Task {
+    
+    private String resultDir;
+
+    private String fileNamePrefix;    
+
+    private static final String PASS = "Pass";
+
+    // method to run this, ant build task
+    public void execute() throws BuildException {
+        File dirObj = new File(this.resultDir);
+        File[] fileList = dirObj.listFiles();
+        for (int idx = 0; idx < fileList.length; idx++) {
+           String fileName = fileList[idx].getName();
+           if (fileName.startsWith(this.fileNamePrefix)) {
+               String testResultFilePassStatus  = getTestResultFilePassStatus(
+                                          fileList[idx].getAbsolutePath());
+               if (!PASS.equals(testResultFilePassStatus)) {
+                  String[] dirNameParts = (this.resultDir).split("/"); 
+                  String errorContextFileName = dirNameParts[dirNameParts.length - 1] + "/" + fileName;
+                  throw new BuildException("One or more tests in an 'api' target failed. Test failure was found, while inspecting the file " + errorContextFileName + ". Please fix any api tests problems before checking in!", location);
+               }
+           } 
+        }
+    }
+
+    public void setResultDir(String dirPath) {
+        this.resultDir = dirPath;
+    }
+
+    public void setFileNamePrefix(String fileNamePrefix) {
+        this.fileNamePrefix = fileNamePrefix;
+    }
+
+    /*
+       Read the test pass status value, within test result's XML document.
+    */
+    private String getTestResultFilePassStatus(String testResultFilePath) {
+       String resultStr = "";
+       
+       try {	   
+            DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
+            DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
+            Document xmlDocument = docBuilder.parse(testResultFilePath);
+            XPath xPath = XPathFactory.newInstance().newXPath();
+            String xpathExprStr = "/teststatus";
+            String xpathNodeValue = (String)((xPath.compile(xpathExprStr)).
+                                                    evaluate(xmlDocument, 
+                                                            XPathConstants.STRING));
+            resultStr = xpathNodeValue.trim();
+       }
+       catch (Exception ex) {
+          String[] filePathParts = testResultFilePath.split("/");
+          throw new BuildException("Exception occured, processing api test result XML document " + filePathParts[filePathParts.length - 1], location);
+       }
+
+       return resultStr;
+	}
+
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xalan.apache.org
For additional commands, e-mail: commits-help@xalan.apache.org