@@ -4,14 +4,12 @@ module ExceptionSpec (main, spec) where
44
55import Control.Applicative
66import Control.Monad
7−import Control.Concurrent (forkIO, threadDelay)
87import Network.HTTP
98import Network.Stream
109import Network.HTTP.Types hiding (Header)
1110import Network.Wai hiding (Response)
1211import Network.Wai.Internal (Request(..))
1312import Network.Wai.Handler.Warp
14−import System.IO.Unsafe (unsafePerformIO)
1513import Test.Hspec
1614import Control.Exception
1715import qualified Data.Streaming.Network as N
@@ -25,9 +23,9 @@ withTestServer :: (Int -> IO a) -> IO a
2523withTestServer inner = bracket
2624 (N.bindRandomPortTCP "*4")
2725 (sClose . snd)
28− $ \(port, lsocket) -> do
26+ $ \(prt, lsocket) -> do
2927 withAsync (runSettingsSocket defaultSettings lsocket testApp)
30− $ \_ -> inner port
28+ $ \_ -> inner prt
3129
3230testApp :: Application
3331testApp (Network.Wai.Internal.Request {pathInfo = [x]}) f
@@ -61,8 +59,8 @@ spec = describe "responds even if there is an exception" $ do
6159 sc <- rspCode <$> sendGET "http://localhost:2345/bodyError"
6260 sc `shouldBe` (5,0,0)
6361 -}
64− it "ioException" $ withTestServer $ \port -> do
65− sc <- rspCode <$> sendGET (concat $ ["http://localhost:", show port, "/ioException"])
62+ it "ioException" $ withTestServer $ \prt -> do
63+ sc <- rspCode <$> sendGET (concat $ ["http://localhost:", show prt, "/ioException"])
6664 sc `shouldBe` (5,0,0)
6765
6866----------------------------------------------------------------