From 3093d1ffb375b70e125bba4aacefa03d56d094c6 Mon Sep 17 00:00:00 2001 From: Sam T Date: Sun, 19 May 2013 07:31:40 +0400 Subject: ~ Run server from test client. --- krpc.cabal | 3 +++ tests/Client.hs | 18 +++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) 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 other-modules: Shared build-depends: base == 4.* , bytestring + , process + , filepath + , krpc , 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 @@ {-# LANGUAGE OverloadedStrings #-} module Main (main) where +import Control.Concurrent +import Control.Exception import qualified Data.ByteString as B import System.Environment +import System.Process +import System.FilePath import Test.HUnit hiding (Test) import Test.Framework @@ -15,8 +19,20 @@ import Shared addr :: RemoteAddr addr = (0, 6000) +withServ :: FilePath -> IO () -> IO () +withServ serv_path = bracket up terminateProcess . const + where + up = do + (_, _, _, h) <- createProcess (proc serv_path []) + threadDelay 1000000 + return h + main :: IO () -main = defaultMain tests +main = do + let serv_path = "dist" "build" "test-server" "test-server" + withServ serv_path $ + defaultMain tests + (==?) :: (Eq a, Show a) => a -> IO a -> Assertion expected ==? action = do -- cgit v1.2.3