mirror of
https://github.com/coder/coder.git
synced 2025-07-13 21:36:50 +00:00
fix: use terminal emulator that keeps state in ReconnectingPTY tests (#9765)
* Add more pty diagnostics for terminal parsing Signed-off-by: Spike Curtis <spike@coder.com> * print escaped strings Signed-off-by: Spike Curtis <spike@coder.com> * Only log on failure - heisenbug? Signed-off-by: Spike Curtis <spike@coder.com> * use the terminal across matches to keep cursor & contents state Signed-off-by: Spike Curtis <spike@coder.com> * Only log bytes if we're not expecting EOF Signed-off-by: Spike Curtis <spike@coder.com> --------- Signed-off-by: Spike Curtis <spike@coder.com>
This commit is contained in:
@ -1428,8 +1428,9 @@ func testReconnectingPTY(ctx context.Context, t *testing.T, client *codersdk.Cli
|
||||
_, err = conn.Write(data)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.NoError(t, testutil.ReadUntil(ctx, t, conn, matchEchoCommand), "find echo command")
|
||||
require.NoError(t, testutil.ReadUntil(ctx, t, conn, matchEchoOutput), "find echo output")
|
||||
tr := testutil.NewTerminalReader(t, conn)
|
||||
require.NoError(t, tr.ReadUntil(ctx, matchEchoCommand), "find echo command")
|
||||
require.NoError(t, tr.ReadUntil(ctx, matchEchoOutput), "find echo output")
|
||||
|
||||
// Exit should cause the connection to close.
|
||||
data, err = json.Marshal(codersdk.ReconnectingPTYRequest{
|
||||
@ -1440,9 +1441,9 @@ func testReconnectingPTY(ctx context.Context, t *testing.T, client *codersdk.Cli
|
||||
require.NoError(t, err)
|
||||
|
||||
// Once for the input and again for the output.
|
||||
require.NoError(t, testutil.ReadUntil(ctx, t, conn, matchExitCommand), "find exit command")
|
||||
require.NoError(t, testutil.ReadUntil(ctx, t, conn, matchExitOutput), "find exit output")
|
||||
require.NoError(t, tr.ReadUntil(ctx, matchExitCommand), "find exit command")
|
||||
require.NoError(t, tr.ReadUntil(ctx, matchExitOutput), "find exit output")
|
||||
|
||||
// Ensure the connection closes.
|
||||
require.ErrorIs(t, testutil.ReadUntil(ctx, t, conn, nil), io.EOF)
|
||||
require.ErrorIs(t, tr.ReadUntil(ctx, nil), io.EOF)
|
||||
}
|
||||
|
Reference in New Issue
Block a user