Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- createProcess :: (MonadTest m, MonadResource m, HasCallStack) => CreateProcess -> m (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle, ReleaseKey)
- exec :: (MonadTest m, MonadIO m, HasCallStack) => ExecConfig -> String -> [String] -> m String
- execAny :: (MonadTest m, MonadIO m, HasCallStack) => ExecConfig -> String -> [String] -> m (ExitCode, String, String)
- exec_ :: (MonadTest m, MonadIO m, HasCallStack) => ExecConfig -> String -> [String] -> m ()
- execFlex :: (MonadTest m, MonadCatch m, MonadIO m, HasCallStack) => String -> String -> [String] -> m String
- execFlex' :: (MonadTest m, MonadCatch m, MonadIO m, HasCallStack) => ExecConfig -> String -> String -> [String] -> m String
- execFlexAny' :: (MonadTest m, MonadCatch m, MonadIO m, HasCallStack) => ExecConfig -> String -> String -> [String] -> m (ExitCode, String, String)
- procFlex :: (MonadTest m, MonadCatch m, MonadIO m, HasCallStack) => String -> String -> [String] -> m CreateProcess
- binFlex :: (MonadTest m, MonadIO m) => String -> String -> m FilePath
- getProjectBase :: (MonadTest m, MonadIO m) => m String
- waitForProcess :: (MonadTest m, MonadIO m, HasCallStack) => ProcessHandle -> m ExitCode
- maybeWaitForProcess :: (MonadTest m, MonadIO m, HasCallStack) => ProcessHandle -> m (Maybe ExitCode)
- getPid :: (MonadTest m, MonadIO m, HasCallStack) => ProcessHandle -> m (Maybe Pid)
- getPidOk :: (MonadTest m, MonadIO m, HasCallStack) => ProcessHandle -> m Pid
- waitSecondsForProcess :: (MonadTest m, MonadIO m, HasCallStack) => Int -> ProcessHandle -> m (Either TimedOut ExitCode)
- data ExecConfig = ExecConfig {
- execConfigEnv :: Last [(String, String)]
- execConfigCwd :: Last FilePath
- defaultExecConfig :: ExecConfig
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
.
:: (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.
execFlex' :: (MonadTest m, MonadCatch m, MonadIO m, HasCallStack) => ExecConfig -> String -> String -> [String] -> m String Source #
:: (MonadTest m, MonadCatch m, MonadIO m, HasCallStack) | |
=> ExecConfig | |
-> String |
|
-> String |
|
-> [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.
:: (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.
:: (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
.
ExecConfig | |
|