Skip to content

fix: use terminal emulator that keeps state in ReconnectingPTY tests #9765

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 5 commits into from
Sep 19, 2023

Conversation

spikecurtis
Copy link
Contributor

@spikecurtis spikecurtis commented Sep 19, 2023

fixes #9764

I think what's happening is that terminal control sequences are relative to the current cursor position, so by creating a new terminal emulator each time we matched, we were getting incorrect terminal state. This PR refactors so that you create one terminal emulator per reader, then match multiple times against the same emulator as you read more data.

Signed-off-by: Spike Curtis <spike@coder.com>
Signed-off-by: Spike Curtis <spike@coder.com>
Signed-off-by: Spike Curtis <spike@coder.com>
Signed-off-by: Spike Curtis <spike@coder.com>
require.ErrorIs(t, testutil.ReadUntil(ctx, t, netConn3, nil), io.EOF)
tr4 := testutil.NewTerminalReader(t, netConn4)
require.NoError(t, tr4.ReadUntil(ctx, matchEchoOutput), "find echo output")
require.ErrorIs(t, tr4.ReadUntil(ctx, nil), io.EOF)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: original was netConn3 but I think that's copypasta

@spikecurtis spikecurtis changed the title Add more pty diagnostics for terminal parsing fix: fix ReconnectingPTY tests to use terminal emulater that keeps state Sep 19, 2023
@spikecurtis spikecurtis marked this pull request as ready for review September 19, 2023 11:58
@spikecurtis spikecurtis changed the title fix: fix ReconnectingPTY tests to use terminal emulater that keeps state fix: use terminal emulator that keeps state in ReconnectingPTY tests Sep 19, 2023
Copy link
Member

@code-asher code-asher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense!

Signed-off-by: Spike Curtis <spike@coder.com>
@spikecurtis spikecurtis enabled auto-merge (squash) September 19, 2023 17:50
@spikecurtis spikecurtis merged commit 70e481e into main Sep 19, 2023
@spikecurtis spikecurtis deleted the spike/9764-reconnecting-pty-screen branch September 19, 2023 17:57
@github-actions github-actions bot locked and limited conversation to collaborators Sep 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

flake: TestWorkspaceProxyWorkspaceApps_Wsconncache/ReconnectingPTY/SignedTokenQueryParameter
2 participants