From 85329a24980ae18e048318ee7976f0806ad44bb7 Mon Sep 17 00:00:00 2001 From: Ethan Dickson Date: Wed, 15 Jan 2025 03:06:19 +0000 Subject: [PATCH] fix: improve shell compatibility of netstat check in test --- cli/ssh_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cli/ssh_test.go b/cli/ssh_test.go index 23c7a01898cd1..76d76ac8ade16 100644 --- a/cli/ssh_test.go +++ b/cli/ssh_test.go @@ -1219,8 +1219,10 @@ func TestSSH(t *testing.T) { // started and accepting input on stdin. _ = pty.Peek(ctx, 1) - pty.WriteLine(fmt.Sprintf("netstat -an | grep -q %s; echo \"returned $?\"", remoteSock)) - pty.ExpectMatchContext(ctx, "returned 0") + // This needs to support most shells on Linux or macOS + // We can't include exactly what's expected in the input, as that will always be matched + pty.WriteLine(fmt.Sprintf(`echo "results: $(netstat -an | grep %s | wc -l | tr -d ' ')"`, remoteSock)) + pty.ExpectMatchContext(ctx, "results: 1") // And we're done. pty.WriteLine("exit")