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

chaokunyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/fury.git


The following commit(s) were added to refs/heads/main by this push:
     new eeb2e78b chore(java): fix xlang test skip in the case where there is 
no Python at all (#2280)
eeb2e78b is described below

commit eeb2e78befb82dff91a63c8395faa3fdb990d30b
Author: Steven Schlansker <[email protected]>
AuthorDate: Mon Jun 2 17:46:56 2025 -0700

    chore(java): fix xlang test skip in the case where there is no Python at 
all (#2280)
    
    existing code works if python is installed but not pyfory, but on Mac
    the default name for Python is `python3` and there is no `python` at all
    by default
---
 .../main/java/org/apache/fory/test/TestUtils.java  | 28 +++++++++++++++-------
 1 file changed, 19 insertions(+), 9 deletions(-)

diff --git 
a/java/fory-test-core/src/main/java/org/apache/fory/test/TestUtils.java 
b/java/fory-test-core/src/main/java/org/apache/fory/test/TestUtils.java
index a5418238..adf855ee 100644
--- a/java/fory-test-core/src/main/java/org/apache/fory/test/TestUtils.java
+++ b/java/fory-test-core/src/main/java/org/apache/fory/test/TestUtils.java
@@ -20,6 +20,7 @@
 package org.apache.fory.test;
 
 import java.io.BufferedReader;
+import java.io.IOException;
 import java.io.InputStreamReader;
 import java.util.Arrays;
 import java.util.Collections;
@@ -74,7 +75,8 @@ public class TestUtils {
         return false;
       }
     } catch (Exception e) {
-      throw new RuntimeException("Error executing command " + String.join(" ", 
command), e);
+      throw new RuntimeException(
+          "Error executing command " + String.join(" ", command) + ": " + 
e.getMessage(), e);
     }
   }
 
@@ -83,14 +85,22 @@ public class TestUtils {
     if (System.getenv("FORY_CI") != null) {
       return;
     }
-    if (executeCommand(
-        Arrays.asList(
-            "python",
-            "-c",
-            "import importlib, sys; sys.exit(0 if 
importlib.util.find_spec(\"pyfory\") is None else 1)"),
-        10,
-        Collections.emptyMap())) {
-      throw new SkipException("pyfory not installed");
+    try {
+      if (executeCommand(
+          Arrays.asList(
+              "python",
+              "-c",
+              "import importlib, sys; sys.exit(0 if 
importlib.util.find_spec(\"pyfory\") is None else 1)"),
+          10,
+          Collections.emptyMap())) {
+        throw new SkipException("pyfory not installed");
+      }
+    } catch (RuntimeException e) {
+      if (e.getCause() instanceof IOException
+          && e.getMessage().contains("No such file or directory")) {
+        throw new SkipException("Python not installed or not found in PATH");
+      }
+      throw e;
     }
   }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to