flyingmutant / rapid

Rapid is a modern Go property-based testing library
https://pkg.go.dev/pgregory.net/rapid
Mozilla Public License 2.0
579 stars 25 forks source link

Concurrent use of rapid.T #27

Closed vfaronov closed 3 years ago

vfaronov commented 3 years ago

I would like to test a program’s concurrent behavior by calling it from multiple goroutines, each imitating some workload. In each goroutine, I would make calls such as rapid.Int().Draw(t, ...), possibly also t.Helper(), t.Errorf(). But it’s not clear if such concurrent calls are safe on rapid.(*T). By contrast, testing.(*T).Helper and Errorf are documented as concurrent-safe.

If rapid.(*T) is safe for concurrent use, this should be documented. If it is not safe, I think it should be made safe.

I see the problems with reproducibility though...

flyingmutant commented 3 years ago

Right now, things like (*T).Helper() or (*T).Fatalf() are safe for concurrent use (they either delegate ot testing.(*T), or use a mutex internally), but drawing from (*T) is not. As rapid relies on reproducibility for shrinking, I am not sure that allowing concurrent draws makes a lot of sense. Documenting this definitely sound like a good idea.