testing,go/doc: no way to properly distribute non-trivial runnable examples #36586
Labels
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
I filed #35852 as a proposal to try to describe this problem and propose a solution, but since it was declined, I'm falling back to simply filing an issue about the problem. The fact that the solution got rejected doesn't mean that the problem doesn't exist.
--
We can have examples which show up in the godoc but aren't runnable, and runnable examples which are run as part of
go test
. This is enough for most use cases.However, take the case where one has more than a handful of examples in a single package, and they each take a non-trivial amount of time to run, such as 200ms. Since they cannot run in parallel with themselves or any other test within the same package,
go test
can take multiple more seconds than it really needs to.The root of the problem is that there's no way to write examples which are:
go test
)Below are some workarounds I considered:
go test ./...
faster, as there's built-in parallelism between packages being tested. However, this splits up godoc pages, and it's not unreasonable to have more than a handful of examples in a single package. Loses point 1.go test
, and it's easier for the user to see what it does and how to run it. Loses point 2.In the proposal above I tried exploring a couple of solutions to allow running examples in parallel. Are there other solutions we can look into?
/cc @bcmills @leitzler @rsc
The text was updated successfully, but these errors were encountered: