aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitri Shuralyov <dmitshur@golang.org>2023-07-21 13:49:06 -0400
committerGopher Robot <gobot@golang.org>2023-07-28 17:57:22 +0000
commit6df6e61cbbb1c3e002986ce91ee5f5d5d7e00c86 (patch)
tree6766bed8147e16b247aef5233399cd6ae7b1188b
parentb25266c58debb831cd880a7372b197466e75b833 (diff)
downloadgo-6df6e61cbbb1c3e002986ce91ee5f5d5d7e00c86.tar.gz
go-6df6e61cbbb1c3e002986ce91ee5f5d5d7e00c86.zip
[release-branch.go1.21] cmd/dist: handle -json flag in runPending (minimal)
The -json flag is new to Go 1.21, but missed skips in runPending. This CL adds minimal code to fix that. CL 512115 cleans up a bit. For #37486. Fixes #61557. Change-Id: I53e426c9a5585b2703f0ff6661a0470e1993f960 Reviewed-on: https://go-review.googlesource.com/c/go/+/513761 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
-rw-r--r--src/cmd/dist/test.go27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/cmd/dist/test.go b/src/cmd/dist/test.go
index 329a410fea..36a20e8b2a 100644
--- a/src/cmd/dist/test.go
+++ b/src/cmd/dist/test.go
@@ -91,6 +91,29 @@ type work struct {
end chan bool
}
+// printSkip prints a skip message for all of work.
+func (w *work) printSkip(t *tester, msg string) {
+ if t.json {
+ type event struct {
+ Time time.Time
+ Action string
+ Package string
+ Output string `json:",omitempty"`
+ }
+ enc := json.NewEncoder(&w.out)
+ ev := event{Time: time.Now(), Package: w.dt.name, Action: "start"}
+ enc.Encode(ev)
+ ev.Action = "output"
+ ev.Output = msg
+ enc.Encode(ev)
+ ev.Action = "skip"
+ ev.Output = ""
+ enc.Encode(ev)
+ return
+ }
+ fmt.Fprintln(&w.out, msg)
+}
+
// A distTest is a test run by dist test.
// Each test has a unique name and belongs to a group (heading)
type distTest struct {
@@ -1238,7 +1261,7 @@ func (t *tester) runPending(nextTest *distTest) {
go func(w *work) {
if !<-w.start {
timelog("skip", w.dt.name)
- w.out.WriteString("skipped due to earlier error\n")
+ w.printSkip(t, "skipped due to earlier error")
} else {
timelog("start", w.dt.name)
w.err = w.cmd.Run()
@@ -1249,7 +1272,7 @@ func (t *tester) runPending(nextTest *distTest) {
if isUnsupportedVMASize(w) {
timelog("skip", w.dt.name)
w.out.Reset()
- w.out.WriteString("skipped due to unsupported VMA\n")
+ w.printSkip(t, "skipped due to unsupported VMA")
w.err = nil
}
}