on master help sign in
Timeouts for long-running tests
699bf91Michael Snoyman
warp/test/RunSpec.hs+7−1
@@ -136,7 +136,13 @@ withApp settings app f = do
136 bracket
136 bracket
137 (forkIO $ runSettings settings' app `onException` putMVar baton ())
137 (forkIO $ runSettings settings' app `onException` putMVar baton ())
138 killThread
138 killThread
139+ (const $ do
139− (const $ takeMVar baton >> f port)
140+ takeMVar baton
141+ -- use timeout to make sure we don't take too long
142+ mres <- timeout (60 * 1000 * 1000) (f port)
143+ case mres of
144+ Nothing -> error "Timeout triggered, too slow!"
145+ Just a -> pure a)
140
146
141runTest :: Int -- ^ expected number of requests
147runTest :: Int -- ^ expected number of requests
142 -> CounterApplication
148 -> CounterApplication