Open zdevwu opened 2 months ago
Hey @zdevwu, are you expecting the mock generated methods to be concurrency safe? If so, they're not expected to be.
With respect to the two cases you gave above, the first case does not race as he first goroutine only gets unblocked after the mock expectation is declared which serializes the the Sum expectation setting and the mock call to Sum.
Thanks for getting back @r-hang, can you elaborate a bit on the second case please? Although not explicitly sending the signal by closing the releaseChannel
to continue to launch the go routine, the timer in second case makes sure the mock happens before the nested go routine that is calling Sum start running, both cases the mock happens before the call, but race is only detected in the second case with timer released go routine.
There is a strange behaviour for the
Call
when triggered in go routines, adata race
will be detected from timer triggered go routine but not in channel triggered go routine, see the bellow test cases:The fork to demo the issue here:
Triage Notes for the Maintainers