diff options
author | Russ Cox <rsc@golang.org> | 2017-12-04 13:57:48 -0500 |
---|---|---|
committer | Dominik Honnef <dominik@honnef.co> | 2017-12-11 19:08:32 +0000 |
commit | 29be20a111d87b41b91e79a59fd3df95062ce91a (patch) | |
tree | 7ae1ee760e54cd98e51751682338319f3d048626 /src/os/exec/exec_test.go | |
parent | 8c227765f70b5677901692a71d8662f395186a83 (diff) | |
download | go-29be20a111d87b41b91e79a59fd3df95062ce91a.tar.gz go-29be20a111d87b41b91e79a59fd3df95062ce91a.zip |
cmd/go: invalidate cached test results if env vars or files change
When we write a cached test result, we now also write a log of the
environment variables and files inspected by the test run,
along with a hash of their content. Before reusing a cached test result,
we recompute the hash of the content specified by the log, and only
use the result if that content has not changed.
This makes test caching behave correctly for tests that consult
environment variables or stat or read files or directories.
Fixes #22593.
Change-Id: I8608798e73c90e0c1911a38bf7e03e1232d784dc
Reviewed-on: https://go-review.googlesource.com/81895
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/os/exec/exec_test.go')
-rw-r--r-- | src/os/exec/exec_test.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/os/exec/exec_test.go b/src/os/exec/exec_test.go index 0132906933..ed2a55557d 100644 --- a/src/os/exec/exec_test.go +++ b/src/os/exec/exec_test.go @@ -401,9 +401,15 @@ var testedAlreadyLeaked = false // basefds returns the number of expected file descriptors // to be present in a process at start. -// stdin, stdout, stderr, epoll/kqueue +// stdin, stdout, stderr, epoll/kqueue, maybe testlog func basefds() uintptr { - return os.Stderr.Fd() + 1 + n := os.Stderr.Fd() + 1 + for _, arg := range os.Args { + if strings.HasPrefix(arg, "-test.testlogfile=") { + n++ + } + } + return n } func closeUnexpectedFds(t *testing.T, m string) { |