summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam T <pxqr.sta@gmail.com>2013-05-19 07:31:40 +0400
committerSam T <pxqr.sta@gmail.com>2013-05-19 07:31:40 +0400
commit3093d1ffb375b70e125bba4aacefa03d56d094c6 (patch)
tree5c0007c9081624f5773c5d2f9719a24a0d0394b6
parentc22a4f2a7cbb11c4904c3c9796335d1b34f3c601 (diff)
~ Run server from test client.
-rw-r--r--krpc.cabal3
-rw-r--r--tests/Client.hs18
2 files changed, 20 insertions, 1 deletions
diff --git a/krpc.cabal b/krpc.cabal
index bb3fdea6..446c612d 100644
--- a/krpc.cabal
+++ b/krpc.cabal
@@ -48,6 +48,9 @@ test-suite test-client
48 other-modules: Shared 48 other-modules: Shared
49 build-depends: base == 4.* 49 build-depends: base == 4.*
50 , bytestring 50 , bytestring
51 , process
52 , filepath
53
51 , krpc 54 , krpc
52 55
53 , HUnit 56 , HUnit
diff --git a/tests/Client.hs b/tests/Client.hs
index c2ac6d01..d762976d 100644
--- a/tests/Client.hs
+++ b/tests/Client.hs
@@ -1,8 +1,12 @@
1{-# LANGUAGE OverloadedStrings #-} 1{-# LANGUAGE OverloadedStrings #-}
2module Main (main) where 2module Main (main) where
3 3
4import Control.Concurrent
5import Control.Exception
4import qualified Data.ByteString as B 6import qualified Data.ByteString as B
5import System.Environment 7import System.Environment
8import System.Process
9import System.FilePath
6 10
7import Test.HUnit hiding (Test) 11import Test.HUnit hiding (Test)
8import Test.Framework 12import Test.Framework
@@ -15,8 +19,20 @@ import Shared
15addr :: RemoteAddr 19addr :: RemoteAddr
16addr = (0, 6000) 20addr = (0, 6000)
17 21
22withServ :: FilePath -> IO () -> IO ()
23withServ serv_path = bracket up terminateProcess . const
24 where
25 up = do
26 (_, _, _, h) <- createProcess (proc serv_path [])
27 threadDelay 1000000
28 return h
29
18main :: IO () 30main :: IO ()
19main = defaultMain tests 31main = do
32 let serv_path = "dist" </> "build" </> "test-server" </> "test-server"
33 withServ serv_path $
34 defaultMain tests
35
20 36
21(==?) :: (Eq a, Show a) => a -> IO a -> Assertion 37(==?) :: (Eq a, Show a) => a -> IO a -> Assertion
22expected ==? action = do 38expected ==? action = do