diff options
author | Russ Cox <rsc@golang.org> | 2017-11-08 22:03:19 -0500 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2017-11-10 18:00:51 +0000 |
commit | e9d2f1eb36b7600c196474f5de5fa3afd0403c99 (patch) | |
tree | 893576f9dbca92a0cd0179f1c9fc92ce9025a1ea /src/cmd/go/internal/test/testflag.go | |
parent | 3e2dc457a1b8cecd9554c64ee0d54800d5937fc9 (diff) | |
download | go-e9d2f1eb36b7600c196474f5de5fa3afd0403c99.tar.gz go-e9d2f1eb36b7600c196474f5de5fa3afd0403c99.zip |
cmd/go: add go test -json flag
This CL finally adds one of our longest-requested cmd/go features:
a way for test-running harnesses to access test output in structured form.
In fact the structured json output is more informative than the text
output, because the output from multiple parallel tests can be
interleaved as it becomes available, instead of needing to wait for
the previous test to finish before showing any output from the
next test.
See CL 76872 for the conversion details.
Fixes #2981.
Change-Id: I749c4fc260190af9fe633437a781ec0cf56b7260
Reviewed-on: https://go-review.googlesource.com/76873
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/cmd/go/internal/test/testflag.go')
-rw-r--r-- | src/cmd/go/internal/test/testflag.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/cmd/go/internal/test/testflag.go b/src/cmd/go/internal/test/testflag.go index 4bfe6b7327..cdf43a7249 100644 --- a/src/cmd/go/internal/test/testflag.go +++ b/src/cmd/go/internal/test/testflag.go @@ -33,6 +33,7 @@ var testFlagDefn = []*cmdflag.Defn{ {Name: "covermode"}, {Name: "coverpkg"}, {Name: "exec"}, + {Name: "json", BoolVar: &testJSON}, {Name: "vet"}, // Passed to 6.out, adding a "test." prefix to the name if necessary: -v becomes -test.v. @@ -133,8 +134,11 @@ func testFlags(args []string) (packageNames, passToTest []string) { // Arguably should be handled by f.Value, but aren't. switch f.Name { // bool flags. - case "c", "i", "v", "cover": + case "c", "i", "v", "cover", "json": cmdflag.SetBool(cmd, f.BoolVar, value) + if f.Name == "json" && testJSON { + passToTest = append(passToTest, "-test.v") + } case "o": testO = value testNeedBinary = true |