Skip to content

Commit

Permalink
cmd/go: add timestamps to script test output
Browse files Browse the repository at this point in the history
Go tests don't include timestamps by default, but we would like to
have them in order to correlate builder failures with server and
network logs.

Since many of the Go tests with external network and service
dependencies are script tests for the 'go' command, logging timestamps
here adds a lot of logging value with one simple and very low-risk
change.

For #50541.
For #52490.
For #52545.
For #52851.

Change-Id: If3fa86deb4a216ec6a1abc4e6f4ee9b05030a729
Reviewed-on: https://go-review.googlesource.com/c/go/+/405714
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
  • Loading branch information
Bryan C. Mills authored and gopherbot committed May 11, 2022
1 parent 949b3e9 commit d339d08
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/cmd/go/script_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ func TestScript(t *testing.T) {
t.Run(name, func(t *testing.T) {
t.Parallel()
ctx, cancel := context.WithCancel(ctx)
defer cancel()
ts := &testScript{
t: t,
ctx: ctx,
Expand All @@ -94,7 +95,6 @@ func TestScript(t *testing.T) {
defer removeAll(ts.workdir)
}
ts.run()
cancel()
})
}
}
Expand Down Expand Up @@ -210,6 +210,9 @@ func (ts *testScript) setup() {
ts.envMap[kv[:i]] = kv[i+1:]
}
}

fmt.Fprintf(&ts.log, "# (%s)\n", time.Now().UTC().Format(time.RFC3339))
ts.mark = ts.log.Len()
}

// goVersion returns the current Go version.
Expand Down

0 comments on commit d339d08

Please sign in to comment.