mirror of
https://github.com/rwinkhart/sys.git
synced 2026-08-28 04:46:44 -04:00
all: use t.TempDir in tests
This removes all usage of ioutil.TempDir in tests (and a few cases of os.TempDir as well, while we're at it), which simplifies test cleanup a lot. Compile tested (go test -c) for most platforms (except zos). Change-Id: I9178f5ec615c0a6cfef36e8de78c6b72e055b7cb Reviewed-on: https://go-review.googlesource.com/c/sys/+/526297 Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: qiulaidongfeng <2645477756@qq.com> Auto-Submit: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
committed by
Gopher Robot
parent
0514fecd90
commit
0e97d69659
@@ -27,13 +27,7 @@ import (
|
||||
)
|
||||
|
||||
func TestWin32finddata(t *testing.T) {
|
||||
dir, err := ioutil.TempDir("", "go-build")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create temp directory: %v", err)
|
||||
}
|
||||
defer os.RemoveAll(dir)
|
||||
|
||||
path := filepath.Join(dir, "long_name.and_extension")
|
||||
path := filepath.Join(t.TempDir(), "long_name.and_extension")
|
||||
f, err := os.Create(path)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create %v: %v", path, err)
|
||||
@@ -673,12 +667,7 @@ func TestWinVerifyTrust(t *testing.T) {
|
||||
|
||||
// Now that we've verified the legitimate file verifies, let's corrupt it and see if it correctly fails.
|
||||
|
||||
dir, err := ioutil.TempDir("", "go-build")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create temp directory: %v", err)
|
||||
}
|
||||
defer os.RemoveAll(dir)
|
||||
corruptedEvsignedfile := filepath.Join(dir, "corrupted-file")
|
||||
corruptedEvsignedfile := filepath.Join(t.TempDir(), "corrupted-file")
|
||||
evsignedfileBytes, err := ioutil.ReadFile(evsignedfile)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to read %s bytes: %v", evsignedfile, err)
|
||||
|
||||
Reference in New Issue
Block a user