From cb5c127b55f3c9bcf3b2290ed4fb1c0fe1758fd9 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sat, 17 Oct 2026 11:53:31 +0200 Subject: [PATCH] Write all integration test coverage to LAZYGIT_GOCOVERDIR If LAZYGIT_GOCOVERDIR is set, run_integration_tests.sh collects the coverage of the integration tests. Only the lazygit binary writes its data to that directory, though. The test runner always writes to /tmp/code_coverage, so the data ends up in two places unless the variable points there. On CI it always did. Also, the run fails if the directory doesn't exist yet. With a relative path, the binary's data goes missing, because the binary runs in the directory of the test's repo. Pass the directory to the test runner too, create it if needed, and turn it into an absolute path. Co-Authored-By: Claude Opus 5.5 (1M context) --- scripts/run_integration_tests.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/run_integration_tests.sh b/scripts/run_integration_tests.sh index 1fa572988..1d6dcbaa4 100755 --- a/scripts/run_integration_tests.sh +++ b/scripts/run_integration_tests.sh @@ -9,7 +9,13 @@ if [ -n "$LAZYGIT_GOCOVERDIR" ]; then # hacky. To capture the coverage data for the test runner we pass the test.gocoverdir positional # arg, but if we do that then the GOCOVERDIR env var (which you typically pass to the test binary) will be overwritten by the test runner. So we're passing LAZYGIT_GOCOVERDIR instead # and then internally passing that to the test binary as GOCOVERDIR. - go test -timeout 30m -cover -coverpkg=github.com/jesseduffield/lazygit/pkg/... pkg/integration/clients/*.go -args -test.gocoverdir="/tmp/code_coverage" + # + # Go doesn't create the coverage directory itself. The lazygit binary runs in + # the directory of the test's repo, so it also needs an absolute path. + mkdir -p "$LAZYGIT_GOCOVERDIR" + LAZYGIT_GOCOVERDIR=$(cd "$LAZYGIT_GOCOVERDIR" && pwd) + export LAZYGIT_GOCOVERDIR + go test -timeout 30m -cover -coverpkg=github.com/jesseduffield/lazygit/pkg/... pkg/integration/clients/*.go -args -test.gocoverdir="$LAZYGIT_GOCOVERDIR" EXITCODE=$? else go test -timeout 30m pkg/integration/clients/*.go