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:
parent
b19943af01
commit
c7a3b69eb9
3
.github/workflows/ci.yml
vendored
3
.github/workflows/ci.yml
vendored
@ -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:
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user