From 4f6d3fb592af1448a33407b838acceb0acabea0e Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Wed, 5 Jun 2024 11:11:25 +0200 Subject: [PATCH 1/2] Don't wait in integration tests when running in headless mode There's no point in spending time waiting in this case, as nobody can see it. --- pkg/gui/gui_driver.go | 5 +++++ pkg/gui/test_mode.go | 2 +- pkg/integration/components/test_test.go | 2 ++ pkg/integration/components/view_driver.go | 4 +++- pkg/integration/types/types.go | 1 + 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/pkg/gui/gui_driver.go b/pkg/gui/gui_driver.go index 3421602e9..5de0ad4ee 100644 --- a/pkg/gui/gui_driver.go +++ b/pkg/gui/gui_driver.go @@ -21,6 +21,7 @@ type GuiDriver struct { gui *Gui isIdleChan chan struct{} toastChan chan string + headless bool } var _ integrationTypes.GuiDriver = &GuiDriver{} @@ -161,3 +162,7 @@ func (self *GuiDriver) NextToast() *string { return nil } } + +func (self *GuiDriver) Headless() bool { + return self.headless +} diff --git a/pkg/gui/test_mode.go b/pkg/gui/test_mode.go index 65009fb78..c5014ad72 100644 --- a/pkg/gui/test_mode.go +++ b/pkg/gui/test_mode.go @@ -38,7 +38,7 @@ func (gui *Gui) handleTestMode() { gui.PopupHandler.(*popup.PopupHandler).SetToastFunc( func(message string, kind types.ToastKind) { toastChan <- message }) - test.Run(&GuiDriver{gui: gui, isIdleChan: isIdleChan, toastChan: toastChan}) + test.Run(&GuiDriver{gui: gui, isIdleChan: isIdleChan, toastChan: toastChan, headless: Headless()}) gui.g.Update(func(*gocui.Gui) error { return gocui.ErrQuit diff --git a/pkg/integration/components/test_test.go b/pkg/integration/components/test_test.go index 047ee507c..ea1c79124 100644 --- a/pkg/integration/components/test_test.go +++ b/pkg/integration/components/test_test.go @@ -84,6 +84,8 @@ func (self *fakeGuiDriver) NextToast() *string { func (self *fakeGuiDriver) CheckAllToastsAcknowledged() {} +func (self *fakeGuiDriver) Headless() bool { return false } + func TestManualFailure(t *testing.T) { test := NewIntegrationTest(NewIntegrationTestArgs{ Description: unitTestDescription, diff --git a/pkg/integration/components/view_driver.go b/pkg/integration/components/view_driver.go index 8d9b336d6..4d8e75217 100644 --- a/pkg/integration/components/view_driver.go +++ b/pkg/integration/components/view_driver.go @@ -601,7 +601,9 @@ func (self *ViewDriver) SetCaptionPrefix(prefix string) *ViewDriver { } func (self *ViewDriver) Wait(milliseconds int) *ViewDriver { - self.t.Wait(milliseconds) + if !self.t.gui.Headless() { + self.t.Wait(milliseconds) + } return self } diff --git a/pkg/integration/types/types.go b/pkg/integration/types/types.go index a30aeb055..9c4f057d2 100644 --- a/pkg/integration/types/types.go +++ b/pkg/integration/types/types.go @@ -46,4 +46,5 @@ type GuiDriver interface { // Pop the next toast that was displayed; returns nil if there was none NextToast() *string CheckAllToastsAcknowledged() + Headless() bool } From f5329440fccc54ca60d6e53ec4db28237905880d Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Wed, 5 Jun 2024 11:12:08 +0200 Subject: [PATCH 2/2] Include demos when running integration tests with go test --- pkg/integration/clients/go_test.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/pkg/integration/clients/go_test.go b/pkg/integration/clients/go_test.go index 6984e0deb..af4bbf5f8 100644 --- a/pkg/integration/clients/go_test.go +++ b/pkg/integration/clients/go_test.go @@ -45,12 +45,6 @@ func TestIntegration(t *testing.T) { return } - // not running demoes right now. Arguably we should, but we'd need to - // strip away any artificial lag they use. - if test.IsDemo() { - return - } - t.Run(test.Name(), func(t *testing.T) { t.Parallel() err := f()