Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 73afdd7

Browse files
authored
chore: agent_test.go: use ptty.Peek() instead of expecting caret in TestAgent_SessionTTYShell (#5821)
1 parent 8afdf24 commit 73afdd7

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

agent/agent_test.go

+4-6
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,16 @@ func TestAgent_GitSSH(t *testing.T) {
133133

134134
func TestAgent_SessionTTYShell(t *testing.T) {
135135
t.Parallel()
136+
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
137+
t.Cleanup(cancel)
136138
if runtime.GOOS == "windows" {
137139
// This might be our implementation, or ConPTY itself.
138140
// It's difficult to find extensive tests for it, so
139141
// it seems like it could be either.
140142
t.Skip("ConPTY appears to be inconsistent on Windows.")
141143
}
142144
session := setupSSHSession(t, codersdk.WorkspaceAgentMetadata{})
143-
command := "bash"
145+
command := "sh"
144146
if runtime.GOOS == "windows" {
145147
command = "cmd.exe"
146148
}
@@ -152,11 +154,7 @@ func TestAgent_SessionTTYShell(t *testing.T) {
152154
session.Stdin = ptty.Input()
153155
err = session.Start(command)
154156
require.NoError(t, err)
155-
caret := "$"
156-
if runtime.GOOS == "windows" {
157-
caret = ">"
158-
}
159-
ptty.ExpectMatch(caret)
157+
_ = ptty.Peek(ctx, 1) // wait for the prompt
160158
ptty.WriteLine("echo test")
161159
ptty.ExpectMatch("test")
162160
ptty.WriteLine("exit")

0 commit comments

Comments
 (0)