File: FdCacheSpec.hs

package info (click to toggle)
haskell-warp 3.4.9-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 456 kB
  • sloc: haskell: 4,873; makefile: 10
file content (27 lines) | stat: -rw-r--r-- 602 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
{-# LANGUAGE CPP #-}

module FdCacheSpec where

import Test.Hspec
#ifndef WINDOWS
import Data.IORef
import Network.Wai.Handler.Warp.FdCache
import System.Posix.IO.ByteString (fdRead)
import System.Posix.Types (Fd(..))

main :: IO ()
main = hspec spec

spec :: Spec
spec = describe "withFdCache" $ do
    it "clean up Fd" $ do
        ref <- newIORef (Fd (-1))
        withFdCache 30000000 $ \getFd -> do
            (Just fd,_) <- getFd "warp.cabal"
            writeIORef ref fd
        nfd <- readIORef ref
        fdRead nfd 1 `shouldThrow` anyIOException
#else
spec :: Spec
spec = return ()
#endif