hedgehog-extras-0.6.0.0: Supplemental library for hedgehog
Safe HaskellSafe-Inferred
LanguageHaskell2010

Hedgehog.Extras.Test.Process

Synopsis

Documentation

createProcess :: (MonadTest m, MonadResource m, HasCallStack) => CreateProcess -> m (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle, ReleaseKey) Source #

Create a process returning handles to stdin, stdout, and stderr as well as the process handle.

exec :: (MonadTest m, MonadIO m, HasCallStack) => ExecConfig -> String -> [String] -> m String Source #

Execute a process, returning the stdout. Fail if the call returns with a non-zero exit code. For a version that doesn't fail upon receiving a non-zero exit code, see execAny.

execAny Source #

Arguments

:: (MonadTest m, MonadIO m, HasCallStack) 
=> ExecConfig 
-> String

The binary to launch

-> [String]

The binary's arguments

-> m (ExitCode, String, String)

exit code, stdout, stderr

Execute a process, returning the error code, the stdout, and the stderr.

exec_ :: (MonadTest m, MonadIO m, HasCallStack) => ExecConfig -> String -> [String] -> m () Source #

Execute a process, returning ().

execFlex :: (MonadTest m, MonadCatch m, MonadIO m, HasCallStack) => String -> String -> [String] -> m String Source #

Create a process returning its stdout.

Being a flex function means that the environment determines how the process is launched.

When running in a nix environment, the envBin argument describes the environment variable that defines the binary to use to launch the process.

When running outside a nix environment, the pkgBin describes the name of the binary to launch via cabal exec.

execFlexAny' Source #

Arguments

:: (MonadTest m, MonadCatch m, MonadIO m, HasCallStack) 
=> ExecConfig 
-> String

pkgBin: name of the binary to launch via 'cabal exec'

-> String

envBin: environment variable defining the binary to launch the process, when in Nix

-> [String] 
-> m (ExitCode, String, String)

exit code, stdout, stderr

Run a process, returning its exit code, its stdout, and its stderr. Contrary to execFlex', this function doesn't fail if the call fails. So, if you want to test something negative, this is the function to use.

procFlex Source #

Arguments

:: (MonadTest m, MonadCatch m, MonadIO m, HasCallStack) 
=> String

Cabal package name corresponding to the executable

-> String

Environment variable pointing to the binary to run

-> [String]

Arguments to the CLI command

-> m CreateProcess

Captured stdout

Create a CreateProcess describing how to start a process given the Cabal package name corresponding to the executable, an environment variable pointing to the executable, and an argument list.

The actual executable used will the one specified by the environment variable, but if the environment variable is not defined, it will be found instead by consulting the "plan.json" generated by cabal. It is assumed that the project has already been configured and the executable has been built.

binFlex Source #

Arguments

:: (MonadTest m, MonadIO m) 
=> String

Package name

-> String

Environment variable pointing to the binary to run

-> m FilePath

Path to executable

Compute the path to the binary given a package name or an environment variable override.

getProjectBase :: (MonadTest m, MonadIO m) => m String Source #

Compute the project base. This will be based on either the CARDANO_NODE_SRC environment variable or the first parent directory that contains the `cabal.project`. Both should point to the root directory of the Github project checkout.

waitForProcess :: (MonadTest m, MonadIO m, HasCallStack) => ProcessHandle -> m ExitCode Source #

Wait for process to exit.

maybeWaitForProcess :: (MonadTest m, MonadIO m, HasCallStack) => ProcessHandle -> m (Maybe ExitCode) Source #

Wait for process to exit or return Nothing if interrupted by an asynchronous exception.

getPid :: (MonadTest m, MonadIO m, HasCallStack) => ProcessHandle -> m (Maybe Pid) Source #

Get the process ID.

getPidOk :: (MonadTest m, MonadIO m, HasCallStack) => ProcessHandle -> m Pid Source #

Get the process ID.

waitSecondsForProcess :: (MonadTest m, MonadIO m, HasCallStack) => Int -> ProcessHandle -> m (Either TimedOut ExitCode) Source #

Wait a maximum of seconds secons for process to exit.

data ExecConfig Source #

Configuration for starting a new process. This is a subset of CreateProcess.

Instances

Instances details
Generic ExecConfig Source # 
Instance details

Defined in Hedgehog.Extras.Test.Process

Associated Types

type Rep ExecConfig :: Type -> Type #

Show ExecConfig Source # 
Instance details

Defined in Hedgehog.Extras.Test.Process

Eq ExecConfig Source # 
Instance details

Defined in Hedgehog.Extras.Test.Process

type Rep ExecConfig Source # 
Instance details

Defined in Hedgehog.Extras.Test.Process

type Rep ExecConfig = D1 ('MetaData "ExecConfig" "Hedgehog.Extras.Test.Process" "hedgehog-extras-0.6.0.0-AkIHpS6lSzKEoqF8MrgoXp" 'False) (C1 ('MetaCons "ExecConfig" 'PrefixI 'True) (S1 ('MetaSel ('Just "execConfigEnv") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Last [(String, String)])) :*: S1 ('MetaSel ('Just "execConfigCwd") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Last FilePath))))