Skip to content

Commit 8d5b6e8

Browse files
committed
Revert "tests: Exponentially back off waiting"
This reverts commit cb94323. The more aggressive (read shorter) initial timeouts could lead to more failing tests. This is partially because after we've implemented the new UI methods, we never investigated that the views now share more common widgets. Widget labels show up in more different views. This leads to more failures in combination with the aggressive timeouts, because the assertions still find the same strings in the old views as well as in the new views. Therefore, tweaking more with the timeouts will make the tests more brittle.
1 parent 8afd454 commit 8d5b6e8

1 file changed

Lines changed: 11 additions & 15 deletions

File tree

test/TestUserAcceptance.hs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ sendKeys :: String -> Condition -> ReaderT Env IO String
764764
sendKeys keys expect = do
765765
sessionName <- getSessionName
766766
liftIO $ callProcess "tmux" $ communicateSessionArgs sessionName keys False
767-
waitForCondition expect defaultCountdown initialBackoffMicroseconds
767+
waitForCondition expect defaultCountdown
768768

769769
sendLiteralKeys :: String -> ReaderT Env IO String
770770
sendLiteralKeys keys = do
@@ -783,8 +783,8 @@ getSessionName = view (envSessionName . ask)
783783
getTestMaildir :: (Monad m) => ReaderT Env m FilePath
784784
getTestMaildir = view (envMaildir . ask)
785785

786-
initialBackoffMicroseconds :: Int
787-
initialBackoffMicroseconds = 20 * 10 ^ (3 :: Int)
786+
holdOffTime :: Int
787+
holdOffTime = 10 ^ (6 :: Int)
788788

789789
-- | convenience function to print captured output to STDERR
790790
debugOutput :: String -> IO ()
@@ -793,15 +793,11 @@ debugOutput out = do
793793
when (isJust d) $ hPutStr stderr ("\n\n" <> out)
794794

795795
-- | wait for the application to render a new interface which we determine with
796-
-- a given condition. We wait a short duration and increase the wait time
797-
-- exponentially until the count down reaches 0. We fail if until then the
798-
-- condition is not met.
799-
waitForCondition ::
800-
Condition
801-
-> Int -- ^ count down value
802-
-> Int -- ^ milliseconds to back off
803-
-> ReaderT Env IO String
804-
waitForCondition cond n backOff = do
796+
-- a given condition. We check up to @n@ times, waiting a short duration
797+
-- between each check, and failing if the tries exhaust with the condition
798+
-- not met.
799+
waitForCondition :: Condition -> Int -> ReaderT Env IO String
800+
waitForCondition cond n = do
805801
out <- capture >>= checkPane
806802
liftIO $ assertBool
807803
( "Wait time exceeded. Condition not met: '" <> show cond
@@ -814,8 +810,8 @@ waitForCondition cond n backOff = do
814810
| checkCondition cond out = pure out
815811
| n <= 0 = pure out
816812
| otherwise = do
817-
liftIO $ threadDelay backOff
818-
waitForCondition cond (n - 1) (backOff * 4)
813+
liftIO $ threadDelay holdOffTime
814+
waitForCondition cond (n - 1)
819815

820816
checkCondition :: Condition -> String -> Bool
821817
checkCondition (Literal s) = (s `isInfixOf`)
@@ -825,7 +821,7 @@ checkCondition (Regex re) = (=~ re)
825821
-- literal string.
826822
--
827823
waitForString :: String -> Int -> ReaderT Env IO String
828-
waitForString substr n = waitForCondition (Literal substr) n initialBackoffMicroseconds
824+
waitForString = waitForCondition . Literal
829825

830826
defaultCountdown :: Int
831827
defaultCountdown = 5

0 commit comments

Comments
 (0)