@@ -1265,7 +1265,7 @@ func (p *Package) buildGo(buildctx *buildContext, wd, result string) (res *packa
12651265 testCommand = append (testCommand , fmt .Sprintf ("-coverprofile=%v" , codecovComponentName (p .FullName ())))
12661266 } else {
12671267 testCommand = append (testCommand , "-coverprofile=testcoverage.out" )
1268- reportCoverage = collectGoTestCoverage (filepath .Join (wd , "testcoverage.out" ), p .FullName ())
1268+ reportCoverage = collectGoTestCoverage (filepath .Join (wd , "testcoverage.out" ), p .FullName (), buildctx . buildDir )
12691269 }
12701270 testCommand = append (testCommand , "./..." )
12711271
@@ -1300,13 +1300,14 @@ func (p *Package) buildGo(buildctx *buildContext, wd, result string) (res *packa
13001300 }, nil
13011301}
13021302
1303- func collectGoTestCoverage (covfile , fullName string ) testCoverageFunc {
1303+ func collectGoTestCoverage (covfile , fullName , cwd string ) testCoverageFunc {
13041304 return func () (coverage , funcsWithoutTest , funcsWithTest int , err error ) {
13051305 // We need to collect the coverage for all packages in the module.
13061306 // To that end we load the coverage file.
13071307 // The coverage file contains the coverage for all packages in the module.
13081308
13091309 cmd := exec .Command ("go" , "tool" , "cover" , "-func" , covfile )
1310+ cmd .Dir = cwd
13101311 out , err := cmd .CombinedOutput ()
13111312 if err != nil {
13121313 err = xerrors .Errorf ("cannot collect test coverage: %w: %s" , err , string (out ))
0 commit comments