on master help sign in
Timeouts for long-running tests
commit699bf916142aebd3aaba56190b9e096e011f18fb authorMichael Snoyman <michael@snoyman.com> dateMon 1 Apr 2019, 11:59 (8 years ago) parent3b23f42
1 file changed+7−1
warp/test/RunSpec.hs+7−1
warp/test/RunSpec.hs+7−1
@@ -136,7 +136,13 @@ withApp settings app f = do
136136 bracket
137137 (forkIO $ runSettings settings' app `onException` putMVar baton ())
138138 killThread
139− (const $ takeMVar baton >> f port)
139+ (const $ do
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)
140146
141147runTest :: Int -- ^ expected number of requests
142148 -> CounterApplication