Repository navigation
Commit 740eb68
committed
Keep Go unit tests off the host's Go env
`utils::go_env` reads GOWORK, GOFLAGS, GOPATH and friends from the
process and from the `go env -w` file under HOME. The Go unit tests
call production code that goes through it, so a developer's ambient
Go config changes what every fixture resolves. On origin/main
`cargo test -p socket-patch-core --lib` fails 15 tests with
GOWORK=off (a common `go env -w` setting), 103 with GOWORK pointing at
any absolute file, and 99 with GOFLAGS=-modfile=alt.mod.
In unit-test builds `go_env` now reads only the vars a test holds
with an EnvGuard (`test_env::guarded_var`); everything else, the
go env file's HOME/XDG_CONFIG_HOME/AppData included, is invisible.
Production builds read the process env exactly as before. The three
registry_fetch tests that hand-rolled set_var/restore now hold their
keys with EnvGuard, so their values stay visible.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011f9aeSwyBVuHJgG8G9SKZ11 parent c09cb0e commit 740eb68
4 files changed
Lines changed: 71 additions & 44 deletions
File tree
- crates/socket-patch-core/src
- utils
- vendor
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
7 | 23 | | |
8 | 24 | | |
9 | 25 | | |
| |||
33 | 49 | | |
34 | 50 | | |
35 | 51 | | |
| 52 | + | |
36 | 53 | | |
37 | 54 | | |
38 | 55 | | |
| |||
53 | 70 | | |
54 | 71 | | |
55 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
56 | 77 | | |
57 | 78 | | |
58 | 79 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
28 | 43 | | |
29 | 44 | | |
30 | 45 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1546 | 1546 | | |
1547 | 1547 | | |
1548 | 1548 | | |
1549 | | - | |
1550 | | - | |
1551 | | - | |
1552 | | - | |
1553 | | - | |
1554 | | - | |
1555 | | - | |
| 1549 | + | |
| 1550 | + | |
| 1551 | + | |
| 1552 | + | |
| 1553 | + | |
| 1554 | + | |
| 1555 | + | |
1556 | 1556 | | |
1557 | | - | |
| 1557 | + | |
| 1558 | + | |
1558 | 1559 | | |
1559 | | - | |
1560 | | - | |
1561 | | - | |
1562 | | - | |
1563 | | - | |
1564 | | - | |
1565 | | - | |
1566 | | - | |
1567 | 1560 | | |
1568 | 1561 | | |
1569 | 1562 | | |
| |||
1671 | 1664 | | |
1672 | 1665 | | |
1673 | 1666 | | |
1674 | | - | |
| 1667 | + | |
1675 | 1668 | | |
1676 | 1669 | | |
1677 | 1670 | | |
1678 | 1671 | | |
1679 | 1672 | | |
1680 | 1673 | | |
1681 | 1674 | | |
1682 | | - | |
1683 | | - | |
1684 | | - | |
1685 | 1675 | | |
1686 | 1676 | | |
1687 | 1677 | | |
| |||
1690 | 1680 | | |
1691 | 1681 | | |
1692 | 1682 | | |
1693 | | - | |
1694 | | - | |
1695 | | - | |
1696 | | - | |
1697 | | - | |
1698 | | - | |
1699 | 1683 | | |
1700 | 1684 | | |
1701 | 1685 | | |
| |||
1707 | 1691 | | |
1708 | 1692 | | |
1709 | 1693 | | |
1710 | | - | |
1711 | | - | |
1712 | 1694 | | |
1713 | | - | |
1714 | | - | |
| 1695 | + | |
| 1696 | + | |
| 1697 | + | |
| 1698 | + | |
| 1699 | + | |
1715 | 1700 | | |
1716 | 1701 | | |
1717 | 1702 | | |
| |||
1729 | 1714 | | |
1730 | 1715 | | |
1731 | 1716 | | |
1732 | | - | |
1733 | | - | |
1734 | | - | |
1735 | | - | |
1736 | | - | |
1737 | | - | |
1738 | | - | |
1739 | | - | |
1740 | | - | |
1741 | | - | |
1742 | | - | |
1743 | | - | |
1744 | | - | |
1745 | 1717 | | |
1746 | 1718 | | |
1747 | 1719 | | |
| |||
0 commit comments