Repository navigation
extension/src: show build errors from go test -json - #4086
Om-singhaI wants to merge 1 commit into
Conversation
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
|
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:
|
|
Message from Gopher Robot: Patch Set 1: Congratulations on opening your first change. Thank you for your contribution! Next steps: Most changes in the Go project go through a few rounds of revision. This can be Please don’t reply on this GitHub thread. Visit golang.org/cl/849385. |
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