From 626c70a1056b60a41bd416ccf36403f78d2bcdfd Mon Sep 17 00:00:00 2001 From: zonescape <44441590+zonescape@users.noreply.github.com> Date: Thu, 21 Nov 2024 11:16:23 +0300 Subject: [PATCH] Test: Remove temporary directory afterwards --- 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() +}