1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-03-21 21:47:32 +02:00

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
This commit is contained in:
Jesse Duffield 2023-07-08 15:23:58 +10:00
parent b19943af01
commit c7a3b69eb9
2 changed files with 6 additions and 29 deletions

View File

@ -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:

View File

@ -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) {