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 2021/02/25 01:51:21 UTC

[groovy] branch master updated: GROOVY-9922: make test more robust on CI environments

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

paulk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/master by this push:
     new 482d0cc  GROOVY-9922: make test more robust on CI environments
482d0cc is described below

commit 482d0cc0711e9e3f6bbcf9612b117fed94841dba
Author: Paul King <pa...@asert.com.au>
AuthorDate: Thu Feb 25 11:50:58 2021 +1000

    GROOVY-9922: make test more robust on CI environments
---
 src/test/groovy/bugs/Groovy9922.groovy | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/test/groovy/bugs/Groovy9922.groovy b/src/test/groovy/bugs/Groovy9922.groovy
index 4ead1ae..4a5b6f1 100644
--- a/src/test/groovy/bugs/Groovy9922.groovy
+++ b/src/test/groovy/bugs/Groovy9922.groovy
@@ -22,7 +22,19 @@ import org.junit.Test
 
 final class Groovy9922 {
     @Test
-    void testGetPid() {
-        assert "jps".execute().text.contains("${Runtime.getRuntime().getPid()} ")
+    void getPidConfirmedByJpsOutputOnEnvironmentsWithThatExecutable() {
+        def result = executeJpsSafe()
+        if (result) {
+            assert result.contains("${Runtime.getRuntime().getPid()} ")
+        }
+    }
+
+    private static String executeJpsSafe() {
+        try {
+            "jps".execute().text
+        } catch(IOException ex) {
+            // some environments, e.g. CI server may not have JPS
+            null
+        }
     }
 }