Skip to content

internal/testing/setup: close the fake credentials file - #3768

Merged
vangent merged 1 commit into
google:masterfrom
TuSKan:setup-test-robustness
Aug 13, 2026
Merged

internal/testing/setup: close the fake credentials file#3768
vangent merged 1 commit into
google:masterfrom
TuSKan:setup-test-robustness

Conversation

@TuSKan

@TuSKan TuSKan commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

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 the test 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 a package on Windows even when the test itself passes. On stock master:

$ go test ./gcp/ -run Credentials
--- FAIL: TestDefaultCredentialsWithParams
    testing.go:1464: TempDir RemoveAll cleanup: unlinkat ...: The process
    cannot access the file because it is being used by another process.
FAIL

and with this change:

$ go test ./gcp/ -run Credentials
ok      gocloud.dev/gcp

The handle is now closed before the file is written to by name. Nine other packages call FakeGCPDefaultCredentials and are affected the same way.

Verified with go build ./..., gofmt -s, go vet, and golangci-lint run (0 issues).

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.
Comment thread internal/testing/setup/setup.go Outdated
Comment thread internal/testing/setup/setup.go Outdated
@TuSKan
TuSKan force-pushed the setup-test-robustness branch from e665c8c to 8843fbd Compare August 13, 2026 21:42
@TuSKan TuSKan changed the title internal/testing/setup: close the fake credentials file, and skip replay tests with no recording internal/testing/setup: close the fake credentials file Aug 13, 2026
@codecov

codecov Bot commented Aug 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.42%. Comparing base (b5401c0) to head (8843fbd).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
internal/testing/setup/setup.go 0.00% 1 Missing and 1 partial ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@vangent
vangent merged commit db29b80 into google:master Aug 13, 2026
13 checks passed
@TuSKan
TuSKan deleted the setup-test-robustness branch August 13, 2026 22:16
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 this pull request may close these issues.

2 participants