From a75bc4d35cdee79fbe9be040dfa18b88833add6b Mon Sep 17 00:00:00 2001 From: Ryan Currah Date: Mon, 16 Sep 2024 08:18:13 -0400 Subject: [PATCH] dont return error when no coverage info exists yet --- src/cmd/go/internal/test/test.go | 6 +++--- src/cmd/go/testdata/script/test_cache_inputs.txt | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cmd/go/internal/test/test.go b/src/cmd/go/internal/test/test.go index d2ce0225683..e8c4191fe8c 100644 --- a/src/cmd/go/internal/test/test.go +++ b/src/cmd/go/internal/test/test.go @@ -1869,7 +1869,7 @@ func (c *runCache) tryCacheWithID(b *work.Builder, a *work.Action, id string) bo f, _, err := cache.GetFile(cache.Default(), coverProfileAndInputKey(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) + fmt.Fprintf(os.Stderr, "testcache: %s: cached test result valid but cached coverage profile missing: %v\n", a.Package.ImportPath, err) } return false } @@ -2062,8 +2062,8 @@ func (c *runCache) saveOutput(a *work.Action, coverProfileFile string) { } }() } else if cache.DebugTest { - base.Errorf("failed to open temporary coverprofile: %s", err) - return + // Not indicative of a problem, as the test may not have generated a cover profile yet. + fmt.Fprintf(os.Stderr, "testcache: %s: opening temporary coverprofile: %s\n", a.Package.ImportPath, err) } } if c.id1 != (cache.ActionID{}) { diff --git a/src/cmd/go/testdata/script/test_cache_inputs.txt b/src/cmd/go/testdata/script/test_cache_inputs.txt index b5c2286ea24..ee0c2c66bc6 100644 --- a/src/cmd/go/testdata/script/test_cache_inputs.txt +++ b/src/cmd/go/testdata/script/test_cache_inputs.txt @@ -128,7 +128,7 @@ go test testcache -run=TestOSArgs -fullpath go test testcache -run=TestOSArgs -fullpath stdout '\(cached\)' -# Ensure that specifying a cover profile does not prevent test results from being cached. +# Ensure that coverage profiles are being cached. go test testcache -run=TestCoverageCache -coverprofile=coverage.out go test testcache -run=TestCoverageCache -coverprofile=coverage.out stdout '\(cached\)'