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/host/machine_info_linux_test.go | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'pkg/host/machine_info_linux_test.go') diff --git a/pkg/host/machine_info_linux_test.go b/pkg/host/machine_info_linux_test.go index fdb3f3011..755b792f7 100644 --- a/pkg/host/machine_info_linux_test.go +++ b/pkg/host/machine_info_linux_test.go @@ -7,8 +7,6 @@ import ( "bufio" "bytes" "fmt" - "io/ioutil" - "os" "path/filepath" "runtime" "strings" @@ -385,11 +383,7 @@ power management: } func TestGetGlobsInfo(t *testing.T) { - dir, err := ioutil.TempDir("", "syz-host-globstest") - if err != nil { - t.Fatal(err) - } - defer os.RemoveAll(dir) + dir := t.TempDir() if err := osutil.MkdirAll(filepath.Join(dir, "a", "b", "c", "d")); err != nil { t.Fatal(err) } -- cgit mrf-deployment