-
Notifications
You must be signed in to change notification settings - Fork 887
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
Conversation
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.
There was a problem hiding this 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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
pty/ptytest/ptytest.go
Outdated
} | ||
// Set the actual close function for the tpty. | ||
tpty.close = func(reason string) error { | ||
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitMedium) |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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.
p.logf("%s: %s", reason, fmt.Sprintf(format, args...)) | ||
|
||
require.FailNowf(t, reason, format, args...) | ||
require.FailNowf(p.t, reason, format, args...) |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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.
To ensure ptytest closure always happens the same way, we now define a
new
Close
function onPTY
and always call the close function insteadof manually closing read/writers.
A few additional log messages have been added as well, to better
understand the shutdown process in case of errors.