Skip to content
Permalink
Browse files

Add launcher tests

  • Loading branch information...
Anviking committed Mar 14, 2019
1 parent 2b15077 commit 93e32c4e048d332ef115cf1019dfaa7847defb05
@@ -0,0 +1,27 @@
import Control.Monad
( forM_ )
import Launcher
import Prelude
import System.Exit
( ExitCode (..) )
import Test.Hspec

main :: IO ()
main = hspec $ do
describe "Launcher.monitor" $ do
it "node + wallet" $ do
let commands =
[ Command "./app/launcher/mock/node-exit-0.sh" []
, Command "./app/launcher/mock/wallet.sh" []
]
running <- launch commands
(ProcessHasExited name code) <- monitor running
putStrLn "killing"
forM_ running kill
putStrLn "has killed"
name `shouldBe` cmdName (commands !! 0)
code `shouldBe` ExitSuccess
-- Not quite working

it "trivial" $
True `shouldBe` True
@@ -0,0 +1,4 @@
#!/usr/bin/env bash
echo "I'm a node (will exit 0)";
sleep $[ ( $RANDOM % 2 ) + 1 ]s;
exit 0;
@@ -0,0 +1,4 @@
#!/usr/bin/env bash
echo "I'm a node (will exit 1)";
sleep $[ ( $RANDOM % 2 ) + 1 ]s;
exit 1;
@@ -0,0 +1,2 @@
#!/usr/bin/env bash
while true; do echo "I'm a node"; sleep $[ ( $RANDOM % 2 ) + 1 ]s; done
@@ -0,0 +1,4 @@
#!/usr/bin/env bash
echo "I'm a wallet (will exit 0)";
sleep $[ ( $RANDOM % 2 ) + 1 ]s;
exit 0;
@@ -0,0 +1,4 @@
#!/usr/bin/env bash
echo "I'm a wallet (will exit 1)";
sleep $[ ( $RANDOM % 2 ) + 1 ]s;
exit 1;
@@ -0,0 +1,2 @@
#!/usr/bin/env bash
while true; do echo "I'm a wallet"; sleep $[ ( $RANDOM % 2 ) + 1 ]s; done
@@ -143,6 +143,34 @@ executable cardano-generate-mnemonic
main-is:
GenerateMnemonic.hs


test-suite launcher-tests
default-language:
Haskell2010
default-extensions:
NoImplicitPrelude
OverloadedStrings
ghc-options:
-threaded -rtsopts
-Wall
-O2
if (!flag(development))
ghc-options: -Werror
build-depends:
base
, hspec
, process
, async
type:
exitcode-stdio-1.0
hs-source-dirs:
app/launcher
app/cli
main-is:
LauncherSpec.hs
other-modules:
Launcher

test-suite unit
default-language:
Haskell2010

0 comments on commit 93e32c4

Please sign in to comment.
You can’t perform that action at this time.