Dump goroutine stacks when the test watchdog fires

The watchdog only log.Fatal'd with a message, so a hung test told us
that it timed out but not where it was stuck -- useless for diagnosing
an intermittent deadlock under the race detector. Dump all goroutine
stacks to stderr first (the harness surfaces this process's stderr on
failure), turning a bare timeout into an actionable stack trace.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Stefan Haller
2026-07-20 14:26:25 +02:00
co-authored by Claude Opus 4.8
parent 840a66e733
commit 03a914c04c
+5
View File
@@ -3,6 +3,7 @@ package gui
import (
"log"
"os"
"runtime/pprof"
"time"
"github.com/jesseduffield/lazygit/pkg/gocui"
@@ -48,6 +49,10 @@ func (gui *Gui) handleTestMode() {
timeout := 40 * time.Second * testTimeoutMultiplier
go utils.Safe(func() {
time.Sleep(timeout)
// Dump all goroutine stacks before dying, so a hung test shows
// where it got stuck rather than just that it timed out. The
// test harness surfaces this process's stderr on failure.
_ = pprof.Lookup("goroutine").WriteTo(os.Stderr, 2)
log.Fatalf("%v is up, lazygit integration test took too long to complete", timeout)
})
}