Skip to content

extension/src: show build errors from go test -json - #4086

Open
Om-singhaI wants to merge 1 commit into
golang:masterfrom
Om-singhaI:fix-3744-build-output
Open

Om-singhaI wants to merge 1 commit into
golang:masterfrom
Om-singhaI:fix-3744-build-output

Conversation

@Om-singhaI

Copy link
Copy Markdown

Since go1.24, go test -json reports build output on stdout as JSON
events with Action "build-output", instead of plain text on stderr.
goTest adds -json whenever go.testFlags has -v, and the test explorer
always runs with it. processTestResultLineInJSONMode then drops every
event whose Action is not "output", so a package that does not compile
shows only "FAIL pkg [build failed]" and no compiler errors.

This change prints "build-output" events as well. Their file names are
relative to the directory go test runs in, like the old stderr text, so
they are expanded with testconfig.dir the same way. The test explorer
passes its own output channel to goTest, so the errors show up in the
Test Results view again, and isBuildFailure can find the "# pkg" header
line and mark the tests as "Compilation failed" instead of skipped.

To test it without VS Code, processTestResultLineInJSONMode moves to a
new file, goTestOutput.ts, which does not import vscode. The new unit
test uses go test -json lines captured from go1.27.

Fixes #3744

Since go1.24, go test -json reports build output on stdout as JSON
events with Action "build-output", instead of plain text on stderr.
goTest adds -json whenever go.testFlags has -v, and the test explorer
always runs with it. processTestResultLineInJSONMode then drops every
event whose Action is not "output", so a package that does not compile
shows only "FAIL pkg [build failed]" and no compiler errors.

This change prints "build-output" events as well. Their file names are
relative to the directory go test runs in, like the old stderr text, so
they are expanded with testconfig.dir the same way. The test explorer
passes its own output channel to goTest, so the errors show up in the
Test Results view again, and isBuildFailure can find the "# pkg" header
line and mark the tests as "Compilation failed" instead of skipped.

To test it without VS Code, processTestResultLineInJSONMode moves to a
new file, goTestOutput.ts, which does not import vscode. The new unit
test uses go test -json lines captured from go1.27.

Fixes golang#3744
@gopherbot

Copy link
Copy Markdown
Collaborator

This PR (HEAD: 8ec1f59) has been imported to Gerrit for code review.

Please visit Gerrit at https://go-review.googlesource.com/c/vscode-go/+/849385.

Important tips:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to log in to Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.

@gopherbot

Copy link
Copy Markdown
Collaborator

Message from Gopher Robot:

Patch Set 1:

Congratulations on opening your first change. Thank you for your contribution!

Next steps:
A maintainer will review your change and provide feedback. See
https://go.dev/doc/contribute#review for more info and tips to get your
patch through code review.

Most changes in the Go project go through a few rounds of revision. This can be
surprising to people new to the project. The careful, iterative review process
is our way of helping mentor contributors and ensuring that their contributions
have a lasting impact.


Please don’t reply on this GitHub thread. Visit golang.org/cl/849385.
After addressing review feedback, remember to publish your drafts!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When using go1.24 or later, the Go: Test command no longer displays compile errors

2 participants