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: unexpected test cache hit of "PASS" when test should "FAIL" #30313
Comments
I tried to reproduce this, but I actually didn't see As far as I understand, I'll take a closer look tomorrow. There may not be an easy solution though. |
Thanks @jayconrod The following
This fails with:
|
I think I understand this now. The difference between So as far as the cache is concerned, after the source file change, the test binary is identical. A hash of the test binary is used to derive a cache key, which is used to look up a list of files the test accessed previously. None of the known input files have changed, so the cache test result is used. Of course, the code in the "dead" function actually matters for this test, since it runs I'm going to close this issue because the cache is working as designed here. I'm not sure the details of this are documented anywhere. #22593 seems to be where this was originally discussed. #23799 would probably be the right fix for this: this test would need to identify itself as uncacheable if there were a way to do so. |
@jayconrod - that makes total sense, thanks. Apologies, in this situation it's definitely a case of my error, so thank you for taking the time to look into this. The usual pattern I follow for testing programs has a reference from
(taken from In this case, because the program I'm testing is a The problem I'm seeing is easily solved by keeping such a reference form |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Testing with the 1.12rc1 ahead of the release
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
The first run of
go test .
does not result in a cache hit, as expected:The second run does; not clear whether this is expected or not given the code in question:
Now let's remove the flag
-silent
which should cause thetestscript
test intestdata/missing.txt
to fail:Re-run the tests:
This cache hit is definitely unexpected and not only that it's wrong:
Re-running
go test .
we still get an incorrect cache hit:But if we:
then:
What did you expect to see?
For
go test .
not to report a "cached" result of success when in factgo test
results in a failure.Also to note, if the above steps are repeated outside of
GOPATH
then the test results are never cached:gives:
What did you see instead?
When within GOPATH,
go test .
incorrectly reports a cached result of "success" whengo test
results in a fail.cc @bcmills
The text was updated successfully, but these errors were encountered: