Skip to content

Commit

Permalink
Test: Remove temporary directory afterwards (#4045)
Browse files Browse the repository at this point in the history
  • Loading branch information
zonescape authored Nov 25, 2024
1 parent 034a485 commit ce8c415
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions testing/scenarios/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ func InitializeServerConfig(config *core.Config) (*exec.Cmd, error) {

var (
testBinaryPath string
testBinaryCleanFn func()
testBinaryPathGen sync.Once
)

Expand All @@ -108,6 +109,7 @@ func genTestBinaryPath() {
return err
}
tempDir = dir
testBinaryCleanFn = func() { os.RemoveAll(dir) }
return nil
}))
file := filepath.Join(tempDir, "xray.test")
Expand Down
12 changes: 12 additions & 0 deletions testing/scenarios/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package scenarios

import (
"testing"
)

func TestMain(m *testing.M) {
genTestBinaryPath()
defer testBinaryCleanFn()

m.Run()
}

0 comments on commit ce8c415

Please sign in to comment.