aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/internal/test/test.go
diff options
context:
space:
mode:
authorBryan C. Mills <bcmills@google.com>2020-08-14 17:44:22 -0400
committerBryan C. Mills <bcmills@google.com>2020-08-17 19:43:21 +0000
commit1b86bdbdc3991c13c6ed156100a5f4918fdd9c6b (patch)
tree1630f7d8bec19ca853d9e9804aeb532e44df6f28 /src/cmd/go/internal/test/test.go
parentf30044a03bc7cf107dbec03c02fb6d0072878252 (diff)
downloadgo-1b86bdbdc3991c13c6ed156100a5f4918fdd9c6b.tar.gz
go-1b86bdbdc3991c13c6ed156100a5f4918fdd9c6b.zip
cmd/test2json: do not emit a final Action if the result is not known
If we are parsing a test output, and the test does not end in the usual PASS or FAIL line (say, because it panicked), then we need the exit status of the test binary in order to determine whether the test passed or failed. If we don't have that status available, we shouldn't guess arbitrarily — instead, we should omit the final "pass" or "fail" action entirely. (In practice, we nearly always DO have the final status, such as when running 'go test' or 'go tool test2json some.exe'.) Fixes #40132 Change-Id: Iae482577361a6033395fe4a05d746b980e18c3de Reviewed-on: https://go-review.googlesource.com/c/go/+/248624 Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>
Diffstat (limited to 'src/cmd/go/internal/test/test.go')
-rw-r--r--src/cmd/go/internal/test/test.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/cmd/go/internal/test/test.go b/src/cmd/go/internal/test/test.go
index 9c120e08dc..9cef8cf89c 100644
--- a/src/cmd/go/internal/test/test.go
+++ b/src/cmd/go/internal/test/test.go
@@ -1098,9 +1098,13 @@ func (c *runCache) builderRunTest(b *work.Builder, ctx context.Context, a *work.
}
var stdout io.Writer = os.Stdout
+ var err error
if testJSON {
json := test2json.NewConverter(lockedStdout{}, a.Package.ImportPath, test2json.Timestamp)
- defer json.Close()
+ defer func() {
+ json.Exited(err)
+ json.Close()
+ }()
stdout = json
}
@@ -1204,7 +1208,7 @@ func (c *runCache) builderRunTest(b *work.Builder, ctx context.Context, a *work.
}
t0 := time.Now()
- err := cmd.Start()
+ err = cmd.Start()
// This is a last-ditch deadline to detect and
// stop wedged test binaries, to keep the builders