From ef26b2c89bd7971b2380e421f32ffc1ca1f6e234 Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Mon, 23 Jan 2023 11:08:44 +0000 Subject: [PATCH] chore: agent_test.go: use ptty.Peek() instead of expecting caret in TestAgent_SessionTTYShell --- agent/agent_test.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/agent/agent_test.go b/agent/agent_test.go index 44b1ff7bf93ae..7c588fbe028fc 100644 --- a/agent/agent_test.go +++ b/agent/agent_test.go @@ -133,6 +133,8 @@ 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 @@ -140,7 +142,7 @@ func TestAgent_SessionTTYShell(t *testing.T) { 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" } @@ -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")