Thanks to visit codestin.com
Credit goes to github.com

Skip to content

proposal: cmd/go: add test option to cache linked test binary #77349

@bradfitz

Description

@bradfitz

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 -cachelink -run=^TestFoo$ ./pkg/
$ go test -cachelink -run=^TestBar$ ./pkg/

.... not have to link pkg.test on the second call.

From the docs there:

	-cachelink
	    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    ProposalToolProposalIssues describing a requested change to a Go tool or command-line program.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions