Skip to content

Commit

Permalink
Stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
newhoggy committed Aug 3, 2020
1 parent 8d36cf4 commit 3e6cf5d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
1 change: 0 additions & 1 deletion cardano-cli/cardano-cli.cabal
Expand Up @@ -225,7 +225,6 @@ test-suite cardano-cli-test
Test.Pioneers.Exercise2
Test.Pioneers.Exercise3
Test.Pioneers.Exercise4
Test.Process

default-language: Haskell2010
default-extensions: NoImplicitPrelude
Expand Down
14 changes: 8 additions & 6 deletions cardano-node/test/Test/Cardano/Node/Chairman.hs
Expand Up @@ -14,15 +14,17 @@ import qualified Test.Common.Process as H

prop_spawnOneNode :: Property
prop_spawnOneNode = H.propertyOnce $ do
base <- H.getProjectBase

(_mIn, _mOut, _mErr, hProcess) <- H.createProcess =<< H.procNode
[ "run"
, "--database-path", "../db/node-2/"
, "--socket-path", "../socket/node-2-socket"
, "--database-path", base <> "/db/node-2/"
, "--socket-path", base <> "/socket/node-2-socket"
, "--port", "3002"
, "--topology", "../configuration/defaults/simpleview/topology-node-2.json"
, "--config", "../configuration/defaults/simpleview/config-2.yaml"
, "--signing-key", "../configuration/defaults/simpleview/genesis/delegate-keys.002.key"
, "--delegation-certificate", "../configuration/defaults/simpleview/genesis/delegation-cert.002.json"
, "--topology", base <> "/configuration/defaults/simpleview/topology-node-2.json"
, "--config", base <> "/configuration/defaults/simpleview/config-2.yaml"
, "--signing-key", base <> "/configuration/defaults/simpleview/genesis/delegate-keys.002.key"
, "--delegation-certificate", base <> "/configuration/defaults/simpleview/genesis/delegation-cert.002.json"
]

H.threadDelay 10000000
Expand Down
15 changes: 14 additions & 1 deletion cardano-node/test/Test/Common/Process.hs
Expand Up @@ -3,6 +3,7 @@

module Test.Common.Process
( createProcess
, getProjectBase
, procNode
, interruptProcessGroupOf
, waitForProcess
Expand All @@ -15,12 +16,14 @@ import Control.Monad.IO.Class
import Data.Bool
import Data.Function
import Data.Maybe (Maybe (..))
import Data.Semigroup ((<>))
import Data.String (String)
import GHC.Stack (HasCallStack)
import System.Exit (ExitCode)
import System.IO (Handle, IO)
import System.Process (CreateProcess (..), ProcessHandle)
import System.Process (CmdSpec (..), CreateProcess (..), ProcessHandle)

import qualified Data.List as L
import qualified GHC.Stack as GHC
import qualified Hedgehog as H
import qualified System.Environment as IO
Expand All @@ -30,6 +33,9 @@ createProcess :: HasCallStack
=> CreateProcess
-> H.PropertyT IO (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle)
createProcess cp = GHC.withFrozenCallStack $ do
case IO.cmdspec cp of
RawCommand cmd args -> H.annotate $ "Command line: " <> cmd <> " " <> L.intercalate " " args
ShellCommand cmd -> H.annotate $ "Command line: " <> cmd
H.evalM . liftIO $ IO.createProcess cp

interruptProcessGroupOf :: HasCallStack
Expand All @@ -55,3 +61,10 @@ procNode arguments = do
Just cardanoCli -> return $ IO.proc cardanoCli arguments
Nothing -> return $ IO.proc "cabal" ("exec":"--":"cardano-node":arguments)
return $ cp { IO.create_group = True }

getProjectBase :: H.PropertyT IO String
getProjectBase = do
maybeCardanoCli <- liftIO $ IO.lookupEnv "CARDANO_NODE_SRC"
case maybeCardanoCli of
Just path -> return path
Nothing -> return ".."
5 changes: 4 additions & 1 deletion nix/haskell.nix
Expand Up @@ -104,7 +104,10 @@ let
packages.cardano-cli.preCheck = "export CARDANO_CLI=${pkgSet.cardano-cli.components.exes.cardano-cli}/bin/cardano-cli";

# cardano-node-test depends on cardano-node
packages.cardano-node.preCheck = "export CARDANO_NODE=${pkgSet.cardano-node.components.exes.cardano-node}/bin/cardano-node";
packages.cardano-node.preCheck = "
export CARDANO_NODE=${pkgSet.cardano-node.components.exes.cardano-node}/bin/cardano-node
export CARDANO_NODE_SRC=${../}
";
}
{
packages = lib.genAttrs projectPackages
Expand Down

0 comments on commit 3e6cf5d

Please sign in to comment.