[go] cmd/go: cache coverage profile with tests

201 views
Skip to first unread message

Gerrit Dou (Gerrit)

unread,
Jan 6, 2022, 6:15:36 PM1/6/22
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Gerrit Dou has uploaded this change for review.

View Change

cmd/go: cache coverage profile with tests

This CL stores coverage profile data in the GOCACHE under the
'coverprofile' subkey alongside tests. This makes tests which use
coverage profiles cacheable. The values of the -coverprofile and
-outputdir flags are not included in the cache key to allow cached
profile data to be written to any output file.

Fixes #23565

Change-Id: Ifcf8999fa6de917ea20a52a3e3293d9ded0bf080
GitHub-Last-Rev: 9ada3115023e79fe43311b684fef21ebcc63e1a0
GitHub-Pull-Request: golang/go#50483
---
M src/cmd/go/internal/test/test.go
M src/cmd/go/internal/test/cover.go
M src/cmd/go/go_test.go
M src/cmd/go/alldocs.go
4 files changed, 154 insertions(+), 17 deletions(-)

diff --git a/src/cmd/go/alldocs.go b/src/cmd/go/alldocs.go
index d903214..a145bc1 100644
--- a/src/cmd/go/alldocs.go
+++ b/src/cmd/go/alldocs.go
@@ -1681,8 +1681,9 @@
//
// The rule for a match in the cache is that the run involves the same
// test binary and the flags on the command line come entirely from a
-// restricted set of 'cacheable' test flags, defined as -benchtime, -cpu,
-// -list, -parallel, -run, -short, -timeout, -failfast, and -v.
+// restricted set of 'cacheable' test flags, defined as -benchtime, -cover,
+// -covermode, -coverprofile, -cpu, -list, -parallel, -run, -short, -timeout,
+// -failfast, -v, -vet and -outputdir.
// If a run of go test has any test or non-test flags outside this set,
// the result is not cached. To disable test caching, use any test flag
// or argument other than the cacheable flags. The idiomatic way to disable
diff --git a/src/cmd/go/go_test.go b/src/cmd/go/go_test.go
index 170c882..625c854 100644
--- a/src/cmd/go/go_test.go
+++ b/src/cmd/go/go_test.go
@@ -2320,6 +2320,68 @@
tg.run("test", "-cover", "-short", "math", "strings")
}

+func TestCacheCoverageProfile(t *testing.T) {
+ tooSlow(t)
+
+ if godebug.Get("gocacheverify") == "1" {
+ t.Skip("GODEBUG gocacheverify")
+ }
+
+ tg := testgo(t)
+ defer tg.cleanup()
+ tg.parallel()
+ tg.setenv("GOPATH", filepath.Join(tg.pwd(), "testdata"))
+ tg.makeTempdir()
+ tg.setenv("GOCACHE", tg.path("c1"))
+
+ // checkProfile asserts that the given profile contains the given mode
+ // and coverage lines for all given files.
+ checkProfile := func(t *testing.T, profile, mode string, files ...string) {
+ t.Helper()
+ if out, err := os.ReadFile(profile); err != nil {
+ t.Fatalf("failed to open coverprofile: %v", err)
+ } else {
+ if n := bytes.Count(out, []byte("mode: "+mode)); n != 1 {
+ if n == 0 {
+ t.Fatalf("missing mode: %s", mode)
+ } else {
+ t.Fatalf("too many mode: %s", mode)
+ }
+ }
+ for _, fname := range files {
+ if !bytes.Contains(out, []byte(fname)) {
+ t.Fatalf("missing file in coverprofile: %s", fname)
+ }
+ }
+ }
+ }
+
+ tg.run("test", "-coverprofile="+tg.path("cover.out"), "-x", "-v", "-short", "strings")
+ tg.grepStdout(`ok \t`, "expected strings test to succeed")
+ checkProfile(t, tg.path("cover.out"), "set", "strings/strings.go")
+ // Repeat commands should use the cache.
+ tg.run("test", "-coverprofile="+tg.path("cover.out"), "-x", "-v", "-short", "strings")
+ tg.grepStdout(`ok \tstrings\t\(cached\)`, "expected strings test results to be cached")
+ checkProfile(t, tg.path("cover.out"), "set", "strings/strings.go")
+ // Cover profiles should be cached independently. Since strings is already cached,
+ // only math should need to run.
+ tg.run("test", "-coverprofile="+tg.path("cover.out"), "-x", "-v", "-short", "strings", "math")
+ tg.grepStdout(`ok \tstrings\t\(cached\)`, "expected strings test results to be cached")
+ checkProfile(t, tg.path("cover.out"), "set", "strings/strings.go", "math/mod.go")
+ // A new -coverprofile file should use the cached coverage profile contents.
+ tg.run("test", "-coverprofile="+tg.path("cover1.out"), "-x", "-v", "-short", "strings")
+ tg.grepStdout(`ok \tstrings\t\(cached\)`, "expected cached strings test results to be used regardless of -coverprofile")
+ checkProfile(t, tg.path("cover1.out"), "set", "strings/strings.go")
+ // A new -covermode should not use the cached coverage profile, since the covermode changes
+ // the profile output.
+ tg.run("test", "-covermode=count", "-coverprofile="+tg.path("cover.out"), "-x", "-v", "-short", "strings")
+ tg.grepStdoutNot(`ok \tstrings\t\(cached\)`, "cached strings test results should not be used with different -covermode")
+ // A new -coverpkg should not use the cached coverage profile, since the coverpkg changes
+ // the profile output.
+ tg.run("test", "-coverpkg=math", "-coverprofile="+tg.path("cover.out"), "-x", "-v", "-short", "strings")
+ tg.grepStdoutNot(`ok \tstrings\t\(cached\)`, "cached strings test results should not be used with different -coverpkg")
+}
+
func TestIssue22588(t *testing.T) {
// Don't get confused by stderr coming from tools.
tg := testgo(t)
diff --git a/src/cmd/go/internal/test/cover.go b/src/cmd/go/internal/test/cover.go
index 657d22a..6be2e41 100644
--- a/src/cmd/go/internal/test/cover.go
+++ b/src/cmd/go/internal/test/cover.go
@@ -6,6 +6,7 @@

import (
"cmd/go/internal/base"
+ "errors"
"fmt"
"io"
"os"
@@ -43,10 +44,9 @@
}

// mergeCoverProfile merges file into the profile stored in testCoverProfile.
-// It prints any errors it encounters to ew.
-func mergeCoverProfile(ew io.Writer, file string) {
+func mergeCoverProfile(file string) error {
if coverMerge.f == nil {
- return
+ return nil
}
coverMerge.Lock()
defer coverMerge.Unlock()
@@ -56,22 +56,22 @@
r, err := os.Open(file)
if err != nil {
// Test did not create profile, which is OK.
- return
+ return nil
}
defer r.Close()

n, err := io.ReadFull(r, buf)
if n == 0 {
- return
+ return nil
}
if err != nil || string(buf) != expect {
- fmt.Fprintf(ew, "error: test wrote malformed coverage profile.\n")
- return
+ return errMalformedCoverProfile
}
_, err = io.Copy(coverMerge.f, r)
if err != nil {
- fmt.Fprintf(ew, "error: saving coverage profile: %v\n", err)
+ return fmt.Errorf("saving coverage profile: %v\n", err)
}
+ return nil
}

func closeCoverProfile() {
@@ -82,3 +82,5 @@
base.Errorf("closing coverage profile: %v", err)
}
}
+
+var errMalformedCoverProfile = errors.New("test wrote malformed coverage profile")
diff --git a/src/cmd/go/internal/test/test.go b/src/cmd/go/internal/test/test.go
index 50e6d52..2d34a73 100644
--- a/src/cmd/go/internal/test/test.go
+++ b/src/cmd/go/internal/test/test.go
@@ -123,8 +123,9 @@

The rule for a match in the cache is that the run involves the same
test binary and the flags on the command line come entirely from a
-restricted set of 'cacheable' test flags, defined as -benchtime, -cpu,
--list, -parallel, -run, -short, -timeout, -failfast, and -v.
+restricted set of 'cacheable' test flags, defined as -benchtime, -cover,
+-covermode, -coverprofile, -cpu, -list, -parallel, -run, -short, -timeout,
+-failfast, -v, -vet and -outputdir.
If a run of go test has any test or non-test flags outside this set,
the result is not cached. To disable test caching, use any test flag
or argument other than the cacheable flags. The idiomatic way to disable
@@ -1336,11 +1337,13 @@
}
args := str.StringList(execCmd, a.Deps[0].BuiltTarget(), testlogArg, panicArg, fuzzArg, testArgs)

+ var coverprofileFile string
if testCoverProfile != "" {
// Write coverage to temporary profile, for merging later.
+ coverprofileFile = a.Objdir + "_cover_.out"
for i, arg := range args {
if strings.HasPrefix(arg, "-test.coverprofile=") {
- args[i] = "-test.coverprofile=" + a.Objdir + "_cover_.out"
+ args[i] = "-test.coverprofile=" + coverprofileFile
}
}
}
@@ -1417,7 +1420,9 @@
a.TestOutput = &buf
t := fmt.Sprintf("%.3fs", time.Since(t0).Seconds())

- mergeCoverProfile(cmd.Stdout, a.Objdir+"_cover_.out")
+ if coverErr := mergeCoverProfile(coverprofileFile); coverErr != nil {
+ fmt.Fprintf(cmd.Stdout, "error: %v\n", coverErr)
+ }

if err == nil {
norun := ""
@@ -1439,7 +1444,7 @@
cmd.Stdout.Write([]byte("\n"))
}
fmt.Fprintf(cmd.Stdout, "ok \t%s\t%s%s%s\n", a.Package.ImportPath, t, coveragePercentage(out), norun)
- c.saveOutput(a)
+ c.saveOutput(a, coverprofileFile)
} else {
base.SetExitStatus(1)
if len(out) == 0 {
@@ -1520,7 +1525,14 @@
// Note that this list is documented above,
// so if you add to this list, update the docs too.
cacheArgs = append(cacheArgs, arg)
-
+ case "-test.coverprofile",
+ "-test.outputdir":
+ // The -coverprofile and -outputdir arguments are cacheable but
+ // only change where profiles are written. They don't change the
+ // profile contents, so they aren't added to the cacheArgs. This
+ // allows cached coverage profiles to be written to different files.
+ // Note that this list is documented above,
+ // so if you add to this list, update the docs too.
default:
// nothing else is cacheable
if cache.DebugTest {
@@ -1640,6 +1652,26 @@
j++
}
c.buf.Write(data[j:])
+
+ // Write coverage data to profile.
+ if testCover {
+ // coverprofile cache expiration time should be coupled with the test data above, so
+ // the entry can be ignored.
+ f, _, err := cache.Default().GetFile(testCoverProfileKey(testID, testInputsID))
+ if err != nil {
+ if cache.DebugTest {
+ fmt.Fprintf(os.Stderr, "testcache: %s: test coverage profile not found: %v\n", a.Package.ImportPath, err)
+ }
+ return false
+ }
+ if err := mergeCoverProfile(f); err != nil {
+ if cache.DebugTest {
+ fmt.Fprintf(os.Stderr, "testcache: %s: test coverage profile not merged: %v\n", a.Package.ImportPath, err)
+ }
+ return false
+ }
+ }
+
return true
}

@@ -1788,7 +1820,12 @@
return cache.Subkey(testID, fmt.Sprintf("inputs:%x", testInputsID))
}

-func (c *runCache) saveOutput(a *work.Action) {
+// testCoverProfileKey returns the "coverprofile" cache key for the pair (testID, testInputsID).
+func testCoverProfileKey(testID, testInputsID cache.ActionID) cache.ActionID {
+ return cache.Subkey(testAndInputKey(testID, testInputsID), "coverprofile")
+}
+
+func (c *runCache) saveOutput(a *work.Action, coverprofileFile string) {
if c.id1 == (cache.ActionID{}) && c.id2 == (cache.ActionID{}) {
return
}
@@ -1809,12 +1846,27 @@
if err != nil {
return
}
+ saveCoverProfile := func(testID cache.ActionID) {
+ if coverprofileFile == "" {
+ return
+ }
+ coverprof, err := os.Open(coverprofileFile)
+ if err != nil {
+ if cache.DebugTest {
+ fmt.Fprintf(os.Stderr, "testcache: %s: failed to open temporary coverprofile file: %s", a.Package.ImportPath, err)
+ }
+ return
+ }
+ defer coverprof.Close()
+ cache.Default().Put(testCoverProfileKey(testID, testInputsID), coverprof)
+ }
if c.id1 != (cache.ActionID{}) {
if cache.DebugTest {
fmt.Fprintf(os.Stderr, "testcache: %s: save test ID %x => input ID %x => %x\n", a.Package.ImportPath, c.id1, testInputsID, testAndInputKey(c.id1, testInputsID))
}
cache.Default().PutNoVerify(c.id1, bytes.NewReader(testlog))
cache.Default().PutNoVerify(testAndInputKey(c.id1, testInputsID), bytes.NewReader(a.TestOutput.Bytes()))
+ saveCoverProfile(c.id1)
}
if c.id2 != (cache.ActionID{}) {
if cache.DebugTest {
@@ -1822,6 +1874,7 @@
}
cache.Default().PutNoVerify(c.id2, bytes.NewReader(testlog))
cache.Default().PutNoVerify(testAndInputKey(c.id2, testInputsID), bytes.NewReader(a.TestOutput.Bytes()))
+ saveCoverProfile(c.id2)
}
}


To view, visit change 376134. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: Ifcf8999fa6de917ea20a52a3e3293d9ded0bf080
Gerrit-Change-Number: 376134
Gerrit-PatchSet: 1
Gerrit-Owner: Gerrit Dou <letsus...@gmail.com>
Gerrit-MessageType: newchange

Gopher Robot (Gerrit)

unread,
Jan 6, 2022, 6:16:12 PM1/6/22
to Gerrit Dou, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Congratulations on opening your first change. Thank you for your contribution!

Next steps:
A maintainer will review your change and provide feedback. See
https://golang.org/doc/contribute.html#review for more info and tips to get your
patch through code review.

Most changes in the Go project go through a few rounds of revision. This can be
surprising to people new to the project. The careful, iterative review process
is our way of helping mentor contributors and ensuring that their contributions
have a lasting impact.

During May-July and Nov-Jan the Go project is in a code freeze, during which
little code gets reviewed or merged. If a reviewer responds with a comment like
R=go1.11 or adds a tag like "wait-release", it means that this CL will be
reviewed as part of the next development cycle. See https://golang.org/s/release
for more details.

View Change

    To view, visit change 376134. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: Ifcf8999fa6de917ea20a52a3e3293d9ded0bf080
    Gerrit-Change-Number: 376134
    Gerrit-PatchSet: 1
    Gerrit-Owner: Gerrit Dou <letsus...@gmail.com>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-Comment-Date: Thu, 06 Jan 2022 23:16:06 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: No
    Gerrit-MessageType: comment

    James Roberts (Gerrit)

    unread,
    Apr 9, 2022, 11:25:06 PM4/9/22
    to Gerrit Bot, goph...@pubsubhelper.golang.org, Bryan Mills, Michael Matloob, Russ Cox, Ian Lance Taylor, Gopher Robot, golang-co...@googlegroups.com

    Attention is currently required from: Bryan Mills, Michael Matloob.

    View Change

    1 comment:

    • Patchset:

      • Patch Set #1:

        Hi all. I sent this during the 1.18 release freeze and it may have fallen out of view. I just wanted to note that I'm still active to maintain this CL and respond to feedback. I hope this can be included in 1.19. Please let me know if there's anything else I can do to help move this forward. Thanks!

    To view, visit change 376134. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: Ifcf8999fa6de917ea20a52a3e3293d9ded0bf080
    Gerrit-Change-Number: 376134
    Gerrit-PatchSet: 1
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
    Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-CC: Ian Lance Taylor <ia...@golang.org>
    Gerrit-CC: James Roberts <jprobe...@gmail.com>
    Gerrit-CC: Russ Cox <r...@golang.org>
    Gerrit-Attention: Bryan Mills <bcm...@google.com>
    Gerrit-Attention: Michael Matloob <mat...@golang.org>
    Gerrit-Comment-Date: Fri, 08 Apr 2022 00:04:27 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Gerrit-MessageType: comment

    Than McIntosh (Gerrit)

    unread,
    Jun 16, 2022, 8:28:41 AM6/16/22
    to Gerrit Bot, James Roberts, goph...@pubsubhelper.golang.org, Bryan Mills, Michael Matloob, Russ Cox, Ian Lance Taylor, Gopher Robot, golang-co...@googlegroups.com

    Attention is currently required from: Bryan Mills, Michael Matloob.

    View Change

    3 comments:

    • Patchset:

      • Patch Set #1:

        Seems OK to me overall (disclaimer: I am not a "go" command expert)

    • File src/cmd/go/internal/test/test.go:

      • Patch Set #1, Line 1424: fmt.Fprintf(cmd.Stdout, "error: %v\n", coverErr)

        This issues the error, but doesn't seem to cause the test to fail. If this WAI?

      • Patch Set #1, Line 1860: defer coverprof.Close()

        Unless I am missing something it seems as though it would be better to avoid using defer here and to an explicit close after the cache put, so that you can check for errors.

    To view, visit change 376134. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: Ifcf8999fa6de917ea20a52a3e3293d9ded0bf080
    Gerrit-Change-Number: 376134
    Gerrit-PatchSet: 1
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
    Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-CC: Ian Lance Taylor <ia...@golang.org>
    Gerrit-CC: James Roberts <jprobe...@gmail.com>
    Gerrit-CC: Russ Cox <r...@golang.org>
    Gerrit-CC: Than McIntosh <th...@google.com>
    Gerrit-Attention: Bryan Mills <bcm...@google.com>
    Gerrit-Attention: Michael Matloob <mat...@golang.org>
    Gerrit-Comment-Date: Thu, 16 Jun 2022 12:28:36 +0000

    Gerrit Bot (Gerrit)

    unread,
    Jun 20, 2022, 9:05:13 PM6/20/22
    to James Roberts, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

    Attention is currently required from: Bryan Mills, Michael Matloob.

    Gerrit Bot uploaded patch set #2 to this change.

    View Change

    cmd/go: cache coverage profile with tests

    This CL stores coverage profile data in the GOCACHE under the
    'coverprofile' subkey alongside tests. This makes tests which use
    coverage profiles cacheable. The values of the -coverprofile and
    -outputdir flags are not included in the cache key to allow cached
    profile data to be written to any output file.

    Fixes #23565

    Change-Id: Ifcf8999fa6de917ea20a52a3e3293d9ded0bf080
    GitHub-Last-Rev: de26ed4fd02f850a7ce9f970d2b57323bbe1c7e8
    GitHub-Pull-Request: golang/go#50483
    ---
    M src/cmd/go/alldocs.go
    M src/cmd/go/go_test.go
    M src/cmd/go/internal/test/cover.go
    M src/cmd/go/internal/test/test.go
    4 files changed, 160 insertions(+), 17 deletions(-)

    To view, visit change 376134. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: Ifcf8999fa6de917ea20a52a3e3293d9ded0bf080
    Gerrit-Change-Number: 376134
    Gerrit-PatchSet: 2
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
    Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-CC: Ian Lance Taylor <ia...@golang.org>
    Gerrit-CC: James Roberts <jprobe...@gmail.com>
    Gerrit-CC: Russ Cox <r...@golang.org>
    Gerrit-CC: Than McIntosh <th...@google.com>
    Gerrit-Attention: Bryan Mills <bcm...@google.com>
    Gerrit-Attention: Michael Matloob <mat...@golang.org>
    Gerrit-MessageType: newpatchset

    James Roberts (Gerrit)

    unread,
    Jun 20, 2022, 9:47:49 PM6/20/22
    to Gerrit Bot, goph...@pubsubhelper.golang.org, Than McIntosh, Bryan Mills, Michael Matloob, Russ Cox, Ian Lance Taylor, Gopher Robot, golang-co...@googlegroups.com

    Attention is currently required from: Bryan Mills, Michael Matloob.

    View Change

    3 comments:

    • Patchset:

      • Patch Set #1:

        Seems OK to me overall (disclaimer: I am not a "go" command expert)

      • Thank you for your feedback!

    • File src/cmd/go/internal/test/test.go:

      • This issues the error, but doesn't seem to cause the test to fail. […]

        I'm not sure what the intended behavior is here. I can say that this should be maintaining the previous behavior.

        This was a great point to call out and I hadn't considered it before. However, I don't think I'm in a good position to make the decision to change the behavior in this CL. I generally agree that failures to write coverage profile data should fail the test run though.

        I'll wait for one of the "go" command experts to weigh in. If others agree with a change to fail tests here, I can dig a little deeper and file a new issue to correct the behavior. I think this can be changed independently of caching coverage profiles.

      • Unless I am missing something it seems as though it would be better to avoid using defer here and to […]

        I don't think you're missing anything. This was my mistake.

        I've updated the code to log to os.Stderr , following the previous existing behavior. I'm not completely certain that this is the correct decision, so I'll leave the comment unresolved for another reviewer to confirm.

    To view, visit change 376134. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: Ifcf8999fa6de917ea20a52a3e3293d9ded0bf080
    Gerrit-Change-Number: 376134
    Gerrit-PatchSet: 2
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
    Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-CC: Ian Lance Taylor <ia...@golang.org>
    Gerrit-CC: James Roberts <jprobe...@gmail.com>
    Gerrit-CC: Russ Cox <r...@golang.org>
    Gerrit-CC: Than McIntosh <th...@google.com>
    Gerrit-Attention: Bryan Mills <bcm...@google.com>
    Gerrit-Attention: Michael Matloob <mat...@golang.org>
    Gerrit-Comment-Date: Tue, 21 Jun 2022 01:47:44 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Than McIntosh <th...@google.com>
    Gerrit-MessageType: comment

    Bryan Mills (Gerrit)

    unread,
    Jun 22, 2022, 4:47:30 PM6/22/22
    to Gerrit Bot, James Roberts, goph...@pubsubhelper.golang.org, Than McIntosh, Bryan Mills, Michael Matloob, Russ Cox, Ian Lance Taylor, Gopher Robot, golang-co...@googlegroups.com

    Attention is currently required from: James Roberts, Michael Matloob, Than McIntosh.

    View Change

    5 comments:

    • Patchset:

      • Patch Set #1:

        Hi all. I sent this during the 1.18 release freeze and it may have fallen out of view. […]

        Sorry we missed this during the 1.19 cycle. Unfortunately I think at this point it probably needs to wait for 1.20 — test caching in `cmd/go` is already somewhat buggy (see, for example, #49267) and I'd prefer to avoid the risk of exposing additional bugs (or further exposing that bug), especially at this point in the cycle.

        Ideally we should probably fix #49267 (and hopefully simplify the test-caching logic) before adding more test-caching complexity...

    • File src/cmd/go/internal/test/test.go:

      • I'm not sure what the intended behavior is here. […]

        I agree that this looks suspicious and I also agree that it can be fixed independently — but at least a TODO (and/or a fix in a CL prior to this one) would help clarify what's going on.

    • File src/cmd/go/internal/test/test.go:

      • 		// coverprofile cache expiration time should be coupled with the test data above, so

      • 		// the entry can be ignored.

      • I'm having some trouble interpreting this comment — could you add a bit more detail?

        (Which test data above? Which entry can be ignored?)

      • Patch Set #2, Line 1672:

      • 		if err := mergeCoverProfile(f); err != nil {

      • 			if cache.DebugTest {


      • fmt.Fprintf(os.Stderr, "testcache: %s: test coverage profile not merged: %v\n", a.Package.ImportPath, err)
        }

      • 			return false
        }

        If `mergeCoverProfile` fails partway through a merge operation, does it back out the incremental writes?

        If not, I think there is some risk of producing an invalid coverage profile if (for example) part of the coverage profile is merged before a read error occurs. (Probably a failure here needs to do more than just avoid the cached result.)

        I wonder — would it make sense to move the call to `mergeCoverProfile` to somewhere on the caller side, so that we are completely committed to using the cached result before we determine whether there is an error in merging?

      • Patch Set #2, Line 1861:

        	if coverprof != nil {
        defer func() {
        if err := coverprof.Close(); err != nil && cache.DebugTest {
        fmt.Fprintf(os.Stderr, "testcache: %s: closing temporary coverprofile: %v", a.Package.ImportPath, err)
        }
        }()
        }
        saveCoverProfile := func(testID cache.ActionID) {
        if coverprof == nil {
        return
        }
        cache.Default().Put(testCoverProfileKey(testID, testInputsID), coverprof)
        }

        (nit) It seems like we could simplify this a bit by consolidating the failure logic into the `saveCoverProfile` variable:


        ```
        saveCoverProfile := func(testID cache.ActionID) {}
        if coverprofileFile != "" {
        coverprof, err = os.Open(coverprofileFile)
        if err == nil {
        saveCoverProfile = func(testID cache.ActionID) {
        cache.Default().Put(…)
        }
        defer func() {

        }()
        } else if cache.DebugTest {
        fmt.Fprintf(os.Stderr, "testcache: %s: failed to open temporary coverprofile: %s", a.Package.ImportPath, err)
        }
        }
        ```

    To view, visit change 376134. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: Ifcf8999fa6de917ea20a52a3e3293d9ded0bf080
    Gerrit-Change-Number: 376134
    Gerrit-PatchSet: 2
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
    Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-CC: Ian Lance Taylor <ia...@golang.org>
    Gerrit-CC: James Roberts <jprobe...@gmail.com>
    Gerrit-CC: Russ Cox <r...@golang.org>
    Gerrit-CC: Than McIntosh <th...@google.com>
    Gerrit-Attention: James Roberts <jprobe...@gmail.com>
    Gerrit-Attention: Than McIntosh <th...@google.com>
    Gerrit-Attention: Michael Matloob <mat...@golang.org>
    Gerrit-Comment-Date: Wed, 22 Jun 2022 20:47:25 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: James Roberts <jprobe...@gmail.com>

    Gerrit Bot (Gerrit)

    unread,
    Aug 9, 2022, 9:25:00 PM8/9/22
    to James Roberts, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

    Attention is currently required from: James Roberts, Michael Matloob, Than McIntosh.

    Gerrit Bot uploaded patch set #3 to this change.

    View Change

    cmd/go: cache coverage profile with tests

    This CL stores coverage profile data in the GOCACHE under the
    'coverprofile' subkey alongside tests. This makes tests which use
    coverage profiles cacheable. The values of the -coverprofile and
    -outputdir flags are not included in the cache key to allow cached
    profile data to be written to any output file.

    Fixes #23565

    Change-Id: Ifcf8999fa6de917ea20a52a3e3293d9ded0bf080
    GitHub-Last-Rev: 3e83a0077cde55a86430fd0a0123e1cdfa4c490e

    GitHub-Pull-Request: golang/go#50483
    ---
    M src/cmd/go/alldocs.go
    M src/cmd/go/go_test.go
    M src/cmd/go/internal/test/cover.go
    M src/cmd/go/internal/test/test.go
    4 files changed, 159 insertions(+), 17 deletions(-)

    To view, visit change 376134. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: Ifcf8999fa6de917ea20a52a3e3293d9ded0bf080
    Gerrit-Change-Number: 376134
    Gerrit-PatchSet: 3
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
    Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-CC: Ian Lance Taylor <ia...@golang.org>
    Gerrit-CC: James Roberts <jprobe...@gmail.com>
    Gerrit-CC: Russ Cox <r...@golang.org>
    Gerrit-CC: Than McIntosh <th...@google.com>
    Gerrit-Attention: James Roberts <jprobe...@gmail.com>
    Gerrit-Attention: Than McIntosh <th...@google.com>
    Gerrit-Attention: Michael Matloob <mat...@golang.org>
    Gerrit-MessageType: newpatchset

    Gerrit Bot (Gerrit)

    unread,
    Aug 9, 2022, 9:54:23 PM8/9/22
    to James Roberts, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

    Attention is currently required from: James Roberts, Michael Matloob, Than McIntosh.

    Gerrit Bot uploaded patch set #4 to this change.

    View Change

    cmd/go: cache coverage profile with tests

    This CL stores coverage profile data in the GOCACHE under the
    'coverprofile' subkey alongside tests. This makes tests which use
    coverage profiles cacheable. The values of the -coverprofile and
    -outputdir flags are not included in the cache key to allow cached
    profile data to be written to any output file.

    Fixes #23565

    Change-Id: Ifcf8999fa6de917ea20a52a3e3293d9ded0bf080
    GitHub-Last-Rev: 6c1281ad6484bbd21620f8939574de89d705337b

    GitHub-Pull-Request: golang/go#50483
    ---
    M src/cmd/go/alldocs.go
    M src/cmd/go/go_test.go
    M src/cmd/go/internal/test/cover.go
    M src/cmd/go/internal/test/test.go
    4 files changed, 173 insertions(+), 20 deletions(-)

    To view, visit change 376134. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: Ifcf8999fa6de917ea20a52a3e3293d9ded0bf080
    Gerrit-Change-Number: 376134
    Gerrit-PatchSet: 4

    James Roberts (Gerrit)

    unread,
    Aug 9, 2022, 10:04:42 PM8/9/22
    to Gerrit Bot, goph...@pubsubhelper.golang.org, Than McIntosh, Bryan Mills, Michael Matloob, Russ Cox, Ian Lance Taylor, Gopher Robot, golang-co...@googlegroups.com

    Attention is currently required from: Bryan Mills, Michael Matloob, Than McIntosh.

    View Change

    5 comments:

    • Patchset:

      • Patch Set #1:

        Sorry we missed this during the 1.19 cycle. […]

        Sorry for taking so long to respond. Now that the tree has reopened for 1.20, I'll be sure to stay more active.

        Thank you for all the thoughtful feedback in your review!

        I took a look at #49267 and left a comment to try to help move that issue forward as best I could.

        While I understand the reluctance to add complexity to a somewhat buggy system, I hope this change won't be blocked. The company I work for mandates test coverage data for all our software and it's painful to see how much compute is wasted in CI pipelines by running the same tests on unchanged packages.

    • File src/cmd/go/internal/test/test.go:

      • I agree that this looks suspicious and I also agree that it can be fixed independently — but at leas […]

        I've added a TODO comment and will open an issue to decide on the change. Happy to submit a CL once we know the intended behavior.

    • File src/cmd/go/internal/test/test.go:

      • Patch Set #2, Line 1663:

        		// coverprofile cache expiration time should be coupled with the test data above, so
        // the entry can be ignored.

      • I'm having some trouble interpreting this comment — could you add a bit more detail? […]

        I've updated the comment. The "test data above" and "entry" are referring to the condition: `if entry.Time.Before(testCacheExpire)` on line 1631. I'm not sure how else to reference this check.

      • Patch Set #2, Line 1672:

        		if err := mergeCoverProfile(f); err != nil {
        if cache.DebugTest {
        fmt.Fprintf(os.Stderr, "testcache: %s: test coverage profile not merged: %v\n", a.Package.ImportPath, err)
        }
        return false
        }

      • If `mergeCoverProfile` fails partway through a merge operation, does it back out the incremental wri […]

        There isn't any logic to back out partial writes from `io.Copy` on error during merge. This isn't something I'd considered, thanks for pointing it out. I've updated the patch to Seek to the last known good write on merge failure and Truncate when closing the merged file. It's a best-effort attempt that's meant to follow the behavior of `Cache.copyFile`.


      • > I wonder — would it make sense to move the call to `mergeCoverProfile` to somewhere on the caller side, so that we are completely committed to using the cached result before we determine whether there is an error in merging?

      • I may be misunderstanding your idea here. I don't see how we can move the call to `mergeCoverProfile` to the caller, since it's abstracted as a `work.Action.TryCache` function. I also thought that we've already committed to using the cached result at this point, because the next line after the condition returns `true` from the `TryCache` function.

        Hopefully the update to make `mergeCoverProfile` back out incremental writes on partial failure resolves this issue as well. If not, I may need an alternative explanation of what you have in mind.

      • Patch Set #2, Line 1861:

        	if coverprof != nil {
        defer func() {
        if err := coverprof.Close(); err != nil && cache.DebugTest {
        fmt.Fprintf(os.Stderr, "testcache: %s: closing temporary coverprofile: %v", a.Package.ImportPath, err)
        }
        }()
        }
        saveCoverProfile := func(testID cache.ActionID) {
        if coverprof == nil {
        return
        }
        cache.Default().Put(testCoverProfileKey(testID, testInputsID), coverprof)
        }

      • (nit) It seems like we could simplify this a bit by consolidating the failure logic into the `saveCo […]

        Ack

    To view, visit change 376134. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: Ifcf8999fa6de917ea20a52a3e3293d9ded0bf080
    Gerrit-Change-Number: 376134
    Gerrit-PatchSet: 4
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
    Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-CC: Ian Lance Taylor <ia...@golang.org>
    Gerrit-CC: James Roberts <jprobe...@gmail.com>
    Gerrit-CC: Russ Cox <r...@golang.org>
    Gerrit-CC: Than McIntosh <th...@google.com>
    Gerrit-Attention: Bryan Mills <bcm...@google.com>
    Gerrit-Attention: Than McIntosh <th...@google.com>
    Gerrit-Attention: Michael Matloob <mat...@golang.org>
    Gerrit-Comment-Date: Wed, 10 Aug 2022 02:04:38 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Bryan Mills <bcm...@google.com>

    Bryan Mills (Gerrit)

    unread,
    Oct 5, 2022, 5:12:12 PM10/5/22
    to Gerrit Bot, James Roberts, goph...@pubsubhelper.golang.org, Than McIntosh, Bryan Mills, Michael Matloob, Russ Cox, Ian Lance Taylor, Gopher Robot, golang-co...@googlegroups.com

    Attention is currently required from: Michael Matloob, Than McIntosh.

    View Change

    1 comment:

    • Patchset:

      • Patch Set #4:

        The major coverage changes for 1.20 have landed — could you rebase this change and see if it is still ready to move forward?

    To view, visit change 376134. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: Ifcf8999fa6de917ea20a52a3e3293d9ded0bf080
    Gerrit-Change-Number: 376134
    Gerrit-PatchSet: 4
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
    Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-CC: Ian Lance Taylor <ia...@golang.org>
    Gerrit-CC: James Roberts <jprobe...@gmail.com>
    Gerrit-CC: Russ Cox <r...@golang.org>
    Gerrit-CC: Than McIntosh <th...@google.com>
    Gerrit-Attention: Than McIntosh <th...@google.com>
    Gerrit-Attention: Michael Matloob <mat...@golang.org>
    Gerrit-Comment-Date: Wed, 05 Oct 2022 21:12:06 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Gerrit-MessageType: comment

    Gerrit Bot (Gerrit)

    unread,
    Oct 16, 2022, 8:34:54 PM10/16/22
    to James Roberts, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

    Attention is currently required from: Michael Matloob, Than McIntosh.

    Gerrit Bot uploaded patch set #5 to this change.

    View Change

    cmd/go: cache coverage profile with tests

    This CL stores coverage profile data in the GOCACHE under the
    'coverprofile' subkey alongside tests. This makes tests which use
    coverage profiles cacheable. The values of the -coverprofile and
    -outputdir flags are not included in the cache key to allow cached
    profile data to be written to any output file.

    Fixes #23565

    Change-Id: Ifcf8999fa6de917ea20a52a3e3293d9ded0bf080
    GitHub-Last-Rev: 0990fbffd0d69f2dc6622110d8623088458d28d1

    GitHub-Pull-Request: golang/go#50483
    ---
    M src/cmd/go/alldocs.go
    M src/cmd/go/go_test.go
    M src/cmd/go/internal/test/cover.go
    M src/cmd/go/internal/test/test.go
    4 files changed, 170 insertions(+), 20 deletions(-)

    To view, visit change 376134. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: Ifcf8999fa6de917ea20a52a3e3293d9ded0bf080
    Gerrit-Change-Number: 376134
    Gerrit-PatchSet: 5
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
    Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-CC: Ian Lance Taylor <ia...@golang.org>
    Gerrit-CC: James Roberts <jprobe...@gmail.com>
    Gerrit-CC: Russ Cox <r...@golang.org>
    Gerrit-CC: Than McIntosh <th...@google.com>
    Gerrit-Attention: Than McIntosh <th...@google.com>
    Gerrit-Attention: Michael Matloob <mat...@golang.org>
    Gerrit-MessageType: newpatchset

    James Roberts (Gerrit)

    unread,
    Oct 16, 2022, 8:38:50 PM10/16/22
    to Gerrit Bot, goph...@pubsubhelper.golang.org, Than McIntosh, Bryan Mills, Michael Matloob, Russ Cox, Ian Lance Taylor, Gopher Robot, golang-co...@googlegroups.com

    Attention is currently required from: Bryan Mills, Michael Matloob, Than McIntosh.

    View Change

    1 comment:

    • Patchset:

      • Patch Set #4:

        The major coverage changes for 1. […]

        Done. Thanks for the ping.

    To view, visit change 376134. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: Ifcf8999fa6de917ea20a52a3e3293d9ded0bf080
    Gerrit-Change-Number: 376134
    Gerrit-PatchSet: 5
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
    Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-CC: Ian Lance Taylor <ia...@golang.org>
    Gerrit-CC: James Roberts <jprobe...@gmail.com>
    Gerrit-CC: Russ Cox <r...@golang.org>
    Gerrit-CC: Than McIntosh <th...@google.com>
    Gerrit-Attention: Bryan Mills <bcm...@google.com>
    Gerrit-Attention: Than McIntosh <th...@google.com>
    Gerrit-Attention: Michael Matloob <mat...@golang.org>
    Gerrit-Comment-Date: Mon, 17 Oct 2022 00:38:44 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Bryan Mills <bcm...@google.com>
    Gerrit-MessageType: comment

    Than McIntosh (Gerrit)

    unread,
    Oct 17, 2022, 10:06:37 AM10/17/22
    to Gerrit Bot, James Roberts, goph...@pubsubhelper.golang.org, Bryan Mills, Michael Matloob, Russ Cox, Ian Lance Taylor, Gopher Robot, golang-co...@googlegroups.com

    Attention is currently required from: Bryan Mills, Michael Matloob.

    View Change

    1 comment:

    • File src/cmd/go/internal/test/cover.go:

      • Patch Set #5, Line 70: \n

        Remove newline (Go convention is that error strings should not end with punctuation or newlines)

    To view, visit change 376134. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: Ifcf8999fa6de917ea20a52a3e3293d9ded0bf080
    Gerrit-Change-Number: 376134
    Gerrit-PatchSet: 5
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
    Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-CC: Ian Lance Taylor <ia...@golang.org>
    Gerrit-CC: James Roberts <jprobe...@gmail.com>
    Gerrit-CC: Russ Cox <r...@golang.org>
    Gerrit-CC: Than McIntosh <th...@google.com>
    Gerrit-Attention: Bryan Mills <bcm...@google.com>
    Gerrit-Attention: Michael Matloob <mat...@golang.org>
    Gerrit-Comment-Date: Mon, 17 Oct 2022 14:06:31 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Gerrit-MessageType: comment

    James Roberts (Gerrit)

    unread,
    Oct 17, 2022, 10:52:49 AM10/17/22
    to Gerrit Bot, goph...@pubsubhelper.golang.org, Than McIntosh, Bryan Mills, Michael Matloob, Russ Cox, Ian Lance Taylor, Gopher Robot, golang-co...@googlegroups.com

    Attention is currently required from: Bryan Mills, Michael Matloob.

    View Change

    1 comment:

    • File src/cmd/go/internal/test/cover.go:

      • Patch Set #5, Line 70: \n

        Remove newline (Go convention is that error strings should not end with punctuation or newlines)

      • Done. Bad port of fmt.Fprintf -> fmt.Errorf 😞 Good spot, thanks.

    To view, visit change 376134. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: Ifcf8999fa6de917ea20a52a3e3293d9ded0bf080
    Gerrit-Change-Number: 376134
    Gerrit-PatchSet: 5
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
    Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-CC: Ian Lance Taylor <ia...@golang.org>
    Gerrit-CC: James Roberts <jprobe...@gmail.com>
    Gerrit-CC: Russ Cox <r...@golang.org>
    Gerrit-CC: Than McIntosh <th...@google.com>
    Gerrit-Attention: Bryan Mills <bcm...@google.com>
    Gerrit-Attention: Michael Matloob <mat...@golang.org>
    Gerrit-Comment-Date: Mon, 17 Oct 2022 14:52:44 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No

    Gerrit Bot (Gerrit)

    unread,
    Oct 17, 2022, 10:52:53 AM10/17/22
    to James Roberts, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

    Attention is currently required from: Bryan Mills, Michael Matloob.

    Gerrit Bot uploaded patch set #6 to this change.

    View Change

    cmd/go: cache coverage profile with tests

    This CL stores coverage profile data in the GOCACHE under the
    'coverprofile' subkey alongside tests. This makes tests which use
    coverage profiles cacheable. The values of the -coverprofile and
    -outputdir flags are not included in the cache key to allow cached
    profile data to be written to any output file.

    Fixes #23565

    Change-Id: Ifcf8999fa6de917ea20a52a3e3293d9ded0bf080
    GitHub-Last-Rev: af9a74c8474f31a1812a979303c324f094fe0956

    GitHub-Pull-Request: golang/go#50483
    ---
    M src/cmd/go/alldocs.go
    M src/cmd/go/go_test.go
    M src/cmd/go/internal/test/cover.go
    M src/cmd/go/internal/test/test.go
    4 files changed, 170 insertions(+), 20 deletions(-)

    To view, visit change 376134. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: Ifcf8999fa6de917ea20a52a3e3293d9ded0bf080
    Gerrit-Change-Number: 376134
    Gerrit-PatchSet: 6
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
    Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-CC: Ian Lance Taylor <ia...@golang.org>
    Gerrit-CC: James Roberts <jprobe...@gmail.com>
    Gerrit-CC: Russ Cox <r...@golang.org>
    Gerrit-CC: Than McIntosh <th...@google.com>
    Gerrit-Attention: Bryan Mills <bcm...@google.com>
    Gerrit-Attention: Michael Matloob <mat...@golang.org>
    Gerrit-MessageType: newpatchset

    Gerrit Bot (Gerrit)

    unread,
    Jul 25, 2023, 5:15:49 PM7/25/23
    to James Roberts, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

    Attention is currently required from: Bryan Mills, Michael Matloob.

    Gerrit Bot uploaded patch set #7 to this change.

    View Change

    cmd/go: cache coverage profile with tests

    This CL stores coverage profile data in the GOCACHE under the
    'coverprofile' subkey alongside tests. This makes tests which use
    coverage profiles cacheable. The values of the -coverprofile and
    -outputdir flags are not included in the cache key to allow cached
    profile data to be written to any output file.

    Fixes #23565

    Change-Id: Ifcf8999fa6de917ea20a52a3e3293d9ded0bf080
    GitHub-Last-Rev: ace4a178499cf382b7efed63239818bac4bebc92

    GitHub-Pull-Request: golang/go#50483
    ---
    M src/cmd/go/alldocs.go
    M src/cmd/go/go_test.go
    M src/cmd/go/internal/test/cover.go
    M src/cmd/go/internal/test/test.go
    4 files changed, 151 insertions(+), 20 deletions(-)

    To view, visit change 376134. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-MessageType: newpatchset
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: Ifcf8999fa6de917ea20a52a3e3293d9ded0bf080
    Gerrit-Change-Number: 376134
    Gerrit-PatchSet: 7

    James Roberts (Gerrit)

    unread,
    Jul 25, 2023, 5:50:25 PM7/25/23
    to Gerrit Bot, goph...@pubsubhelper.golang.org, Than McIntosh, Bryan Mills, Michael Matloob, Russ Cox, Ian Lance Taylor, Gopher Robot, golang-co...@googlegroups.com

    Attention is currently required from: Bryan Mills, Michael Matloob.

    View Change

    1 comment:

    • Patchset:

      • Patch Set #7:

        I'm going to abandon this CL since I haven't made any progress on it over the last 2 release cycle. That's on me. This CL has had conflicts for over 6 months and I should have addressed them sooner. In case anyone wants to use this branch as a starting point for a future CL, I've resolved the conflicts in the latest patch set.

        From the comments:
        > test caching in cmd/go is already somewhat buggy (see, for example, [#49267](https://go.dev/issue/49267)) and I'd prefer to avoid the risk of exposing additional bugs (or further exposing that bug), especially at this point in the cycle.
        >
        > Ideally we should probably fix [#49267](https://go.dev/issue/49267) (and hopefully simplify the test-caching logic) before adding more test-caching complexity...

        I get the impression that this change won't move forward until other bugs in `cmd/go test` are fixed and I recognize that I don't have the expertise or time to resolve them. I tried to help diagnose the issue called out in the comment but it didn't seem to help.

        Since I don't feel that I can move this issue forward, I'm going to officially abandon the CL and hope that someone else can complete the task. Please feel free to work off these changes if they're useful.

        Thanks Bryan and Than for your reviews. I hope I can find another opportunity to contribute the future.

    To view, visit change 376134. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: Ifcf8999fa6de917ea20a52a3e3293d9ded0bf080
    Gerrit-Change-Number: 376134
    Gerrit-PatchSet: 7
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
    Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-CC: Ian Lance Taylor <ia...@golang.org>
    Gerrit-CC: James Roberts <jprobe...@gmail.com>
    Gerrit-CC: Russ Cox <r...@golang.org>
    Gerrit-CC: Than McIntosh <th...@google.com>
    Gerrit-Attention: Bryan Mills <bcm...@google.com>
    Gerrit-Attention: Michael Matloob <mat...@golang.org>
    Gerrit-Comment-Date: Tue, 25 Jul 2023 21:50:21 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No

    Gopher Robot (Gerrit)

    unread,
    Jul 25, 2023, 5:52:57 PM7/25/23
    to Gerrit Bot, James Roberts, goph...@pubsubhelper.golang.org, Than McIntosh, Bryan Mills, Michael Matloob, Russ Cox, Ian Lance Taylor, golang-co...@googlegroups.com

    Gopher Robot abandoned this change.

    View Change

    Abandoned GitHub PR golang/go#50483 has been closed.

    To view, visit change 376134. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-MessageType: abandon
    Reply all
    Reply to author
    Forward
    0 new messages