Commit cc41410
committed
fix: prevent false positive recursion detection in tests (Fixes #564)
Problem: When building goenv AUR package with goenv-installed Go (not system Go), all exec tests fail with 'infinite recursion detected' error. This happens because _GOENV_EXEC_ACTIVE=1 is inherited from parent shell when tests run under goenv-managed Go.
Root Cause: Simple boolean check (if env var != '') creates false positive when tests inherit _GOENV_EXEC_ACTIVE from parent shell. Pattern: User has goenv Go active → runs 'paru -S goenv' → build runs 'make check' → 'go test' calls goenv exec internally → recursion guard finds inherited env var → FALSE POSITIVE.
Solution: Changed recursion guard from simple boolean check to PID-based detection. Now checks if env var value equals parent PID (os.Getppid()), indicating actual shim → exec → shim → exec recursion chain, not just inherited environment. Also added os.Unsetenv('_GOENV_EXEC_ACTIVE') in test setup as defensive measure.
Testing: All exec tests now pass (TestExecCommand with 9 subtests, TestExecEnvironmentVariables, TestExecWithShims). PID-based approach prevents false positives while still catching real infinite recursion.1 parent 4abf4c6 commit cc41410
2 files changed
Lines changed: 13 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
67 | 70 | | |
68 | | - | |
| 71 | + | |
| 72 | + | |
69 | 73 | | |
70 | 74 | | |
71 | 75 | | |
| |||
312 | 316 | | |
313 | 317 | | |
314 | 318 | | |
315 | | - | |
316 | | - | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
317 | 322 | | |
318 | 323 | | |
319 | 324 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
111 | 115 | | |
112 | 116 | | |
113 | 117 | | |
| |||
0 commit comments