Skip to content
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

test result caching with --raw-command <test-binary>? #345

Closed
nfi-hashicorp opened this issue Jul 27, 2023 · 1 comment · Fixed by #350
Closed

test result caching with --raw-command <test-binary>? #345

nfi-hashicorp opened this issue Jul 27, 2023 · 1 comment · Fixed by #350

Comments

@nfi-hashicorp
Copy link
Contributor

It appears that if you pre-build your test binaries with go test -c and run them with --raw-command, the Go test results cache is not used? I found this a bit surprising, but after some thought it makes sense.

It seems that the caching logic is done inside go test invoking the binary, not the binary itself. So in order for gotestsum to do test caching, it would have to import or reimplement the functionality from go test. A tall order.

If this is correct, it might be worth calling out in the docs somewhere.

(Context: I'm trying to run without Go in CI to avoid having to lug the whole build cache around. I just want the test cache; it should be considerably smaller.)

@dnephin
Copy link
Member

dnephin commented Jul 30, 2023

Hello!

It seems that the caching logic is done inside go test invoking the binary, not the binary itself.

That seems to be correct. From https://pkg.go.dev/cmd/go/internal/test

In package list mode only, go test caches successful package test
results to avoid unnecessary repeated running of tests. When the
result of a test can be recovered from the cache, go test will
redisplay the previous output instead of running the test binary
again. When this happens, go test prints '(cached)' in place of the
elapsed time in the summary line.

Add a note about this to https://github.com/gotestyourself/gotestsum/blob/main/.project/docs/running-without-go.md sounds like a great addition. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants