Skip to content

fix: Improve ptytest closure on expect match timeout #5337

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 3 commits into from
Dec 7, 2022

Conversation

mafredri
Copy link
Member

@mafredri mafredri commented Dec 7, 2022

To ensure ptytest closure always happens the same way, we now define a
new Close function on PTY and always call the close function instead
of manually closing read/writers.

A few additional log messages have been added as well, to better
understand the shutdown process in case of errors.

To ensure ptytest closure always happens the same way, we now define a
new `Close` function on `PTY` and always call the close function instead
of manually closing read/writers.

A few additional log messages have been added as well, to better
understand the shutdown process in case of errors.
@mafredri mafredri self-assigned this Dec 7, 2022
@mafredri mafredri requested a review from mtojek December 7, 2022 14:31
Copy link
Member

@mtojek mtojek left a comment

Choose a reason for hiding this comment

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

LGTM!

tpty.logf("closed %s: %v", name, err)
}
// Set the actual close function for the tpty.
tpty.close = func(reason string) error {
Copy link
Member

Choose a reason for hiding this comment

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

👍

}
// Set the actual close function for the tpty.
tpty.close = func(reason string) error {
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitMedium)
Copy link
Member

Choose a reason for hiding this comment

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

nit: in theory, this can be also WaitShort.

Copy link
Member Author

Choose a reason for hiding this comment

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

I was paranoid since we're waiting on two goroutines to close, but we can always bump it if it becomes a problem. I'll go with short.

Comment on lines +218 to +220
p.logf("%s: %s", reason, fmt.Sprintf(format, args...))

require.FailNowf(t, reason, format, args...)
require.FailNowf(p.t, reason, format, args...)
Copy link
Member

Choose a reason for hiding this comment

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

I'm curious, is there a reason why these 2 lists are not merged into one call, require.FailNowf?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because require output differs from the common ptytest logs, this may duplicate the information but it gives an easier trail to follow.

@mafredri mafredri enabled auto-merge (squash) December 7, 2022 15:16
@mafredri mafredri merged commit f7467ca into main Dec 7, 2022
@mafredri mafredri deleted the mafredri/improve-ptytest-timeout-close branch December 7, 2022 15:20
@github-actions github-actions bot locked and limited conversation to collaborators Dec 7, 2022
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