on wai-extra/3.0.4.5 help sign in
typeable/wai/warp/test/FdCacheSpec.hs
27 lines 597 B history raw
1{-# LANGUAGE CPP #-}
3module FdCacheSpec where
5import Test.Hspec
6#ifdef SENDFILEFD
7import Data.IORef
8import Network.Wai.Handler.Warp.FdCache
9import System.Posix.IO (fdRead)
10import System.Posix.Types (Fd(..))
12main :: IO ()
13main = hspec spec
15spec :: Spec
16spec = describe "withFdCache" $ do
17 it "clean up Fd" $ do
18 ref <- newIORef (Fd (-1))
19 withFdCache 30000000 $ \(Just mfc) -> do
20 (fd,_) <- getFd mfc "warp.cabal"
21 writeIORef ref fd
22 nfd <- readIORef ref
23 fdRead nfd 1 `shouldThrow` anyIOException
24#else
25spec :: Spec
26spec = return ()
27#endif