harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r577392 - in /harmony/enhanced/buildtest/branches/2.0/tests/eut: build.xml summary-reporter/src/org/apache/harmony/eut/reporter/EUTReporter.java
Date Wed, 19 Sep 2007 17:28:28 GMT
Author: smishura
Date: Wed Sep 19 10:28:27 2007
New Revision: 577392

URL: http://svn.apache.org/viewvc?rev=577392&view=rev
Log:
Apply patch from HARMONY-4821:
([buildtest][eut] broken status checked due to new EUT summary reporter)

Modified:
    harmony/enhanced/buildtest/branches/2.0/tests/eut/build.xml
    harmony/enhanced/buildtest/branches/2.0/tests/eut/summary-reporter/src/org/apache/harmony/eut/reporter/EUTReporter.java

Modified: harmony/enhanced/buildtest/branches/2.0/tests/eut/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/buildtest/branches/2.0/tests/eut/build.xml?rev=577392&r1=577391&r2=577392&view=diff
==============================================================================
--- harmony/enhanced/buildtest/branches/2.0/tests/eut/build.xml (original)
+++ harmony/enhanced/buildtest/branches/2.0/tests/eut/build.xml Wed Sep 19 10:28:27 2007
@@ -329,7 +329,8 @@
             collect.output.to.summarize,
             setup.efl,
             generate.reports,
-            duplicate.results.in.latest"
+            duplicate.results.in.latest,
+            exit.based.on.eut.status"
         description="Processes JUnit reports and creates a summary">
     </target>
 
@@ -373,6 +374,8 @@
             classpath="${work.dir}/summary-reporter/classes"
             classname="org.apache.harmony.eut.reporter.EUTReporter"
             fork="true"
+            failonerror="false"
+            resultproperty="reporter.exit.code"
             output="${work.dir}/r_output.txt"> 
             <arg value="${eclipse.buildid}"/>
             <arg value="${results.dir}"/>
@@ -403,6 +406,36 @@
                 <include name="index.htm"/>
             </fileset>
         </copy>
+    </target>
+
+    <!-- produce ant runner exit code based on EUT results -->
+    <target name="exit.based.on.eut.status" depends="generate.reports">
+        <fail message="EUT failed: There are unexpected failures">
+            <condition>
+                <equals arg1="${reporter.exit.code}" arg2="1"/>
+           </condition>
+        </fail>
+        
+        <fail message="EUT failed: Fatal Error: some reports are unavailable">
+            <condition>
+                <equals arg1="${reporter.exit.code}" arg2="2"/>
+           </condition>
+        </fail>
+
+        <fail message="EUT failed: Fatal Error: reporter internal error">
+            <condition>
+                <equals arg1="${reporter.exit.code}" arg2="3"/>
+           </condition>
+        </fail>
+
+        <fail message="EUT failed: Fatal Error: magic error (never happens)">
+            <condition>
+                <not>
+                    <equals arg1="${reporter.exit.code}" arg2="0"/>
+                </not>
+           </condition>
+        </fail>
+        <echo message="EUT passed!"/>
     </target>
 
     <target name="compose.report.get.java.version">

Modified: harmony/enhanced/buildtest/branches/2.0/tests/eut/summary-reporter/src/org/apache/harmony/eut/reporter/EUTReporter.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/buildtest/branches/2.0/tests/eut/summary-reporter/src/org/apache/harmony/eut/reporter/EUTReporter.java?rev=577392&r1=577391&r2=577392&view=diff
==============================================================================
--- harmony/enhanced/buildtest/branches/2.0/tests/eut/summary-reporter/src/org/apache/harmony/eut/reporter/EUTReporter.java
(original)
+++ harmony/enhanced/buildtest/branches/2.0/tests/eut/summary-reporter/src/org/apache/harmony/eut/reporter/EUTReporter.java
Wed Sep 19 10:28:27 2007
@@ -27,6 +27,12 @@
  */
 public final class EUTReporter {
 
+    /* EUTReporter return codes. */
+    private static final int RETURN_EUT_PASSED = 0;
+    private static final int RETURN_EUT_FAILED = 1;
+    private static final int RETURN_USAGE_ERROR = 2;
+    private static final int RETURN_INTERNAL_ERROR = 3;
+
     /** Keeps the list of test suites being processed. */
     static ArrayList<EUTSuiteInfo> suiteList = new ArrayList<EUTSuiteInfo>();
 
@@ -54,7 +60,9 @@
         System.err.println("    *  <eut_version>.suites.properties file");
         System.err.println("    *  tested.java.version file");
         System.err.println("    *  running.java.version file");
-        System.exit(1);
+        System.err.println("EUT SCRIPT: "
+                + "incorrect using of reporter or missed resources...");
+        System.exit(RETURN_USAGE_ERROR);
     }
 
     private static void checkFileExistance(File f) {
@@ -86,7 +94,25 @@
         return String.valueOf(aliquot) + "." + fractionStr + "%";
     }
 
-    public static void main(String[] args) throws Exception {
+    /*
+     * The contruct for return code is:
+     * 0 - sucessfully generated report and EUT is PASSED
+     * 1 - sucessfully generated report and EUT is FAILED
+     * 2 - wrong usage (or input data is missed)
+     * 3 - unexpected parsing error (uncought throwable)
+     */
+    public static void main(String[] args) {
+        try {
+            main_unsafe(args);
+        } catch (Throwable e) {
+            System.err.println("EUT SCRIPT: "
+                    + "Unexpected Error during EUT results parsing:" + e);
+            e.printStackTrace();
+            System.exit(RETURN_INTERNAL_ERROR);
+        }
+    }
+
+    private static void main_unsafe(String[] args) throws Exception {
 
         // check the run arguments
         if (args.length != 6) {
@@ -196,6 +222,17 @@
                 "report.txt");
         EUTTXTReportEmitter.emitTXTReport(out, esi);
         out.close();
-        System.out.println("EUT summary report was successfully generated");
+        System.out.println("EUT SCRIPT: "
+                + "EUT summary report was successfully generated");
+
+        if (esi.tests_run_total == esi.ss.tests_reported_passed) {
+            System.out.println("EUT SCRIPT: "
+                    + "No unexpected EUT issues detected");
+            System.exit(RETURN_EUT_PASSED);
+        } else {
+            System.err.println("EUT SCRIPT: "
+                    + "Unexpected EUT issues are detected");
+            System.exit(RETURN_EUT_FAILED);
+        }
     }
 } // end of class 'EUTReporter' definition



Mime
View raw message