| 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.Exit(m.Run()) |
| 18 | } |
| 19 | cleanupUserState, err := testenv.IsolateUserState() |
| 20 | if err != nil { |
| 21 | panic(err) |
| 22 | } |
| 23 | goleak.VerifyTestMain(m, goleak.Cleanup(func(exitCode int) { |
| 24 | cleanupUserState() |
| 25 | os.Exit(exitCode) |
| 26 | })) |
| 27 | } |
| 28 |