Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2413106

Browse files
fix: improve shell compatibility of netstat check in test (#16141)
When I wrote the original just the other day, I used `$?`, which is fineon CI and in most cases, but not when the person running the test hastheir system shell set to fish (Fish uses $status) instead. In theinterest of letting this test pass locally, I'll instead just grab theline count of the grep output. However, `wc` is padded on macos withspaces, so we need to get rid of those too.
1 parent5380690 commit2413106

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

‎cli/ssh_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,8 +1219,10 @@ func TestSSH(t *testing.T) {
12191219
// started and accepting input on stdin.
12201220
_=pty.Peek(ctx,1)
12211221

1222-
pty.WriteLine(fmt.Sprintf("netstat -an | grep -q %s; echo\"returned $?\"",remoteSock))
1223-
pty.ExpectMatchContext(ctx,"returned 0")
1222+
// This needs to support most shells on Linux or macOS
1223+
// We can't include exactly what's expected in the input, as that will always be matched
1224+
pty.WriteLine(fmt.Sprintf(`echo "results: $(netstat -an | grep %s | wc -l | tr -d ' ')"`,remoteSock))
1225+
pty.ExpectMatchContext(ctx,"results: 1")
12241226

12251227
// And we're done.
12261228
pty.WriteLine("exit")

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp