Paul Eggert wrote:
> Is there some less processey way to address
> the issue? For example, can we exec the Java interpreter with the
> argument -Dline.separator='\n', or call
> System.setProperty("line.separator", "\n") early in the test?
Indeed, a JVM argument
-Dline.separator=$'\n'
(not -Dline.separator='\n') does the job. But since the $'...' is relatively
new in POSIX [1][2], here's a patch that simply used a pre-initialized shell
variable instead. Verified to pass on all relevant platforms [3].
[1]
https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/utilities/V3_chap02.html#tag_19_02_04
[2] https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html
[3] https://github.com/gnu-bison/ci-check/actions/runs/16850399757
>From f8439296bbff1c87e82e63e207b981facd869c85 Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Sat, 9 Aug 2025 12:57:33 +0200
Subject: [PATCH] tests: Fix test failures of Java tests on Cygwin.
Fix suggested by Paul Eggert.
* tests/atlocal.in (lf): New variable.
* tests/local.at (AT_JAVA_PARSER_CHECK): Pass a Windows-agnostic value
of line.separator to the Java runtime.
---
tests/atlocal.in | 4 ++++
tests/local.at | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/tests/atlocal.in b/tests/atlocal.in
index 0d388d0b..76a5f360 100644
--- a/tests/atlocal.in
+++ b/tests/atlocal.in
@@ -104,6 +104,10 @@ fi
# Empty if no Java VM was found
: ${CONF_JAVA='@CONF_JAVA@'}
+# An initialization for Java tests.
+lf='
+'
+
# We need egrep and perl.
: ${EGREP='@EGREP@'}
: ${PERL='@PERL@'}
diff --git a/tests/local.at b/tests/local.at
index ee542f9e..a3601bd6 100644
--- a/tests/local.at
+++ b/tests/local.at
@@ -1599,7 +1599,7 @@ AT_CHECK([sed >&2 -e '/^profiling:.*:Merge mismatch for summaries/d' stderr],
# AT_JAVA_PARSER_CHECK(COMMAND, EXIT-STATUS, EXPOUT, EXPERR, [PRE])
# -----------------------------------------------------------------
m4_define([AT_JAVA_PARSER_CHECK],
-[AT_CHECK([$5[ $SHELL ../../../javaexec.sh ]$1], [$2], [$3], [$4])])
+[AT_CHECK([$5[ $SHELL ../../../javaexec.sh -Dline.separator="$lf" ]$1], [$2], [$3], [$4])])
# AT_PARSER_CHECK(COMMAND, EXIT-STATUS, EXPOUT, EXPERR, [PRE])
--
2.50.1