mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-10 15:46:26 -04:00
Go's default 10-minute timeout was enough for running integration tests normally (both locally and on CI), but with race detection turned on they can take much longer to run. Increase the timeout unconditionally to 30 minutes; we don't bother making a distinction between race vs. normal, because a longer timeout doesn't hurt (I can't recall having hit the global timeout ever; and we still have the per-test watchdog that kills an individual test after 40s).
41 lines
1.8 KiB
Bash
Executable file
41 lines
1.8 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
echo "Running integration tests with $(git --version)"
|
|
|
|
# This is ugly, but older versions of git don't support the GIT_CONFIG_GLOBAL
|
|
# env var; the only way to run tests for these old versions is to copy our test
|
|
# config file to the actual global location. Move an existing file out of the
|
|
# way so that we can restore it at the end.
|
|
if test -f ~/.gitconfig; then
|
|
mv ~/.gitconfig ~/.gitconfig.lazygit.bak
|
|
fi
|
|
|
|
cp test/global_git_config ~/.gitconfig
|
|
|
|
# if the LAZYGIT_GOCOVERDIR env var is set, we'll capture code coverage data
|
|
if [ -n "$LAZYGIT_GOCOVERDIR" ]; then
|
|
# Go expects us to either be running the test binary directly or running `go test`, but because
|
|
# we're doing both and because we want to combine coverage data for both, we need to be a little
|
|
# 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_COCOVERDIR 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"
|
|
EXITCODE=$?
|
|
|
|
# We're merging the coverage data for the sake of having fewer artefacts to upload.
|
|
# We can't merge inline so we're merging to a tmp dir then moving back to the original.
|
|
mkdir -p /tmp/code_coverage_merged
|
|
go tool covdata merge -i=/tmp/code_coverage -o=/tmp/code_coverage_merged
|
|
rm -rf /tmp/code_coverage
|
|
mv /tmp/code_coverage_merged /tmp/code_coverage
|
|
else
|
|
go test -timeout 30m pkg/integration/clients/*.go
|
|
EXITCODE=$?
|
|
fi
|
|
|
|
if test -f ~/.gitconfig.lazygit.bak; then
|
|
mv ~/.gitconfig.lazygit.bak ~/.gitconfig
|
|
fi
|
|
|
|
exit $EXITCODE
|