diff options
Diffstat (limited to 'tests/Client.hs')
-rw-r--r-- | tests/Client.hs | 18 |
1 files changed, 17 insertions, 1 deletions
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 #-} |
2 | module Main (main) where | 2 | module Main (main) where |
3 | 3 | ||
4 | import Control.Concurrent | ||
5 | import Control.Exception | ||
4 | import qualified Data.ByteString as B | 6 | import qualified Data.ByteString as B |
5 | import System.Environment | 7 | import System.Environment |
8 | import System.Process | ||
9 | import System.FilePath | ||
6 | 10 | ||
7 | import Test.HUnit hiding (Test) | 11 | import Test.HUnit hiding (Test) |
8 | import Test.Framework | 12 | import Test.Framework |
@@ -15,8 +19,20 @@ import Shared | |||
15 | addr :: RemoteAddr | 19 | addr :: RemoteAddr |
16 | addr = (0, 6000) | 20 | addr = (0, 6000) |
17 | 21 | ||
22 | withServ :: FilePath -> IO () -> IO () | ||
23 | withServ serv_path = bracket up terminateProcess . const | ||
24 | where | ||
25 | up = do | ||
26 | (_, _, _, h) <- createProcess (proc serv_path []) | ||
27 | threadDelay 1000000 | ||
28 | return h | ||
29 | |||
18 | main :: IO () | 30 | main :: IO () |
19 | main = defaultMain tests | 31 | main = 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 |
22 | expected ==? action = do | 38 | expected ==? action = do |