Skip to content

test(pty/ptytest): fix error message on deadline exceeded #8337

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
Jul 6, 2023

Conversation

mafredri
Copy link
Member

@mafredri mafredri commented Jul 6, 2023

Previously the error message from expecter was not useful since we were immediately closing it on timeout instead of letting the calling code explain what went wrong.

        ptytest.go:95: 2023-07-06 11:46:49.834: cmd: closing expecter: match deadline exceeded
        ptytest.go:100: 2023-07-06 11:46:54.834: cmd: close: copy did not close in time
        ptytest.go:100:
                Error Trace:    /home/mafredri/src/coder/coder/pty/ptytest/ptytest.go:346
                                                        /home/mafredri/src/coder/coder/pty/ptytest/ptytest.go:100
                                                        /home/mafredri/src/coder/coder/pty/ptytest/ptytest.go:324
                                                        /home/mafredri/src/coder/coder/pty/ptytest/ptytest.go:161
                                                        /home/mafredri/src/coder/coder/cli/templatepush_test.go:110
                Error:          close
                Test:           TestTemplatePush/Message_too_long,_warn_but_continue
                Messages:       copy did not close in time

vs now:

        templatepush_test.go:107: 2023-07-06 11:51:10.889: cmd: read error: match deadline exceeded: context deadline exceeded (wanted "Message too long"; got "> Upload \"/tmp/TestTemplatePushMessage_too_long,_warn_but_continue1906856437/003\"? (yes/no) ")
        templatepush_test.go:107:
                Error Trace:    /home/mafredri/src/coder/coder/pty/ptytest/ptytest.go:346
                                                        /home/mafredri/src/coder/coder/pty/ptytest/ptytest.go:177
                                                        /home/mafredri/src/coder/coder/cli/templatepush_test.go:107
                Error:          read error
                Test:           TestTemplatePush/Message_too_long,_warn_but_continue
                Messages:       match deadline exceeded: context deadline exceeded (wanted "Message too long"; got "> Upload \"/tmp/TestTemplatePushMessage_too_long,_warn_but_continue1906856437/003\"? (yes/no) ")

@mafredri mafredri self-assigned this Jul 6, 2023
@mafredri mafredri requested review from johnstcn and mtojek July 6, 2023 12:29
@@ -297,7 +297,7 @@ func (e *outExpecter) ReadLine(ctx context.Context) string {
return buffer.String()
}

func (e *outExpecter) doMatchWithDeadline(ctx context.Context, name string, fn func() error) error {
func (e *outExpecter) doMatchWithDeadline(ctx context.Context, name string, fn func(*bufio.Reader) error) error {
Copy link
Member Author

Choose a reason for hiding this comment

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

Review: This is a bonus change to make it more obvious what reader should be used in these functions.

@mafredri mafredri merged commit 4a13c58 into main Jul 6, 2023
@mafredri mafredri deleted the mafredri/fix-ptytest-error-message branch July 6, 2023 13:18
@github-actions github-actions bot locked and limited conversation to collaborators Jul 6, 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.

2 participants