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

Skip to content

chore: agent_test.go: use ptty.Peek() instead of expecting caret in TestAgent_SessionTTYShell #5821

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions agent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,16 @@ func TestAgent_GitSSH(t *testing.T) {

func TestAgent_SessionTTYShell(t *testing.T) {
t.Parallel()
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
t.Cleanup(cancel)
if runtime.GOOS == "windows" {
// This might be our implementation, or ConPTY itself.
// It's difficult to find extensive tests for it, so
// it seems like it could be either.
t.Skip("ConPTY appears to be inconsistent on Windows.")
}
session := setupSSHSession(t, codersdk.WorkspaceAgentMetadata{})
command := "bash"
command := "sh"
if runtime.GOOS == "windows" {
command = "cmd.exe"
}
Expand All @@ -152,11 +154,7 @@ func TestAgent_SessionTTYShell(t *testing.T) {
session.Stdin = ptty.Input()
err = session.Start(command)
require.NoError(t, err)
caret := "$"
if runtime.GOOS == "windows" {
caret = ">"
}
ptty.ExpectMatch(caret)
_ = ptty.Peek(ctx, 1) // wait for the prompt
ptty.WriteLine("echo test")
ptty.ExpectMatch("test")
ptty.WriteLine("exit")
Expand Down