Fire up a separate LDAP server instance for each example

This commit is contained in:
Matvey Aksenov 2015-04-01 23:31:59 +00:00
parent 3543e6a0b6
commit cfaabed84e
5 changed files with 18 additions and 28 deletions

View File

@ -1,4 +1,4 @@
guard :haskell, all_on_start: true, all_on_pass: true, cmd: "cabal exec -- ghci -isrc -itest -DTEST test/Main.hs -ignore-dot-ghci -optP-include -optPdist/build/autogen/cabal_macros.h" do
guard :haskell, all_on_start: true, all_on_pass: true, cmd: "cabal exec -- ghci -isrc -itest -DTEST test/Spec.hs -ignore-dot-ghci -optP-include -optPdist/build/autogen/cabal_macros.h" do
watch(%r{test/.+Spec\.l?hs$})
watch(%r{src/.+\.l?hs$})
watch(%r{.+\.cabal$})

View File

@ -50,7 +50,7 @@ test-suite spec
hs-source-dirs:
test
main-is:
Main.hs
Spec.hs
other-modules:
Ldap.ClientSpec
build-depends:

View File

@ -1,24 +0,0 @@
module Main (main) where
import Control.Concurrent (threadDelay)
import Control.Exception (bracket)
import System.IO (hGetLine)
import System.Process (runInteractiveProcess, terminateProcess, waitForProcess)
import Test.Hspec
import qualified Spec
import SpecHelper (port)
main :: IO ()
main =
bracket (do (_, out, _, h) <- runInteractiveProcess "./test/ldap.js" [] Nothing
(Just [ ("PORT", show port)
, ("SSL_CERT", "./ssl/cert.pem")
, ("SSL_KEY", "./ssl/key.pem")
])
hGetLine out
return h)
(\h -> do terminateProcess h
waitForProcess h)
(\_ -> hspec Spec.spec)

View File

@ -1 +1 @@
{-# OPTIONS_GHC -F -pgmF hspec-discover -optF --module-name=Spec #-}
{-# OPTIONS_GHC -F -pgmF hspec-discover #-}

View File

@ -21,11 +21,25 @@ module SpecHelper
, oddish
) where
import Control.Exception (bracket)
import System.IO (hGetLine)
import System.Process (runInteractiveProcess, terminateProcess, waitForProcess)
import Ldap.Client as Ldap
locally :: (Ldap -> IO a) -> IO (Either LdapError a)
locally = Ldap.with localhost port
locally f =
bracket (do (_, out, _, h) <- runInteractiveProcess "./test/ldap.js" [] Nothing
(Just [ ("PORT", show port)
, ("SSL_CERT", "./ssl/cert.pem")
, ("SSL_KEY", "./ssl/key.pem")
])
hGetLine out
return h)
(\h -> do terminateProcess h
waitForProcess h)
(\_ -> Ldap.with localhost port f)
localhost :: Host
localhost = Insecure "localhost"