From 9cce08d72470eb6ae2a2870bb9c70d1893441b0f Mon Sep 17 00:00:00 2001 From: Tom Thorogood Date: Thu, 12 Sep 2019 07:09:39 +0000 Subject: [PATCH] cmd/go/internal/renameio,runtime: avoid leaking temp directory in test TestWriteFileModeAppliesUmask and TestVectoredHandlerDontCrashOnLibrary could both leak /tmp/go-build-* directories which isn't very friendly. Change-Id: Ibee9c33d49ad48958fae4df73853b82d92314bf0 GitHub-Last-Rev: 814e2fa4bb4e4fe9c00b6d465313ce35c7ab4e32 GitHub-Pull-Request: golang/go#34253 Reviewed-on: https://go-review.googlesource.com/c/go/+/194880 Run-TryBot: Agniva De Sarker TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- src/cmd/go/internal/renameio/umask_test.go | 2 +- src/runtime/signal_windows_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cmd/go/internal/renameio/umask_test.go b/src/cmd/go/internal/renameio/umask_test.go index 031fe46e09..1d5e594e7e 100644 --- a/src/cmd/go/internal/renameio/umask_test.go +++ b/src/cmd/go/internal/renameio/umask_test.go @@ -19,6 +19,7 @@ func TestWriteFileModeAppliesUmask(t *testing.T) { if err != nil { t.Fatalf("Failed to create temporary directory: %v", err) } + defer os.RemoveAll(dir) const mode = 0644 const umask = 0007 @@ -29,7 +30,6 @@ func TestWriteFileModeAppliesUmask(t *testing.T) { if err != nil { t.Fatalf("Failed to write file: %v", err) } - defer os.RemoveAll(dir) fi, err := os.Stat(file) if err != nil { diff --git a/src/runtime/signal_windows_test.go b/src/runtime/signal_windows_test.go index c56da15292..9748403412 100644 --- a/src/runtime/signal_windows_test.go +++ b/src/runtime/signal_windows_test.go @@ -28,7 +28,7 @@ func TestVectoredHandlerDontCrashOnLibrary(t *testing.T) { if err != nil { t.Fatalf("failed to create temp directory: %v", err) } - defer os.Remove(dir) + defer os.RemoveAll(dir) // build go dll dll := filepath.Join(dir, "testwinlib.dll")