diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index 1f76e281c..2ded4a5c5 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -623,7 +623,10 @@ func (gui *Gui) Run(startArgs appTypes.StartArgs) error { deadlock.Opts.LogBuf = utils.NewOnceWriter(os.Stderr, func() { gui.g.Close() }) - deadlock.Opts.Disable = !gui.Debug + // disable deadlock reporting if we're not running in debug mode, or if + // we're debugging an integration test. In this latter case, stopping at + // breakpoints and stepping through code can easily take more than 30s. + deadlock.Opts.Disable = !gui.Debug || os.Getenv(components.WAIT_FOR_DEBUGGER_ENV_VAR) == "" if err := gui.Config.ReloadUserConfig(); err != nil { return nil diff --git a/pkg/gui/test_mode.go b/pkg/gui/test_mode.go index e24e922a9..151cb7246 100644 --- a/pkg/gui/test_mode.go +++ b/pkg/gui/test_mode.go @@ -45,10 +45,12 @@ func (gui *Gui) handleTestMode() { log.Fatal("gocui should have already exited") }() - go utils.Safe(func() { - time.Sleep(time.Second * 40) - log.Fatal("40 seconds is up, lazygit recording took too long to complete") - }) + if os.Getenv(components.WAIT_FOR_DEBUGGER_ENV_VAR) == "" { + go utils.Safe(func() { + time.Sleep(time.Second * 40) + log.Fatal("40 seconds is up, lazygit recording took too long to complete") + }) + } } } diff --git a/pkg/integration/clients/injector/main.go b/pkg/integration/clients/injector/main.go index 63c3e2a07..223ff4ecb 100644 --- a/pkg/integration/clients/injector/main.go +++ b/pkg/integration/clients/injector/main.go @@ -31,7 +31,7 @@ func main() { integrationTest := getIntegrationTest() - if os.Getenv("WAIT_FOR_DEBUGGER") != "" { + if os.Getenv(components.WAIT_FOR_DEBUGGER_ENV_VAR) != "" { println("Waiting for debugger to attach...") for !isDebuggerAttached() { time.Sleep(time.Millisecond * 100) diff --git a/pkg/integration/components/runner.go b/pkg/integration/components/runner.go index 821319dc1..d84ee4a22 100644 --- a/pkg/integration/components/runner.go +++ b/pkg/integration/components/runner.go @@ -16,6 +16,7 @@ import ( const ( TEST_NAME_ENV_VAR = "TEST_NAME" SANDBOX_ENV_VAR = "SANDBOX" + WAIT_FOR_DEBUGGER_ENV_VAR = "WAIT_FOR_DEBUGGER" GIT_CONFIG_GLOBAL_ENV_VAR = "GIT_CONFIG_GLOBAL" ) @@ -42,7 +43,7 @@ func RunTests( testDir := filepath.Join(projectRootDir, "test", "_results") - if err := buildLazygit(raceDetector); err != nil { + if err := buildLazygit(waitForDebugger, raceDetector); err != nil { return err } @@ -138,12 +139,17 @@ func prepareTestDir( return createFixture(test, paths, rootDir) } -func buildLazygit(raceDetector bool) error { +func buildLazygit(debug bool, raceDetector bool) error { // // TODO: remove this line! // // skipping this because I'm not making changes to the app code atm. // return nil args := []string{"go", "build"} + if debug { + // Disable compiler optimizations (-N) and inlining (-l) because this + // makes debugging work better + args = append(args, "-gcflags=all=-N -l") + } if raceDetector { args = append(args, "-race") } @@ -210,7 +216,7 @@ func getLazygitCommand(test *IntegrationTest, paths Paths, rootDir string, sandb cmdObj.AddEnvVars(fmt.Sprintf("%s=%s", SANDBOX_ENV_VAR, "true")) } if waitForDebugger { - cmdObj.AddEnvVars("WAIT_FOR_DEBUGGER=true") + cmdObj.AddEnvVars(fmt.Sprintf("%s=true", WAIT_FOR_DEBUGGER_ENV_VAR)) } // Set a race detector log path only to avoid spamming the terminal with the // logs. We are not showing this anywhere yet.