-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
mock: update callString to format context.Context as pointer #1689
base: master
Are you sure you want to change the base?
Conversation
Similar to but not the same as #1597. I'm not a fan of listing types that are more prone to containing values used on different goroutines, feels like whack-a-mole. A compilable example would be helpful here. I'm wondering things like; was the Context actually being matched or did it use mock.Anything/mock.AnythingOfType("context.Context")? |
I would also prefer a solution that isn't specific to
Typically Here is a more complete race:
|
The relevance is in considering that we might not need to format an argument matched against mock.Anything. A potential generic way of reducing the race conditions. |
Summary
This PR proposes updating
func callString
inpackage mock
to formatcontext.Context
arguments as their pointer value, in order to avoid a data race from formatting the internals as a string.Changes
func callString
to formatcontext.Context
args as their pointer valueTest_callString/context
to validateMotivation
This is an example race detected from the new test
Test_callString/context
, before including the fix:Data Race