internal/testing/setup: close the fake credentials file - #3768
Merged
Conversation
FakeGCPDefaultCredentials creates the file with os.CreateTemp and never
closes the returned handle. On Windows an open handle blocks deletion, so
t.TempDir's cleanup fails and every test that calls it reports:
TempDir RemoveAll cleanup: unlinkat ...\fake-gcp-creds...:
The process cannot access the file because it is being used by another
process.
That is enough to fail `go test ./blob/gcsblob/` on Windows even when the
test itself passes. Close the handle before writing to the file by name.
vangent
requested changes
Aug 13, 2026
TuSKan
force-pushed
the
setup-test-robustness
branch
from
August 13, 2026 21:42
e665c8c to
8843fbd
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3768 +/- ##
=======================================
Coverage 75.41% 75.42%
=======================================
Files 104 104
Lines 14262 14267 +5
=======================================
+ Hits 10756 10761 +5
+ Misses 2769 2768 -1
- Partials 737 738 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
FakeGCPDefaultCredentialscreates the file withos.CreateTempand never closes the returned handle. On Windows an open handle blocks deletion, sot.TempDir's cleanup fails and the test reports:That is enough to fail a package on Windows even when the test itself passes. On stock
master:and with this change:
The handle is now closed before the file is written to by name. Nine other packages call
FakeGCPDefaultCredentialsand are affected the same way.Verified with
go build ./...,gofmt -s,go vet, andgolangci-lint run(0 issues).