From 0d08379d0a6e5c91206a82e207c6c05f0f9fddc4 Mon Sep 17 00:00:00 2001 From: Eng Zer Jun Date: Wed, 23 Mar 2022 16:04:21 +0800 Subject: all: use `t.TempDir` to create temporary test directory This commit replaces all `ioutil.TempDir` with `t.TempDir` in tests. The directory created by `t.TempDir` is automatically removed when the test and all its subtests complete. Reference: https://pkg.go.dev/testing#T.TempDir Signed-off-by: Eng Zer Jun --- pkg/compiler/const_file_test.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'pkg/compiler') diff --git a/pkg/compiler/const_file_test.go b/pkg/compiler/const_file_test.go index 51858a790..b38d0795d 100644 --- a/pkg/compiler/const_file_test.go +++ b/pkg/compiler/const_file_test.go @@ -109,11 +109,7 @@ CONST5_SOME_UNDEFINED2 = 100, arch3:??? } } { - dir, err := ioutil.TempDir("", "syz-const") - if err != nil { - t.Fatal(err) - } - defer os.RemoveAll(dir) + dir := t.TempDir() for name, arch := range arches { file := filepath.Join(dir, "consts_"+name+".const") if err := ioutil.WriteFile(file, []byte(arch.oldFormat), 0600); err != nil { -- cgit mrf-deployment