1
0
mirror of https://github.com/golang/go synced 2024-09-29 14:14:29 -06:00
go/misc/cgo
Russ Cox bd95f889cd cmd/go: cache successful test results
This CL adds caching of successful test results, keyed by the
action ID of the test binary and its command line arguments.

Suppose you run:

	go test -short std
	<edit a typo in a comment in math/big/float.go>
	go test -short std

Before this CL, the second go test would re-run all the tests
for the std packages. Now, the second go test will use the cached
result immediately (without any compile or link steps) for any
packages that do not transitively import math/big, and then
it will, after compiling math/big and seeing that the .a file didn't
change, reuse the cached test results for the remaining packages
without any additional compile or link steps.

Suppose that instead of editing a typo you made a substantive
change to one function, but you left the others (including their
line numbers) unchanged. Then the second go test will re-link
any of the tests that transitively depend on math/big, but it still
will not re-run the tests, because the link will result in the same
test binary as the first run.

The only cacheable test arguments are:

	-cpu
	-list
	-parallel
	-run
	-short
	-v

Using any other test flag disables the cache for that run.
The suggested argument to mean "turn off the cache" is -count=1
(asking "please run this 1 time, not 0").

There's an open question about re-running tests when inputs
like environment variables and input files change. For now we
will assume that users will bypass the test cache when they
need to do so, using -count=1 or "go test" with no arguments.

This CL documents the new cache but also documents the
previously-undocumented distinction between "go test" with
no arguments (now called "local directory mode") and with
arguments (now called "package list mode"). It also cleans up
a minor detail of package list mode buffering that used to change
whether test binary stderr was sent to go command stderr based
on details like exactly how many packages were listed or
how many CPUs the host system had. Clearly the file descriptor
receiving output should not depend on those, so package list mode
now consistently merges all output to stdout, where before it
mostly did that but not always.

Fixes #11193.

Change-Id: I120edef347b9ddd5b10e247bfd5bd768db9c2182
Reviewed-on: https://go-review.googlesource.com/75631
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-11-03 22:07:55 +00:00
..
errors misc/cgo/errors: don't pass -C to compiler 2017-09-14 04:02:01 +00:00
fortran *.bash: always use the same string equality operator 2017-03-14 21:46:31 +00:00
gmp all: make copyright headers consistent with one space after period 2016-05-02 13:43:18 +00:00
life test/run: use go tool compile + link instead of go run when possible 2017-10-31 13:21:05 +00:00
nocgo
stdio test/run: use go tool compile + link instead of go run when possible 2017-10-31 13:21:05 +00:00
test go/printer: forbid empty line before first comment in block 2017-11-02 18:17:22 +00:00
testasan
testcarchive misc/cgo/testcarchive: use -no-pie where needed 2017-10-11 21:01:45 +00:00
testcshared misc/cgo/testcshared: don't overwrite cc in parallel runs 2017-10-09 05:31:01 +00:00
testgodefs cmd/cgo: add -srcdir option 2016-10-30 19:14:08 +00:00
testplugin cmd/go: cache successful test results 2017-11-03 22:07:55 +00:00
testsanitizers misc/cgo/testsanitizers: convert test.bash to Go 2017-08-17 15:05:08 +00:00
testshared cmd/go: switch to entirely content-based staleness determination 2017-10-31 13:19:38 +00:00
testsigfwd misc/cgo/testsigfwd: add missing return statement 2016-08-30 21:44:14 +00:00
testso cmd/dist: convert testso test into Go 2015-06-12 04:33:50 +00:00
testsovar misc/cgo/testsovar: needs the extern keyword to export variables on non-windows platforms 2015-07-21 18:10:57 +00:00
testtls all: make copyright headers consistent with one space after period 2016-05-02 13:43:18 +00:00