ory/go-acc

Modifies `go test -json` output, making it invalid JSON

Closed this issue · 4 comments

The output of go test -json contains coverage summaries, e.g.,

{"Time":"2021-06-04T15:08:38.3398169-07:00","Action":"output","Package":"example","Output":"coverage: 14.8% of statements\n"}

These lines are modified by

fmt.Println(strings.Split(line, "% of statements in")[0])

Namely, the last part of the split is removed:

{"Time":"2021-06-04T15:08:38.3398169-07:00","Action":"output","Package":"example","Output":"coverage: 14.8

Unfortunately, that is no longer parsable JSON.

Would you be up for a PR? :)

Thanks for triaging this!

The line was introduced to "improve pipeline handling" in ddc3550. I'm honestly not sure what the right fix would be. I don't want to regress pipe handling. Any suggestions? With some direction, I should be able to PR it.

One possibility would be to check if the string is JSON and leave it untouched if it isn't json

I resolved this issue on master!