GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||
GeezerVison is showing github.com — Keep Go unit tests off the host's Go env by mikolalysenko · Pull Request #2057 · SocketDev/socket-patch Conversation
|
| env | before | after |
|---|---|---|
| clean | 4 failed* | 4 failed* |
GOWORK=off (a common go env -w setting) |
19 failed (15 Go tests) | 4 failed* |
GOWORK=<any absolute file> |
107 failed (103 Go tests across golang_local, vendor::golang, go_consumer_sync, go_mod_edit, go_sum_backup, vex::discover::golang) |
4 failed* |
GOFLAGS=-modfile=alt.mod |
99 of 717 Go tests failed | 4 failed* |
HOME with .config/go/env → GOWORK=off, GOFLAGS=-modfile=alt.mod |
(not measured on main; same lookup path) | 4 failed* |
* The same 4 tests fail in every row, before and after: copy_tree::relax_loop_must_not_traverse_symlinked_root, vlt_heal::an_unremovable_hidden_lock_keeps_every_store_entry, and the two pypi_* wire-failure tests. They rely on permission errors, and my sandbox runs as root. CI doesn't run as root.
A Go developer with GOWORK=off or GOFLAGS set gets red tests on a clean checkout. The CI image could get the same result if it ever exports one of them.
go_env is the single place that reads process env for Go settings (GOWORK, GOFLAGS, GOPATH, GOMODCACHE, GOBIN, plus GOENV/HOME/XDG_CONFIG_HOME/AppData to find the go env file). In unit tests it reads the developer's real environment.
go_env reads through process_env. In production builds that's std::env::var, unchanged. In #[cfg(test)] builds it's test_env::guarded_var, which returns a var only while an EnvGuard holds it. Host values, including the go env file reached through HOME, are invisible.EnvGuard records the keys it holds in a mutex-protected multiset and releases them on drop. Nested guards work, and so does a panic partway through many.registry_fetch goproxy tests hand-rolled set_var/restore. They now hold their keys with EnvGuard, which also drops about 35 lines of manual save/restore. Assertions are unchanged.guarded_var_sees_only_vars_a_live_guard_holds.ctor) on purpose: that would add two new crates to the lockfile, and it would mutate env before main.No test is removed and no assertion is changed or weakened.
--lib suite (7,692 tests).GOWORK=off loop over the Go, test_env and goproxy tests: 30 runs, 0 failures.cargo clippy --locked -p socket-patch-core --all-features -- -D warnings (CI's command) is clean. --all-targets reports no lint in any touched file. The pre-existing --all-targets lints are elsewhere.test_env.rs with #[path] pass: crawler_npm_e2e 128, crawler_deno_e2e 13, upstream_restore_golden 62.https://claude.ai/code/session_011f9aeSwyBVuHJgG8G9SKZ1
Generated by Claude Code
Sorry, something went wrong.
There was an error while loading. Please reload this page.
`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) <[email protected]> Claude-Session: https://claude.ai/code/session_011f9aeSwyBVuHJgG8G9SKZ1
|
bugbot run Generated by Claude Code |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
PR SummaryLow Risk Overview
A new Reviewed by Cursor Bugbot for commit 740eb68. Configure here. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 740eb68. Configure here.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Ready for review at
Generated by Claude Code |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Final review briefWhat it does: In Risk: low. The production Look here
Verified: I read the full diff (4 files, +71/−44). Locally, Changes I made: none. Open questions: none. One minor point that isn't blocking: Auto-merge is armed, so approving sends this straight to the merge queue. Generated by Claude Code |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
At least 1 approving review is required to merge this pull request.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.