ksh: pty test random failure

Just putting this out there. I know it’s a race condition, you can run the test over and over and it’ll fail fail fail, then it’ll pass, then it’ll fail again. This isn’t new, it’s just got enough inertia that I opened an issue for it.

ksh@504d645f on m1Pro macOS 12.6.6

...
test pty begins at 2023-06-04+18:41:50
test pty passed at 2023-06-04+18:42:28 [ 58 tests 0 errors ]
test pty(C.UTF-8) begins at 2023-06-04+18:42:28
	pty.sh[991]: FAIL: tab completion with space in string and -o noglob on: line 1001: expected "^:test-2: echo /private/var/folders/_h/w1zkv1tx5vq028wcyv5yhnnr0000gn/T/ksh93.shtests.85374.15052/pty.C.UTF-8/foo\\ bar \r\n$", got ":test-2: 000gn/T/ksh93.shtests.85374.15052/pty.C.UTF-8/foo\\ bar \r\n"
test pty(C.UTF-8) failed at 2023-06-04+18:43:06 with exit code 1 [ 58 tests 1 error ]
...

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 18

Commits related to this issue

Most upvoted comments

I think I found the real cause of the problem.

My Terminal.app window is 132 columns wide. My iTerm window, the default 80.

When I narrow my Terminal.app window to 80 columns, the test fails equally.

In spite of pty being a pseudoterminal, ksh gets the window size from the real terminal. I don’t know how to fix that.

By default, the pty tests are run with TERM=dumb, on which multiline editing is not possible. On macOS, the $TMPDIR directory path is long, causing a temporary file path that won’t fit on a single line. This explains the regression test failure with the cut-off path.

The fix: run the test with multiline enabled. Please try this:

diff --git a/src/cmd/ksh93/tests/pty.sh b/src/cmd/ksh93/tests/pty.sh
index 0484944ca..786197ac3 100755
--- a/src/cmd/ksh93/tests/pty.sh
+++ b/src/cmd/ksh93/tests/pty.sh
@@ -996,7 +996,7 @@ w exit
 !

 touch "$tmp/foo bar"
-((SHOPT_VSH || SHOPT_ESH)) && tst $LINENO <<!
+((multiline && (SHOPT_VSH || SHOPT_ESH))) && TERM=vt100 tst $LINENO <<!
 L tab completion with space in string and -o noglob on
 # https://github.com/ksh93/ksh/pull/413
 # Amended to test that completion keeps working after -o noglob