New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/go: test cache not invalidated when modifying testdata subdirectory #53053
Comments
how are you using the file in tests/modifying the file? |
In my original example, I am running an external tool on the testdata directory after having accessed the directory from the Go test. I distilled this into a reproducer:
|
Indeed. In general the Go test process must touch all of the data that should be used as a cache input, since it doesn't have instrumentation for other programs. |
I do not expect Go to pick up changes to files touched by external tools only. What I find surprising and what led me to open this issue is that touching a directory from a Go test results in certain changes to the contents of this directory to cause cache invalidation, but not all such changes. |
I think probably the best we could do here is provide some library function that touches all of files in the |
A change should cause the cache to be invalidated if (and only if) it changes the result of a function called by the Go test process. I agree that that is sometimes surprising when subprocesses are involved. |
That sounds great. It's exactly the workaround I have adopted (save for enabling this by default for |
or maybe only if exec is used? it sounds like a very expensive operation especially if there's a deep hierarchy that's only used by external tools |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
testdata
with test data that contains a subdirectorysubdir
that contains a filefoo
.go test ./...
.foo
.go test ./...
.What did you expect to see?
The test is rerun despite caching being enabled since a data dependency changed.
What did you see instead?
The test is not run again.
Root cause
The cache invalidation logic in
test.go
lists all entries intestdata
ingo/src/cmd/go/internal/test/test.go
Line 1737 in 61fc5df
testdata/subdir
). This function records the results of astat
, including the mtime of the directory. But the mtime of a directory is not updated when any of the files it contains changes.Instead, the logic could do a full recursive walk over the directory and collect the individual mtimes of the contents.
The text was updated successfully, but these errors were encountered: