Add support for GOCOVERDIR to e2e tests (#1622)

Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
This commit is contained in:
Christian Mesh 2024-05-07 15:22:35 -04:00 committed by GitHub
parent 60a0e82c1f
commit 7d3f5bea9f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -245,11 +245,24 @@ func GoBuild(pkgPath, tmpPrefix string) string {
panic(err)
}
cmd := exec.Command(
"go", "build",
args := []string{
"go",
"build",
}
if len(os.Getenv("GOCOVERDIR")) != 0 {
args = append(args,
"-cover",
"-coverpkg=github.com/opentofu/opentofu/...",
)
}
args = append(args,
"-o", tmpFilename,
pkgPath,
)
cmd := exec.Command(args[0], args[1:]...)
cmd.Stderr = os.Stderr
cmd.Stdout = os.Stdout