sync between tests

This commit is contained in:
Evgeny Poberezkin
2025-05-23 11:30:02 +01:00
parent 5a7e4e0da3
commit 09348c46f7

View File

@@ -37,6 +37,7 @@ import Simplex.Messaging.Version
import Simplex.Messaging.Version.Internal
import System.Environment (lookupEnv)
import System.Info (os)
import System.Process (callCommand)
import Test.Hspec hiding (fit, it)
import UnliftIO.Concurrent
import qualified UnliftIO.Exception as E
@@ -302,7 +303,7 @@ serverBracket process afterProcess f = do
started <- newEmptyTMVarIO
E.bracket
(forkIOWithUnmask (\unmask -> unmask (process started) `E.catchAny` handleStartError started))
(\t -> killThread t >> afterProcess >> waitFor started "stop")
(\t -> killThread t >> afterProcess >> waitFor started "stop" >> callCommand "sync")
(\t -> waitFor started "start" >> f t >>= \r -> r <$ threadDelay 100000)
where
-- it putTMVar is called twise to unlock both parts of the bracket in case of start failure