[tools] go/packages: make Config.Env test independent of go list build work

0 views
Skip to first unread message

Quim Muntal (Gerrit)

unread,
Jun 8, 2026, 12:23:18 PM (3 days ago) Jun 8
to goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Michael Matloob, Michael Matloob, Ian Alexander, golang...@luci-project-accounts.iam.gserviceaccount.com, golang-co...@googlegroups.com

Quim Muntal submitted the change

Change information

Commit message:
go/packages: make Config.Env test independent of go list build work

TestEmptyEnvironment expected packages.Load with Env set to only
FOO=BAR to fail when loading fmt. That failure was incidental and an
implementation detail.

Replace the test with a direct check of the original invariant:
when Config.Env is non-nil, go/packages must not inherit the process
environment. The new test sets GOFLAGS=-tags=fromparent in the parent
process, loads a temporary module using a Config.Env that omits GOFLAGS,
and verifies that a file guarded by that tag is not selected.
Change-Id: I08f1bff72cbc26bf2821018f909a91171d4bb74e
Auto-Submit: Quim Muntal <quimm...@gmail.com>
Reviewed-by: Michael Matloob <mat...@golang.org>
Reviewed-by: Ian Alexander <ji...@google.com>
Reviewed-by: Michael Matloob <mat...@google.com>
Files:
  • M go/packages/packages_test.go
Change size: S
Delta: 1 file changed, 36 insertions(+), 7 deletions(-)
Branch: refs/heads/master
Submit Requirements:
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: tools
Gerrit-Branch: master
Gerrit-Change-Id: I08f1bff72cbc26bf2821018f909a91171d4bb74e
Gerrit-Change-Number: 787721
Gerrit-PatchSet: 2
Gerrit-Owner: Quim Muntal <quimm...@gmail.com>
Gerrit-Reviewer: Ian Alexander <ji...@google.com>
Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
Gerrit-Reviewer: Michael Matloob <mat...@google.com>
Gerrit-Reviewer: Quim Muntal <quimm...@gmail.com>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages