threads / patch / 64542

patch, 2 partszsh testsuite fixes

Subject: [PATCH 0/2] zsh testsuite fixes

## tl;dr

3 messages between Nov 28, 2025 and Nov 28, 2025. Diffs are folded; open one to read it.

replies: 2people: 1as markdown or json

brian m. carlson· Nov 28, 2025, 01:21 UTC · lore

This series contains two small patches to make our testsuite pass under zsh's sh mode with 5.9. This is the mode that is in use when zsh is invoked as `sh` and differs from zsh's default behavior.

Note that no attempt has been made to make the testsuite work under zsh's default or ksh modes, since it is known that many tests will fail in this case (in part, because outside of sh mode, zsh runs the final process in a pipeline in the main shell instead of a subshell).

The first patch fixes a compatibility issue in which we've accidentally requested behavior from POSIX 1003.1-2024, which is too new to be portably supported. It just so happens that most shells happen to support it anyway, but zsh does not at the moment.

The second patch fixes a more mysterious issue with the testsuite hanging. It's unclear why it does so, but it almost certainly has to do with the internals of the testsuite since creating a simple testcase does not reproduce the problem. However, the patch is simple and easy (simply change to a subshell), so we do so.

With these two patches, the testsuite passes in zsh's sh mode. This should offer users whose `/bin/sh` is AT&T ksh93 (which does not support `local` and therefore does not work as our shell) an additional choice of shells to use for portability.

brian m. carlson (2):
  t0614: use numerical comparison with test_line_count
  t5564: fix test hang under zsh's sh mode
 t/t0614-reftable-fsck.sh | 2 +-
 t/t5564-http-proxy.sh    | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
brian m. carlson· Nov 28, 2025, 01:21 UTC · re: brian m. carlson · lore

[PATCH 1/2] t0614: use numerical comparison with test_line_count

In this comparison, we want to know whether the number of lines is greater than 1. Our test_line_count function passes the first argument as the comparison operator to test, so what we want is a numerical comparison, not a string comparison. While this does not produce a functional problem now, it could very well if we expected two or more items, in which case the value "10" would not match when it should.

Furthermore, the "<" and ">" comparisons are new in POSIX 1003.1-2024 and we don't want to require such a new version of POSIX since many popular and supported operating systems were released before that version of POSIX was released.

Finally, zsh's builtin test operator does not like the greater-than sign in "test", since it is only supported in the double-bracket extension. This has been reported and will be addressed in a future version, but since our code is also technically incorrect, as well as not very compatible, let's fix it by using a numeric comparison.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 t/t0614-reftable-fsck.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Show changes to t/t0614-reftable-fsck.sh +1 −1
diff --git a/t/t0614-reftable-fsck.sh b/t/t0614-reftable-fsck.sh
index 85cc47d67e..677eb9143c 100755
--- a/t/t0614-reftable-fsck.sh
+++ b/t/t0614-reftable-fsck.sh
@@ -20,7 +20,7 @@ test_expect_success "no errors reported on a well formed repository" '
 		done &&
 
 		# The repository should end up with multiple tables.
-		test_line_count ">" 1 .git/reftable/tables.list &&
+		test_line_count -gt 1 .git/reftable/tables.list &&
 
 		git refs verify 2>err &&
 		test_must_be_empty err
brian m. carlson· Nov 28, 2025, 01:21 UTC · re: brian m. carlson · lore

[PATCH 2/2] t5564: fix test hang under zsh's sh mode

This test starts a SOCKS server in Perl in the background and then kills it after the tests are done. However, when using zsh (in sh mode) in the tests, the start_socks function hangs until the background process is killed.

Note that this does not reproduce in a simple shell script, so there is likely some interaction between job handling, our heavy use of eval in the test framework, and possibly other complexities of our test framework. What is clear, however, is that switching from a compound statement to a subshell fixes the problem entirely and the test passes with no problem, so do that.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 t/t5564-http-proxy.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Show changes to t/t5564-http-proxy.sh +2 −2
diff --git a/t/t5564-http-proxy.sh b/t/t5564-http-proxy.sh
index c3903faf2d..3bcbdef409 100755
--- a/t/t5564-http-proxy.sh
+++ b/t/t5564-http-proxy.sh
@@ -40,10 +40,10 @@ test_expect_success 'clone can prompt for proxy password' '
 
 start_socks() {
 	mkfifo socks_output &&
-	{
+	(
 		"$PERL_PATH" "$TEST_DIRECTORY/socks4-proxy.pl" "$1" >socks_output &
 		echo $! > "$TRASH_DIRECTORY/socks.pid"
-	} &&
+	) &&
 	read line <socks_output &&
 	test "$line" = ready
 }

← back to recent threads