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

cmd/go: add build -json, to report build failures in JSON #23037

Open
zolotov opened this Issue Dec 7, 2017 · 5 comments

Comments

Projects
None yet
3 participants
@zolotov
Contributor

zolotov commented Dec 7, 2017

If I run go test on a directory and one of the packages is failed to run, I won't get any json output for it.
It would be great to have at least a single package-fail json-message.

@ianlancetaylor

This comment has been minimized.

Contributor

ianlancetaylor commented Dec 7, 2017

In general the go tool does not support multiple packages in a single directory.

Can you give a small complete example?

@zolotov

This comment has been minimized.

Contributor

zolotov commented Dec 7, 2017

  • dir/compilablePackage/foo_test.go
  • dir/nonCompilablePackage/foo_test.go

run cd dir && go test -json ./...

@ianlancetaylor

This comment has been minimized.

Contributor

ianlancetaylor commented Dec 15, 2017

Thanks. For future reference, when I ask for a small complete example, it really helps a lot if you can give a complete example, which means the exact files and the exact commands. Otherwise I have to guess what you mean when you say "nonCompilablePackage", and experience tells me that I often guess wrong.

Here is a complete example that may show the problem:

src/p1/p1.go

package p1

func F() {}

src/p1/p1_test.go

package p1

import "testing"

func TestF(t *testing.T) {
	F()
	t.Log("F")
}

src/p2/p2.go:

package p2

func F() {}

this file will not compile

src/p2/p2_test.go:

package p2

import "testing"

func TestF(t *testing.T) {
	F()
	t.Log("F")
}
go test -json ./...
# p2
src/p2/p2.go:5:1: syntax error: non-declaration statement outside function body
{"Time":"2017-12-15T13:38:12.885932037-08:00","Action":"run","Package":"p1","Test":"TestF"}
{"Time":"2017-12-15T13:38:12.886027694-08:00","Action":"output","Package":"p1","Test":"TestF","Output":"=== RUN   TestF\n"}
{"Time":"2017-12-15T13:38:12.88604052-08:00","Action":"output","Package":"p1","Test":"TestF","Output":"--- PASS: TestF (0.00s)\n"}
{"Time":"2017-12-15T13:38:12.886047376-08:00","Action":"output","Package":"p1","Test":"TestF","Output":"\tp1_test.go:7: F\n"}
{"Time":"2017-12-15T13:38:12.886054374-08:00","Action":"pass","Package":"p1","Test":"TestF","Elapsed":0}
{"Time":"2017-12-15T13:38:12.88607203-08:00","Action":"output","Package":"p1","Output":"PASS\n"}
{"Time":"2017-12-15T13:38:12.886112826-08:00","Action":"output","Package":"p1","Output":"ok  \tp1\t0.009s\n"}
{"Time":"2017-12-15T13:38:12.886135226-08:00","Action":"pass","Package":"p1","Elapsed":0.009}
FAIL	p2 [build failed]

If I understand you correctly, you are saying that you would like to have JSON output that reports that we were unable to build package p2. Is that correct?

CC @rsc

@ianlancetaylor ianlancetaylor changed the title from cmd/test2json: add JSON output for building package failures while running go test on directory with several packages to cmd/go: add JSON output for building package failures while running go test on directory with several packages Dec 15, 2017

@ianlancetaylor ianlancetaylor added this to the Go1.10 milestone Dec 15, 2017

@zolotov

This comment has been minimized.

Contributor

zolotov commented Dec 15, 2017

Yes, that's correct.

@rsc

This comment has been minimized.

Contributor

rsc commented Jan 4, 2018

You're asking for go build -json. We are only adding go test -json in this release. Maybe in a future release we could add go build -json and make go test imply that flag. Sorry.

@rsc rsc changed the title from cmd/go: add JSON output for building package failures while running go test on directory with several packages to cmd/go: add build -json, to report build failures in JSON Jan 4, 2018

@rsc rsc modified the milestones: Go1.10, Go1.11 Jan 4, 2018

sigma added a commit to sigma/go-junit-report that referenced this issue Mar 20, 2018

add support for build-originated logs
Unfortunately, there is no go build json output as of yet
(golang/go#23037)

sigma added a commit to sigma/go-junit-report that referenced this issue Mar 20, 2018

add support for build-originated logs
Unfortunately, there is no go build json output as of yet
(golang/go#23037)

@ianlancetaylor ianlancetaylor modified the milestones: Go1.11, Unplanned Jul 3, 2018

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