From a00195d304e6858406c6c9c961d253eeb8cb0aec Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Thu, 7 Sep 2023 17:21:16 -0700 Subject: all: use t.Chdir in tests Change-Id: I5bc514bedeb1155e6db52e37736fd6101774aea0 Reviewed-on: https://go-review.googlesource.com/c/go/+/529896 Auto-Submit: Ian Lance Taylor LUCI-TryBot-Result: Go LUCI Reviewed-by: Dmitri Shuralyov Reviewed-by: Ian Lance Taylor Commit-Queue: Ian Lance Taylor --- src/os/exec/exec_test.go | 22 ---------------------- 1 file changed, 22 deletions(-) (limited to 'src/os/exec/exec_test.go') diff --git a/src/os/exec/exec_test.go b/src/os/exec/exec_test.go index fd185cadcf..8c62387193 100644 --- a/src/os/exec/exec_test.go +++ b/src/os/exec/exec_test.go @@ -169,28 +169,6 @@ func helperCommandContext(t *testing.T, ctx context.Context, name string, args . return cmd } -func chdir(t *testing.T, dir string) { - t.Helper() - - prev, err := os.Getwd() - if err != nil { - t.Fatal(err) - } - if err := os.Chdir(dir); err != nil { - t.Fatal(err) - } - t.Logf("Chdir(%#q)", dir) - - t.Cleanup(func() { - if err := os.Chdir(prev); err != nil { - // Couldn't chdir back to the original working directory. - // panic instead of t.Fatal so that we don't run other tests - // in an unexpected location. - panic("couldn't restore working directory: " + err.Error()) - } - }) -} - var helperCommandUsed sync.Map var helperCommands = map[string]func(...string){ -- cgit v1.3-5-g9baa