-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
all: replace os.MkdirTemp
with T.TempDir
#45402
Comments
The // localTmp returns a local temporary directory not on NFS.
func localTmp() string {
switch runtime.GOOS {
case "android", "windows":
return TempDir()
case "darwin", "ios":
switch runtime.GOARCH {
case "arm64":
return TempDir()
}
}
return "/tmp"
} Does this really ensures that the returned directory is really not on a remote filesystem? |
How many packages does this encompass? My feeling is, to avoid a protected review process, this is best addressed, at least until a pattern/patterns are established, on a package by package basis. |
There are about 18 packages in Here is a list of all test files; in the list is included a file in std
cmd
|
Another possible issue when using Currently it seems that there are no cases of However there may be cases in future, that should be handled and documented correctly. |
Thinking more carefully, there should be no issues with calling |
I think |
Change https://golang.org/cl/307653 mentions this issue: |
Updates: #45402 Change-Id: Ia61f422d058bf57fc3688abc25597d6cc1692c51 Reviewed-on: https://go-review.googlesource.com/c/go/+/307653 Run-TryBot: Dave Cheney <dave@cheney.net> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Dave Cheney <dave@cheney.net> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
The usage of
It would be better to replace it with the function |
The chtmpdir can be used when the test does not actually need to know the path to the temporary directory. It is better, for now, to not replace |
Change https://golang.org/cl/307989 mentions this issue: |
Change https://golang.org/cl/307990 mentions this issue: |
Change https://golang.org/cl/308011 mentions this issue: |
Change https://golang.org/cl/308109 mentions this issue: |
Change https://golang.org/cl/308129 mentions this issue: |
Updates #45402 Change-Id: I573133d6b987e8ac23e3e2018652612af684c755 Reviewed-on: https://go-review.googlesource.com/c/go/+/307990 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Updates #45402 Change-Id: I3aa82fc2486b4de49b45388bbab24f5ffe558f91 Reviewed-on: https://go-review.googlesource.com/c/go/+/307989 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Tobias Klauser <tobias.klauser@gmail.com>
Updates #45402 Change-Id: Idbd8067759d58bc57c52ede4ddccc98ab0ae18fc Reviewed-on: https://go-review.googlesource.com/c/go/+/308129 Run-TryBot: Dave Cheney <dave@cheney.net> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Tobias Klauser <tobias.klauser@gmail.com>
Change https://golang.org/cl/308409 mentions this issue: |
Updates #45402 Change-Id: Ifb1fa5232a0fa1be62e886643cec9deaa3b312ad Reviewed-on: https://go-review.googlesource.com/c/go/+/308409 Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Updates #45402 Change-Id: Ib8e62a13ddff884e4d34b3a0fdc9a10db2b68da6 Reviewed-on: https://go-review.googlesource.com/c/go/+/308109 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Add the tempDirCanonical function, for tests that need a temporary directory that does not contain symlinks. Updates #45402 Change-Id: I3d08ef32ef911331544acce3d7d013b4c3382960 Reviewed-on: https://go-review.googlesource.com/c/go/+/308011 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Change https://golang.org/cl/308996 mentions this issue: |
Updates #45402. Change-Id: I6fe356b51bc825a907f979d9c44432a4d43d1f6e Reviewed-on: https://go-review.googlesource.com/c/go/+/308996 Trust: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Change https://golang.org/cl/309351 mentions this issue: |
Change https://golang.org/cl/309352 mentions this issue: |
Updates #45402 Change-Id: I9d55191c4021387b771550b5c93c91806f694aa6 Reviewed-on: https://go-review.googlesource.com/c/go/+/309351 Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Tobias Klauser <tobias.klauser@gmail.com>
Updates #45402 Change-Id: I3d83a66270ca38e82d6bb7f8a1367af3d5343a98 Reviewed-on: https://go-review.googlesource.com/c/go/+/309352 Trust: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Change https://golang.org/cl/309354 mentions this issue: |
Change https://golang.org/cl/309355 mentions this issue: |
Change https://golang.org/cl/309356 mentions this issue: |
Updates #45402 Change-Id: I296f8c676c68ed1e10b6ad1a17b5b23d2c395252 Reviewed-on: https://go-review.googlesource.com/c/go/+/309355 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Joe Tsai <thebrokentoaster@gmail.com> TryBot-Result: Go Bot <gobot@golang.org>
Updates #45402 Change-Id: Ic2f696837034de17333a6a53127a4bfd301e96a4 Reviewed-on: https://go-review.googlesource.com/c/go/+/309354 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Tobias Klauser <tobias.klauser@gmail.com>
Updates #45402 Change-Id: Ie84795ed456883c0558fa9b5e3f2186f5f2c0fd9 Reviewed-on: https://go-review.googlesource.com/c/go/+/309356 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Tobias Klauser <tobias.klauser@gmail.com>
Change https://golang.org/cl/362246 mentions this issue: |
Use t.TempDir() instead of os.MkdirTemp(). This is a copy of CL 309356 from the main repo. Updates golang/go#45402. Change-Id: Ia555a701e4de568871a765ee551e65a5c998cde9 Reviewed-on: https://go-review.googlesource.com/c/tools/+/362246 Trust: Than McIntosh <thanm@google.com> Reviewed-by: Bryan C. Mills <bcmills@google.com>
Change https://go.dev/cl/462896 mentions this issue: |
Change https://go.dev/cl/464350 mentions this issue: |
Updates #45402 Change-Id: Ieffd1c8b0b5e4e63024b5be2e1f910fb4411eb94 GitHub-Last-Rev: fa7418c GitHub-Pull-Request: #57940 Reviewed-on: https://go-review.googlesource.com/c/go/+/462896 Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org>
Updates golang#45402 Change-Id: Ieffd1c8b0b5e4e63024b5be2e1f910fb4411eb94 GitHub-Last-Rev: fa7418c GitHub-Pull-Request: golang#57940 Reviewed-on: https://go-review.googlesource.com/c/go/+/462896 Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org>
Following #45182 I propose to change all the calls to
os.MkdirTemp
in tests withT.TempDir
.The
os.MkdirTemp
is used 145 times in tests.Currently
os.MkdirTemp
is not used consistently:t.Name()
as name(as an example in
os_test.go
:TestDirentRepeat
->direntRepeat-test
)In the tests for the
os
package there is a support function:This function can be probably removed.
One possible issue is mixing the use of
defer
andT.Cleanup
, as an example in case of chdir to a temporary directory, resulting in an incorrect cleanup order; one example is https://golang.org/cl/307189 but there seems to be other possible cases.I would like to submit the change, but a lot of packages are involved; how should I proceed?
Probably I should start with the
std
module followed bycmd
andmisc
(?).Should I submit one change for package instead of one change for module?
Thanks.
The text was updated successfully, but these errors were encountered: