返回 DeepSeek-Reasonix
main_test.go
根目录 / internal / plugin / main_test.go
1 package plugin
2
3 import (
4 "os"
5 "testing"
6
7 "reasonix/internal/testenv"
8
9 "go.uber.org/goleak"
10 )
11
12 func TestMain(m *testing.M) {
13 // MCP helper subprocesses run this same test binary under the sandbox and
14 // inherit the already-isolated parent environment. They must not try to
15 // allocate a second user home outside their allowed roots.
16 if os.Getenv("GO_WANT_HELPER_PROCESS") == "1" || os.Getenv("GO_WANT_HELPER_STDERR_EXIT") == "1" ||
17 os.Getenv("GO_WANT_HELPER_STDERR_CODEPAGE") == "1" {
18 os.Exit(m.Run())
19 }
20 cleanupUserState, err := testenv.IsolateUserState()
21 if err != nil {
22 panic(err)
23 }
24 goleak.VerifyTestMain(m, goleak.Cleanup(func(exitCode int) {
25 cleanupUserState()
26 os.Exit(exitCode)
27 }))
28 }
29
29 lines GO