on master help sign in
More resilient tests (again)
commitcd08dd7acf7483b02e3164fb9bcf21e147e06f97 authorMichael Snoyman <michael@snoyman.com> dateTue 3 Dec 2013, 12:31 (13 years ago) parent441a1d7
1 file changed+3−3
warp/test/RunSpec.hs+3−3
warp/test/RunSpec.hs+3−3
@@ -4,7 +4,8 @@
44module RunSpec (main, spec, withApp) where
55
66import Control.Concurrent (forkIO, killThread, threadDelay)
7−import Control.Monad (forM_)
7+import Control.Monad (forM_, replicateM_)
8+import System.Timeout (timeout)
89import Control.Monad.IO.Class (MonadIO, liftIO)
910import Data.ByteString (ByteString, hPutStr, hGetSome)
1011import qualified Data.ByteString as S
@@ -102,8 +103,7 @@ runTest expected app chunks = do
102103 withApp defaultSettings (app ref) $ \port -> do
103104 handle <- connectTo "127.0.0.1" $ PortNumber $ fromIntegral port
104105 forM_ chunks $ \chunk -> hPutStr handle chunk >> hFlush handle
105− _ <- hGetSome handle 4096
106− threadDelay 30000
106+ _ <- timeout 100000 $ replicateM_ expected $ hGetSome handle 4096
107107 res <- I.readIORef ref
108108 case res of
109109 Left s -> error s