Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2023-06-01 16:31:05 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2023-06-01 16:36:11 +0300
commitcefa042692ff71a6e56c72a4f7eaea85496d891a (patch)
tree97b26c5b78cc2d1e901e89c006b60e8b32db7659
parentf82056a5081d5ed208cac8249a855581ff9a2613 (diff)
testcfg: Build binaries with coverage information enabledpks-coverage-for-binaries
-rw-r--r--Makefile2
-rw-r--r--internal/command/command.go2
-rw-r--r--internal/testhelper/testcfg/binaries.go1
3 files changed, 4 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 8d13402f5..11443742b 100644
--- a/Makefile
+++ b/Makefile
@@ -380,7 +380,7 @@ test-go: override TEST_OPTIONS := ${TEST_OPTIONS} -coverprofile "${TEST_COVERAGE
test-go: prepare-tests ${GOCOVER_COBERTURA}
${Q}rm -rf "${TEST_COVERAGE_DIR}"
${Q}mkdir -p "${TEST_COVERAGE_DIR}"
- ${Q}$(call run_go_tests)
+ ${Q}GOCOVERDIR="${TEST_COVERAGE_DIR}" $(call run_go_tests)
${Q}go tool cover -html "${TEST_COVERAGE_DIR}/all.merged" -o "${TEST_COVERAGE_DIR}/all.html"
@ # sed is used below to convert file paths to repository root relative paths. See https://gitlab.com/gitlab-org/gitlab/-/issues/217664
${Q}${GOCOVER_COBERTURA} <"${TEST_COVERAGE_DIR}/all.merged" | sed 's;filename=\"$(shell go list -m)/;filename=\";g' >"${TEST_COVERAGE_DIR}/cobertura.xml"
diff --git a/internal/command/command.go b/internal/command/command.go
index ea688a156..ecc918b4c 100644
--- a/internal/command/command.go
+++ b/internal/command/command.go
@@ -84,6 +84,8 @@ var (
"LD_LIBRARY_PATH",
"TZ",
+ "GOCOVERDIR",
+
// Export git tracing variables for easier debugging
"GIT_TRACE",
"GIT_TRACE_PACK_ACCESS",
diff --git a/internal/testhelper/testcfg/binaries.go b/internal/testhelper/testcfg/binaries.go
index 54526ed06..3b591ce76 100644
--- a/internal/testhelper/testcfg/binaries.go
+++ b/internal/testhelper/testcfg/binaries.go
@@ -111,6 +111,7 @@ func BuildBinary(tb testing.TB, targetDir, sourcePath string) string {
cmd := exec.Command(
"go",
"build",
+ "-cover",
"-buildvcs=false",
"-tags", strings.Join(buildTags, ","),
"-ldflags", fmt.Sprintf("-X %s/version.version=%s", testhelper.PkgPath("internal"), version.GetVersion()),