@@ -86,11 +86,11 @@ withApp :: Settings -> Application -> (Int -> IO a) -> IO a
8686withApp settings app f = do
8787 port <- getPort
8888 baton <- newEmptyMVar
89+ let settings' = setPort port
90+ $ setBeforeMainLoop (putMVar baton ())
91+ settings
8992 bracket
90− (forkIO $ runSettings settings
91− { settingsPort = port
92− , settingsBeforeMainLoop = putMVar baton ()
93− } app `onException` putMVar baton ())
93+ (forkIO $ runSettings settings' app `onException` putMVar baton ())
9494 killThread
9595 (const $ takeMVar baton >> f port)
9696
@@ -117,9 +117,8 @@ runTerminateTest :: InvalidRequest
117117 -> IO ()
118118runTerminateTest expected input = do
119119 ref <- I.newIORef Nothing
120− withApp defaultSettings
121− { settingsOnException = \_ e -> I.writeIORef ref $ Just e
122− } dummyApp $ \port -> do
120+ let onExc _ = I.writeIORef ref . Just
121+ withApp (setOnException onExc defaultSettings) dummyApp $ \port -> do
123122 handle <- connectTo "127.0.0.1" $ PortNumber $ fromIntegral port
124123 hPutStr handle input
125124 hFlush handle
@@ -276,7 +275,7 @@ spec = do
276275 I.atomicModifyIORef ifront (\front -> (front . ("threadDelay interrupted":), ()))
277276 liftIO $ I.atomicModifyIORef ifront $ \front -> (front . (S.concat bss:), ())
278277 return $ responseLBS status200 [] ""
279− withApp defaultSettings { settingsTimeout = 1 } app $ \port -> do
278+ withApp (setTimeout 1 defaultSettings) app $ \port -> do
280279 let bs1 = S.replicate 2048 88
281280 bs2 = "This is short"
282281 bs = S.append bs1 bs2