Proposal Details
I propose that cmd/go have a new go test flag to control whether the linked test binary is written to the GOCACHE build cache.
Tiny example change: https://go-review.googlesource.com/c/go/+/739161
That change lets this,
$ go test -cachebinary -run=^TestFoo$ ./pkg/
$ go test -cachebinary -run=^TestBar$ ./pkg/
.... not have to link pkg.test on the second call.
From the docs there:
-cachebinary
Cache the emphemeral test binary (the linker output) in the build
cache. This avoids re-linking the test binary if running the same
test binary repeatedly but with different flags, environment,
or other test inputs such that the test caching rules above
would not apply. On such case is Go test wrappers that shard tests
within a package across multiple machines, sharing a common build
cache with GOCACHEPROG.
I'm not wed to those exact docs, but that explains the background.
(I thought I remembered seeing this proposal once, but I can't find it, so maybe I'm remembering a conversation instead?)
/cc @golang/tools-team
Edit: renamed from -cachelink to -cachebinary
Proposal Details
I propose that
cmd/gohave a newgo testflag to control whether the linked test binary is written to the GOCACHE build cache.Tiny example change: https://go-review.googlesource.com/c/go/+/739161
That change lets this,
.... not have to link
pkg.teston the second call.From the docs there:
I'm not wed to those exact docs, but that explains the background.
(I thought I remembered seeing this proposal once, but I can't find it, so maybe I'm remembering a conversation instead?)
/cc @golang/tools-team
Edit: renamed from
-cachelinkto-cachebinary