@@ -1265,7 +1265,7 @@ func (p *Package) buildGo(buildctx *buildContext, wd, result string) (res *packa
1265
1265
testCommand = append (testCommand , fmt .Sprintf ("-coverprofile=%v" , codecovComponentName (p .FullName ())))
1266
1266
} else {
1267
1267
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 )
1269
1269
}
1270
1270
testCommand = append (testCommand , "./..." )
1271
1271
@@ -1300,13 +1300,14 @@ func (p *Package) buildGo(buildctx *buildContext, wd, result string) (res *packa
1300
1300
}, nil
1301
1301
}
1302
1302
1303
- func collectGoTestCoverage (covfile , fullName string ) testCoverageFunc {
1303
+ func collectGoTestCoverage (covfile , fullName , cwd string ) testCoverageFunc {
1304
1304
return func () (coverage , funcsWithoutTest , funcsWithTest int , err error ) {
1305
1305
// We need to collect the coverage for all packages in the module.
1306
1306
// To that end we load the coverage file.
1307
1307
// The coverage file contains the coverage for all packages in the module.
1308
1308
1309
1309
cmd := exec .Command ("go" , "tool" , "cover" , "-func" , covfile )
1310
+ cmd .Dir = cwd
1310
1311
out , err := cmd .CombinedOutput ()
1311
1312
if err != nil {
1312
1313
err = xerrors .Errorf ("cannot collect test coverage: %w: %s" , err , string (out ))
0 commit comments