Proposal Details
In our experimentation with testing/synctest (which is really helpful!), we have found that a surprisingly common mistake is to call time.Sleep in the test function but forget to call synctest.Wait afterwards, which causes the test to be racy. These tests are similar in nature to this example.
To that end, I would like to propose a helper function (I don't care much about the exact name) that internally makes these two calls.
package synctest
func Sleep(d time.Duration) {
time.Sleep(d)
Wait()
}
Obviously this function isn't strictly needed, and we could of course make that wrapper ourselves. The hope is that by having it within synctest and replacing two calls with one, the likelihood of the aforementioned mistake will reduce significantly.
Proposal Details
In our experimentation with testing/synctest (which is really helpful!), we have found that a surprisingly common mistake is to call
time.Sleepin the test function but forget to callsynctest.Waitafterwards, which causes the test to be racy. These tests are similar in nature to this example.To that end, I would like to propose a helper function (I don't care much about the exact name) that internally makes these two calls.
Obviously this function isn't strictly needed, and we could of course make that wrapper ourselves. The hope is that by having it within synctest and replacing two calls with one, the likelihood of the aforementioned mistake will reduce significantly.