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:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user