@@ -1854,25 +1854,21 @@ func (c *runCache) saveOutput(a *work.Action, coverprofileFile string) {
1854
1854
if err != nil {
1855
1855
return
1856
1856
}
1857
- var coverprof * os. File
1857
+ saveCoverProfile := func ( testID cache. ActionID ) {}
1858
1858
if coverprofileFile != "" {
1859
- coverprof , err = os .Open (coverprofileFile )
1860
- if err != nil && cache .DebugTest {
1861
- fmt .Fprintf (os .Stderr , "testcache: %s: failed to open temporary coverprofile: %s" , a .Package .ImportPath , err )
1862
- }
1863
- }
1864
- if coverprof != nil {
1865
- defer func () {
1866
- if err := coverprof .Close (); err != nil && cache .DebugTest {
1867
- fmt .Fprintf (os .Stderr , "testcache: %s: closing temporary coverprofile: %v" , a .Package .ImportPath , err )
1859
+ coverprof , err := os .Open (coverprofileFile )
1860
+ if err == nil {
1861
+ saveCoverProfile = func (testID cache.ActionID ) {
1862
+ cache .Default ().Put (testCoverProfileKey (testID , testInputsID ), coverprof )
1868
1863
}
1869
- }()
1870
- }
1871
- saveCoverProfile := func (testID cache.ActionID ) {
1872
- if coverprof == nil {
1873
- return
1864
+ defer func () {
1865
+ if err := coverprof .Close (); err != nil && cache .DebugTest {
1866
+ fmt .Fprintf (os .Stderr , "testcache: %s: closing temporary coverprofile: %v" , a .Package .ImportPath , err )
1867
+ }
1868
+ }()
1869
+ } else if cache .DebugTest {
1870
+ fmt .Fprintf (os .Stderr , "testcache: %s: failed to open temporary coverprofile: %s" , a .Package .ImportPath , err )
1874
1871
}
1875
- cache .Default ().Put (testCoverProfileKey (testID , testInputsID ), coverprof )
1876
1872
}
1877
1873
if c .id1 != (cache.ActionID {}) {
1878
1874
if cache .DebugTest {
0 commit comments