You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2018/09/14 06:11:37 UTC

groovy git commit: try a robustness improvement for 2_4_X CI build

Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_4_X d890d571c -> 8a612adc6


try a robustness improvement for 2_4_X CI build


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/8a612adc
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/8a612adc
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/8a612adc

Branch: refs/heads/GROOVY_2_4_X
Commit: 8a612adc6af0319e63497f77ac06d5b912b96d0b
Parents: d890d57
Author: Paul King <pa...@asert.com.au>
Authored: Fri Sep 14 16:11:27 2018 +1000
Committer: Paul King <pa...@asert.com.au>
Committed: Fri Sep 14 16:11:27 2018 +1000

----------------------------------------------------------------------
 .../org/codehaus/groovy/ant/GroovycTest.java    | 42 +++++++++++++-------
 1 file changed, 28 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/8a612adc/subprojects/groovy-ant/src/test/groovy/org/codehaus/groovy/ant/GroovycTest.java
----------------------------------------------------------------------
diff --git a/subprojects/groovy-ant/src/test/groovy/org/codehaus/groovy/ant/GroovycTest.java b/subprojects/groovy-ant/src/test/groovy/org/codehaus/groovy/ant/GroovycTest.java
index 26b9790..e5c2fa8 100644
--- a/subprojects/groovy-ant/src/test/groovy/org/codehaus/groovy/ant/GroovycTest.java
+++ b/subprojects/groovy-ant/src/test/groovy/org/codehaus/groovy/ant/GroovycTest.java
@@ -22,6 +22,7 @@ import groovy.util.GroovyTestCase;
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.ProjectHelper;
+import org.codehaus.groovy.runtime.DefaultGroovyStaticMethods;
 
 import java.io.*;
 import java.util.regex.Pattern;
@@ -87,20 +88,33 @@ public class GroovycTest extends GroovyTestCase {
         final File result = new File(classDirectory + classname + "_Result.txt");
         final char[] buffer = new char[10];
         FileReader fr = null;
-        try {
-            fr = new FileReader(result);
-            fr.read(buffer);
-            assertEquals("OK.", new String(buffer).trim());
-        } catch (final FileNotFoundException fnfe) {
-            fail("File " + result.getName() + " should have been created but wasn't.");
-        } catch (final IOException ioe) {
-            fail("Error reading file " + result.getName() + ".");
-        } finally {
-            if (null != fr) {
-                try {
-                    fr.close();
-                } catch (IOException e) {
-                    fail("Error close file reader " + result.getName() + ".");
+        // try twice for robustness
+        for (int i = 0; i < 2; i++) {
+            try {
+                fr = new FileReader(result);
+                fr.read(buffer);
+                assertEquals("OK.", new String(buffer).trim());
+                break;
+            } catch (final FileNotFoundException fnfe) {
+                String message = "File " + result.getName() + " should have been created but wasn't.";
+                if (i == 0) {
+                    System.err.println(message);
+                    DefaultGroovyStaticMethods.sleep(this, 50L);
+                } else fail(message);
+            } catch (final IOException ioe) {
+                String message = "Error reading file " + result.getName() + ".";
+                fail(message);
+                if (i == 0) System.err.println(message);
+                else fail(message);
+            } finally {
+                if (null != fr) {
+                    try {
+                        fr.close();
+                    } catch (IOException e) {
+                        String message = "Error closing file reader: " + result.getName() + ".";
+                        if (i == 0) System.err.println(message);
+                        else fail(message);
+                    }
                 }
             }
         }