1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-12-01 22:52:01 +02:00

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.
This commit is contained in:
Jesse Duffield
2023-07-03 14:16:43 +10:00
parent 631cf1e873
commit 6c4e7ee972
23 changed files with 184 additions and 78 deletions

View File

@@ -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 {
go func() {
time.Sleep(time.Millisecond * 100)
isIdleChan := make(chan struct{})
test.Run(&GuiDriver{gui: gui})
gui.c.GocuiGui().AddIdleListener(isIdleChan)
waitUntilIdle := func() {
<-isIdleChan
}
go func() {
waitUntilIdle()
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")