fix a "make check" failure on Cygwin

Bruno Haible via "Bug reports for Bison, the GNU parser generator" <[email protected]> Mon, 14 Jul 2025 11:37:26 +0200
Newsgroups gmane.comp.parsers.bison.bugs
Organization GNU
Message-ID <2101441.0S5aU1g85B@nimes>
This is a multi-part message in MIME format.

--nextPart3408052.AxlXzFCzgd
Content-Transfer-Encoding: 7Bit
Content-Type: text/plain; charset="us-ascii"

Hi,

Building GNU Bison on Cygwin, I see these two test failures:


FAIL: examples/java/calc/Calc
=============================

checking for diff --strip-trailing-cr...
checking for diff --strip-trailing-cr... --strip-trailing-cr
Calc: FAIL: 1 (expected status: 0, effective: 1)
Error: Could not find or load main class Calc
Calc: FAIL: 2 (expected status: 0, effective: 1)
Error: Could not find or load main class Calc
Calc: FAIL: 3 (expected status: 0, effective: 1)
Error: Could not find or load main class Calc
Calc: FAIL: 4 (expected status: 0, effective: 1)
Error: Could not find or load main class Calc
FAIL examples/java/calc/Calc.test (exit status: 1)

FAIL: examples/java/simple/Calc
===============================

checking for diff --strip-trailing-cr...
checking for diff --strip-trailing-cr... --strip-trailing-cr
Calc: FAIL: 1 (expected status: 0, effective: 1)
Error: Could not find or load main class Calc
Calc: FAIL: 2 (expected status: 0, effective: 1)
Error: Could not find or load main class Calc
Calc: FAIL: 3 (expected status: 0, effective: 1)
Error: Could not find or load main class Calc
FAIL examples/java/simple/Calc.test (exit status: 1)


The cause is that the Java implementation is a native Windows one
(since there is no Cygwin build of any Java implementation [1]),
and it does not understand file names of the form /cygwin/c/something.
These file names need to be converted to native Windows syntax right
before invoking 'java'.

The attached patch does it, and thereby fixes these two test failures:
PASS: examples/java/calc/Calc.test
PASS: examples/java/simple/Calc.test

[1] https://cygwin.com/packages/package_list.html


--nextPart3408052.AxlXzFCzgd
Content-Disposition: attachment;
 filename="0001-build-Avoid-failure-of-the-Java-tests-in-Cygwin-base.patch"
Content-Transfer-Encoding: 7Bit
Content-Type: text/x-patch; charset="x-UTF_8J";
 name="0001-build-Avoid-failure-of-the-Java-tests-in-Cygwin-base.patch"

From 9bcc49885db7f5bde632f69918b7e15b58ee9a1d Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Mon, 14 Jul 2025 11:26:31 +0200
Subject: [PATCH] build: Avoid failure of the Java tests in Cygwin-based
 environments.

* examples/test (prog): In Cygwin-based environments, convert the class path
element to native Windows syntax.
---
 examples/test | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/examples/test b/examples/test
index 471e1bf2..f5100649 100755
--- a/examples/test
+++ b/examples/test
@@ -54,6 +54,15 @@ if test -x "$abs_medir/$me"; then
 elif test -f "$abs_medir/$me.class"; then
     prog ()
     {
+        # In Cygwin-based environments, the Java implementation still is a
+        # native Windows Java.  Therefore we need to convert the elements
+        # of the class path from Cygwin syntax to native Windows syntax.
+        # The javaexec.sh script does not do this for us.
+        case `uname -s` in
+            CYGWIN*)
+                abs_medir=`cygpath -w "$abs_medir"`
+                ;;
+        esac
         "$SHELL" "$cwd/javaexec.sh" -cp "$abs_medir" "$me" "$@"
     }
 else
-- 
2.43.0


--nextPart3408052.AxlXzFCzgd--