From 7354e2e23b2980f04a6dbe2d2fb1853f0784849b Mon Sep 17 00:00:00 2001 From: zackattack01 Date: Mon, 23 Dec 2024 15:15:05 -0500 Subject: [PATCH] fixup runsimple cleanup --- pkg/osquery/runsimple/osqueryrunner_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/osquery/runsimple/osqueryrunner_test.go b/pkg/osquery/runsimple/osqueryrunner_test.go index 67935c2f0..2ef4cbc35 100644 --- a/pkg/osquery/runsimple/osqueryrunner_test.go +++ b/pkg/osquery/runsimple/osqueryrunner_test.go @@ -26,11 +26,11 @@ func TestMain(m *testing.M) { fmt.Println("Failed to make temp dir for test binaries") os.Exit(1) //nolint:forbidigo // Fine to use os.Exit in tests } - defer os.RemoveAll(dir) if err := downloadOsqueryInBinDir(dir); err != nil { fmt.Printf("Failed to download osquery: %v\n", err) - os.Exit(1) //nolint:forbidigo // Fine to use os.Exit in tests + os.Remove(dir) // explicit removal as defer will not run when os.Exit is called + os.Exit(1) //nolint:forbidigo // Fine to use os.Exit in tests } testOsqueryBinary = filepath.Join(dir, "osqueryd") @@ -40,6 +40,8 @@ func TestMain(m *testing.M) { // Run the tests! retCode := m.Run() + + os.Remove(dir) // explicit removal as defer will not run when os.Exit is called os.Exit(retCode) //nolint:forbidigo // Fine to use os.Exit in tests }