From c7a3b69eb92dd5b543769cafcb2992da1ee8ed4d Mon Sep 17 00:00:00 2001 From: Jesse Duffield <jessedduffield@gmail.com> Date: Sat, 8 Jul 2023 15:23:58 +1000 Subject: [PATCH] Remove retry logic in integration tests I want to see how we go removing all retry logic within a test. Lazygit should be trusted to tell us when it's no longer busy, and if it that proves false we should fix the issue in the code rather than being lenient in the tests --- .github/workflows/ci.yml | 3 +- .../components/assertion_helper.go | 32 +++---------------- 2 files changed, 6 insertions(+), 29 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 05a5a0f73..3494e6a40 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -68,9 +68,8 @@ jobs: restore-keys: | ${{runner.os}}-go- - name: Test code - # LONG_WAIT_BEFORE_FAIL means that for a given test assertion, we'll wait longer before failing run: | - LONG_WAIT_BEFORE_FAIL=true go test pkg/integration/clients/*.go + go test pkg/integration/clients/*.go build: runs-on: ubuntu-latest env: diff --git a/pkg/integration/components/assertion_helper.go b/pkg/integration/components/assertion_helper.go index f7e435a1f..0529e8bec 100644 --- a/pkg/integration/components/assertion_helper.go +++ b/pkg/integration/components/assertion_helper.go @@ -1,9 +1,6 @@ package components import ( - "os" - "time" - integrationTypes "github.com/jesseduffield/lazygit/pkg/integration/types" ) @@ -11,19 +8,6 @@ type assertionHelper struct { gui integrationTypes.GuiDriver } -// milliseconds we'll wait when an assertion fails. -func retryWaitTimes() []int { - return []int{0} - - if os.Getenv("LONG_WAIT_BEFORE_FAIL") == "true" { - // CI has limited hardware, may be throttled, runs tests in parallel, etc, so we - // give it more leeway compared to when we're running things locally. - return []int{0, 1, 1, 1, 1, 1, 5, 10, 20, 40, 100, 200, 500, 1000, 2000, 4000} - } else { - return []int{0, 1, 1, 1, 1, 1, 5, 10, 20, 40, 100, 200} - } -} - func (self *assertionHelper) matchString(matcher *TextMatcher, context string, getValue func() string) { self.assertWithRetries(func() (bool, string) { value := getValue() @@ -31,19 +15,13 @@ func (self *assertionHelper) matchString(matcher *TextMatcher, context string, g }) } +// We no longer assert with retries now that lazygit tells us when it's no longer +// busy. But I'm keeping the function in case we want to re-introduce it later. func (self *assertionHelper) assertWithRetries(test func() (bool, string)) { - var message string - for _, waitTime := range retryWaitTimes() { - time.Sleep(time.Duration(waitTime) * time.Millisecond) - - var ok bool - ok, message = test() - if ok { - return - } + ok, message := test() + if !ok { + self.fail(message) } - - self.fail(message) } func (self *assertionHelper) fail(message string) {