Skip to content

Commit

Permalink
Make sure process is terminated on failure in Launcher specs
Browse files Browse the repository at this point in the history
  • Loading branch information
KtorZ committed Jul 12, 2019
1 parent 39050fd commit f55b140
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ spec = do
expectPathEventuallyExist d
expectPathEventuallyExist (d <> "/testnet")
expectPathEventuallyExist (d <> "/wallet.db")
`finally` do
terminateProcess ph
TIO.hGetContents o >>= TIO.putStrLn
TIO.hGetContents e >>= TIO.putStrLn
Expand All @@ -83,6 +84,7 @@ spec = do
expectPathEventuallyExist d
expectPathEventuallyExist (d <> "/testnet")
expectPathEventuallyExist (d <> "/wallet.db")
`finally` do
terminateProcess ph
TIO.hGetContents o >>= TIO.putStrLn
TIO.hGetContents e >>= TIO.putStrLn
Expand All @@ -98,13 +100,15 @@ spec = do
waitForServer @t ctx
let pwd = "passphrase"
(_, out, _) <- createWalletViaCLI @t ctx ["n"] m "\n" pwd
expectValidJSON (Proxy @ApiWallet) out
`finally` do
terminateProcess ph
TIO.hGetContents o >>= TIO.putStrLn
TIO.hGetContents e >>= TIO.putStrLn
expectValidJSON (Proxy @ApiWallet) out
withCreateProcess process $ \_ (Just o) (Just e) ph -> do
waitForServer @t ctx
expectEventually' ctx state Ready wallet `finally` do
expectEventually' ctx state Ready wallet
`finally` do
terminateProcess ph
TIO.hGetContents o >>= TIO.putStrLn
TIO.hGetContents e >>= TIO.putStrLn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ spec = do
let process = proc' (commandName @t) args
withCreateProcess process $ \_ _ _ ph -> do
expectPathEventuallyExist db
`finally` do
terminateProcess ph
threadDelay oneSecond

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ spec = do
expectPathEventuallyExist (d <> "/jormungandr")
expectPathEventuallyExist (d <> "/jormungandr-config.json")
expectPathEventuallyExist (d <> "/wallet.db")
`finally` do
terminateProcess ph
TIO.hGetContents o >>= TIO.putStrLn
TIO.hGetContents e >>= TIO.putStrLn
Expand Down Expand Up @@ -146,16 +147,18 @@ spec = do
waitForServer @t ctx
let pwd = "passphrase"
(_, out, _) <- createWalletViaCLI @t ctx ["n"] m "\n" pwd
expectValidJSON (Proxy @ApiWallet) out
`finally` do
terminateProcess ph
TIO.hGetContents o >>= TIO.putStrLn
TIO.hGetContents e >>= TIO.putStrLn
expectValidJSON (Proxy @ApiWallet) out
withCreateProcess process $ \_ (Just o) (Just e) ph -> do
waitForServer @t ctx
expectEventually' ctx state Ready wallet `finally` do
terminateProcess ph
TIO.hGetContents o >>= TIO.putStrLn
TIO.hGetContents e >>= TIO.putStrLn
expectEventually' ctx state Ready wallet
`finally` do
terminateProcess ph
TIO.hGetContents o >>= TIO.putStrLn
TIO.hGetContents e >>= TIO.putStrLn

describe "DaedalusIPC" $ do
let defaultArgs =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import Prelude

import Control.Concurrent
( threadDelay )
import Control.Exception
( finally )
import Control.Monad
( forM_ )
import System.Exit
Expand Down Expand Up @@ -53,6 +55,7 @@ spec = do
let process = proc' (commandName @t) args
withCreateProcess process $ \_ _ _ ph -> do
expectPathEventuallyExist db
`finally` do
terminateProcess ph
threadDelay oneSecond

Expand Down

0 comments on commit f55b140

Please sign in to comment.