]> Cypherpunks repositories - gostls13.git/commit
cmd/dist: flush incomplete lines in -json mode
authorAustin Clements <austin@google.com>
Fri, 19 May 2023 13:32:22 +0000 (09:32 -0400)
committerGopher Robot <gobot@golang.org>
Fri, 19 May 2023 20:13:24 +0000 (20:13 +0000)
commit6333725d5fae3ceda830d3d1d65b1540d004b288
tree3ef70b6acec6a4197d99811ae9a6e1b38e1f1eb3
parente6fb1905cb740b7d68b1c9676f058bf44266539d
cmd/dist: flush incomplete lines in -json mode

Currently, if a test prints an incomplete line and then exits, in JSON
mode, the filter we use to rewrite Package lines will keep the last
incomplete line in an internal buffer and never print it. In theory
this should never happen anyway because the test should only write
JSON to stdout, but we try pretty hard to pass through any non-JSON,
so it seems inconsistent to swallow incomplete lines.

Fix this by adding a testJSONFilter.Flush method and calling it in the
right places. Unfortunately this is a bit tricky because the filter is
constructed pretty far from where we run the exec.Cmd, so we return
the flush function through the various layers in order to route it to
the place where we call Cmd.Run.

Updates #37486.

Change-Id: I38af67e8ad23458598a32fd428779bb0ec21ac3c
Reviewed-on: https://go-review.googlesource.com/c/go/+/496516
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Austin Clements <austin@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
src/cmd/dist/test.go
src/cmd/dist/testjson.go
src/cmd/dist/testjson_test.go