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

Replace os.TempDir usage with t.TempDir #1146

Merged
merged 4 commits into from Aug 15, 2022

Conversation

prashantv
Copy link
Collaborator

Current tests can leave files around if tests fail, and even though they
use rand, it's not seeded, different runs can share the same output file
which causes other failures (e.g., file exists when it's not expected
to). Avoid this by using t.TempDir which automatically removed after
tests have run.

Current tests can leave files around if tests fail, and even though they
use rand, it's not seeded, different runs can share the same output file
which causes other failures (e.g., file exists when it's not expected
to).  Avoid this by using  t.TempDir which automatically removed after
tests have run.
@codecov
Copy link

codecov bot commented Aug 15, 2022

Codecov Report

Merging #1146 (d526b0d) into master (4b03bc5) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master    #1146   +/-   ##
=======================================
  Coverage   98.32%   98.32%           
=======================================
  Files          49       49           
  Lines        2146     2146           
=======================================
  Hits         2110     2110           
  Misses         28       28           
  Partials        8        8           

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Instead of managing the environment variable manually,
use t.Setenv to set and restore its value.
Copy link
Collaborator

@abhinav abhinav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm minus one missed case. will fix

@@ -30,7 +30,7 @@ import (

func BenchmarkBufferedWriteSyncer(b *testing.B) {
b.Run("write file with buffer", func(b *testing.B) {
file, err := os.CreateTemp("", "log")
file, err := os.CreateTemp("", "test.log")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why doesn't this use b.TempDir()?

Suggested change
file, err := os.CreateTemp("", "test.log")
file, err := os.CreateTemp(b.TempDir(), "test.log")

@abhinav abhinav merged commit bdd673d into uber-go:master Aug 15, 2022
@prashantv prashantv deleted the prashant/temp branch February 20, 2023 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants