Skip to content

x/tools/internal/testenv: stop parsing CombinedOutput #65729

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
adonovan opened this issue Feb 15, 2024 · 3 comments
Closed

x/tools/internal/testenv: stop parsing CombinedOutput #65729

adonovan opened this issue Feb 15, 2024 · 3 comments
Assignees
Labels
FrozenDueToAge Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@adonovan
Copy link
Member

adonovan commented Feb 15, 2024

The testenv package defines a number of helpers for skipping tests. One of them checks that go env GOROOT and runtime.GOROOT agree; if not, it skips the test. (Perhaps it should fatal? But I digress.)

When running with GODEBUG=countertrace, the go env command prints a bunch of stuff to stderr, as it should. However, testenv runs the command and then gathers its CombinedOutput (2>&1), which means it is no longer a well-formed go env result. Mayhem ensues.

No Go program should attempt to parse CombinedOutput. It is for human eyes only (or tests that look for fragments of error messages among the wreckage).

@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Feb 15, 2024
@gopherbot gopherbot added this to the Unreleased milestone Feb 15, 2024
@adonovan adonovan self-assigned this Feb 15, 2024
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/564515 mentions this issue: x/tools: don't parse CombinedOutput

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/564516 mentions this issue: x/tools: don't parse CombinedOutput

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/564339 mentions this issue: x/tools: address review of CL 564515 (CombinedOutput)

gopherbot pushed a commit to golang/tools that referenced this issue Feb 16, 2024
I fumbled with git and forked the CL, stranding some review
comments from bcmills on the ill-fated fork.

Updates golang/go#65729

Change-Id: I6d0bf431f841dacb94e9e13a90bf39f8e2ed2fbf
Reviewed-on: https://go-review.googlesource.com/c/tools/+/564339
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
apstndb pushed a commit to apstndb/gotoolsdiff that referenced this issue Jan 11, 2025
This change fixes a bug in internal/testenv in which it would
gather the combined output (2>&1) of the "go env" command and
parse it as an environment variable. However, certain environment
variables (e.g. GODEBUG) cause "go env" to log to stderr,
so that the parser reads garbage. Use Output instead.

Also, preemptively fix a number of similar occurrences in
x/tools. CombinedOutput should be used only when the whole
output is ultimately sent to stderr or a log for human eyes,
or for tests that look for specific error messages in the
unstructured combined log. In those cases, the scope of
the 'out' variable can be reduced to avoid temptation.

Fixes golang/go#65729

Change-Id: Ifc0fd494fcde0e339bb5283e39c7696a34f5a699

.

Change-Id: I6eadd0e76498dc5f4d91e0904af2d52e610df683
Reviewed-on: https://go-review.googlesource.com/c/tools/+/564516
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
apstndb pushed a commit to apstndb/gotoolsdiff that referenced this issue Jan 11, 2025
I fumbled with git and forked the CL, stranding some review
comments from bcmills on the ill-fated fork.

Updates golang/go#65729

Change-Id: I6d0bf431f841dacb94e9e13a90bf39f8e2ed2fbf
Reviewed-on: https://go-review.googlesource.com/c/tools/+/564339
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
@golang golang locked and limited conversation to collaborators Feb 14, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

2 participants