diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2023-07-03 14:16:43 +1000 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2023-07-08 22:54:52 +1000 |
commit | 6c4e7ee9729ccfd65ac03073a37bd110a61be432 (patch) | |
tree | 95d647609ccfe231a0c01cb2ac6f701f5257050d /pkg/gui/test_mode.go | |
parent | 631cf1e873f4bf802d28bc48fc2621c6fdf96c39 (diff) |
Add busy count for integration tests
Integration tests need to be notified when Lazygit is idle so they can progress to the next assertion / user action.
Diffstat (limited to 'pkg/gui/test_mode.go')
-rw-r--r-- | pkg/gui/test_mode.go | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/pkg/gui/test_mode.go b/pkg/gui/test_mode.go index be46041db..e24e922a9 100644 --- a/pkg/gui/test_mode.go +++ b/pkg/gui/test_mode.go @@ -7,29 +7,39 @@ import ( "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/integration/components" - integrationTypes "github.com/jesseduffield/lazygit/pkg/integration/types" "github.com/jesseduffield/lazygit/pkg/utils" ) type IntegrationTest interface { - Run(guiAdapter *GuiDriver) + Run(*GuiDriver) } -func (gui *Gui) handleTestMode(test integrationTypes.IntegrationTest) { +func (gui *Gui) handleTestMode() { + test := gui.integrationTest if os.Getenv(components.SANDBOX_ENV_VAR) == "true" { return } if test != nil { + isIdleChan := make(chan struct{}) + + gui.c.GocuiGui().AddIdleListener(isIdleChan) + + waitUntilIdle := func() { + <-isIdleChan + } + go func() { - time.Sleep(time.Millisecond * 100) + waitUntilIdle() - test.Run(&GuiDriver{gui: gui}) + test.Run(&GuiDriver{gui: gui, isIdleChan: isIdleChan}) gui.g.Update(func(*gocui.Gui) error { return gocui.ErrQuit }) + waitUntilIdle() + time.Sleep(time.Second * 1) log.Fatal("gocui should have already exited") |