From ce8c415d43f674b96cb7cb47e28c5fd275f74254 Mon Sep 17 00:00:00 2001 From: zonescape <44441590+zonescape@users.noreply.github.com> Date: Mon, 25 Nov 2024 07:00:00 +0300 Subject: [PATCH] Test: Remove temporary directory afterwards (#4045) --- testing/scenarios/common.go | 2 ++ testing/scenarios/main_test.go | 12 ++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 testing/scenarios/main_test.go diff --git a/testing/scenarios/common.go b/testing/scenarios/common.go index 8d629c59..dc54105a 100644 --- a/testing/scenarios/common.go +++ b/testing/scenarios/common.go @@ -96,6 +96,7 @@ func InitializeServerConfig(config *core.Config) (*exec.Cmd, error) { var ( testBinaryPath string + testBinaryCleanFn func() testBinaryPathGen sync.Once ) @@ -108,6 +109,7 @@ func genTestBinaryPath() { return err } tempDir = dir + testBinaryCleanFn = func() { os.RemoveAll(dir) } return nil })) file := filepath.Join(tempDir, "xray.test") diff --git a/testing/scenarios/main_test.go b/testing/scenarios/main_test.go new file mode 100644 index 00000000..269081c6 --- /dev/null +++ b/testing/scenarios/main_test.go @@ -0,0 +1,12 @@ +package scenarios + +import ( + "testing" +) + +func TestMain(m *testing.M) { + genTestBinaryPath() + defer testBinaryCleanFn() + + m.Run() +}