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

Skip to content

fix: Improve debuggability of ptytest failures #3367

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
Aug 3, 2022

Conversation

mafredri
Copy link
Member

@mafredri mafredri commented Aug 3, 2022

Since we were not failing tests with require the error output was
somewhat hidden in the stream of log messages. This change standardizes
ptytest logging and failing to improve visibility.

Since we were not failing tests with `require` the error output was
somewhat hidden in the stream of log messages. This change standardizes
ptytest logging and failing to improve visibility.
@mafredri mafredri self-assigned this Aug 3, 2022
@mafredri mafredri requested a review from a team August 3, 2022 10:05
Copy link
Member

@johnstcn johnstcn left a comment

Choose a reason for hiding this comment

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

For posterity, here's what it looks like with a failing test:

$ go test . -test.run='^TestLogin$'
--- FAIL: TestLogin (0.00s)
    --- FAIL: TestLogin/InitialUserTTYConfirmPasswordFailAndReprompt (10.03s)
        t.go:81: 2022-08-03 10:11:46.774 [DEBUG]        <github.com/coder/coder/coderd/coderd.go:417>   debugLogRequest.func1.1 GET /api/v2/buildinfo
        t.go:81: 2022-08-03 10:11:46.775 [DEBUG]        <github.com/coder/coder/coderd/coderd.go:417>   debugLogRequest.func1.1 GET /api/v2/users/first
        ptytest.go:80: 2022-08-03 10:11:46.776: cmd: stdout: "> Your Coder deployment hasn't been set up!"
        login_test.go:109: 2022-08-03 10:11:56.771: cmd: match exceeded deadline: wanted "first user?"; got "> Your Coder deployment hasn't been set up!\r\n> What's your  \x1b[;memail\x1b[0m ? "
        login_test.go:96: 
                Error Trace:    /home/coder/src/cdr/coder/cli/login_test.go:96
                                                        /home/coder/src/cdr/coder/cli/asm_amd64.s:1571
                Error:          Received unexpected error:
                                specify email prompt:
                                    github.com/coder/coder/cli.login.func1
                                        /home/coder/src/cdr/coder/cli/login.go:131
                                  - read /dev/pts/9: file already closed
                Test:           TestLogin/InitialUserTTYConfirmPasswordFailAndReprompt
        login_test.go:109: 
                Error Trace:    /home/coder/src/cdr/coder/cli/ptytest.go:176
                                                        /home/coder/src/cdr/coder/cli/ptytest.go:136
                                                        /home/coder/src/cdr/coder/cli/login_test.go:109
                Error:          match exceeded deadline
                Test:           TestLogin/InitialUserTTYConfirmPasswordFailAndReprompt
                Messages:       wanted "first user?"; got "> Your Coder deployment hasn't been set up!\r\n> What's your  \x1b[;memail\x1b[0m ? "
        ptytest.go:80: 2022-08-03 10:11:56.772: cmd: stdout: "> What's your  \x1b[;memail\x1b[0m ? "
    --- FAIL: TestLogin/InitialUserTTY (10.04s)
        t.go:81: 2022-08-03 10:11:46.777 [DEBUG]        <github.com/coder/coder/coderd/coderd.go:417>   debugLogRequest.func1.1 GET /api/v2/buildinfo
        t.go:81: 2022-08-03 10:11:46.778 [DEBUG]        <github.com/coder/coder/coderd/coderd.go:417>   debugLogRequest.func1.1 GET /api/v2/users/first
        ptytest.go:80: 2022-08-03 10:11:46.779: cmd: stdout: "> Your Coder deployment hasn't been set up!"
        login_test.go:53: 2022-08-03 10:11:56.777: cmd: match exceeded deadline: wanted "firrst user?"; got "> Your Coder deployment hasn't been set up!\r\n> What's your  \x1b[;memail\x1b[0m ? "
        login_test.go:53: 
                Error Trace:    /home/coder/src/cdr/coder/cli/ptytest.go:176
                                                        /home/coder/src/cdr/coder/cli/ptytest.go:136
                                                        /home/coder/src/cdr/coder/cli/login_test.go:53
                Error:          match exceeded deadline
                Test:           TestLogin/InitialUserTTY
                Messages:       wanted "firrst user?"; got "> Your Coder deployment hasn't been set up!\r\n> What's your  \x1b[;memail\x1b[0m ? "
        ptytest.go:80: 2022-08-03 10:11:56.777: cmd: stdout: "> What's your  \x1b[;memail\x1b[0m ? "
FAIL
FAIL    github.com/coder/coder/cli      10.459s
FAIL

This is a big improvement over what we had before.

@mafredri mafredri changed the title fix: Improve debuggability of ptytest failures fix: Improve debuggability of ptytest failures Aug 3, 2022
@mafredri mafredri merged commit 1d6283b into main Aug 3, 2022
@mafredri mafredri deleted the mafredri/ptytest-debuggability-improvements branch August 3, 2022 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants