hw-polysemy-0.2.1.0: Opinionated polysemy library
Safe HaskellSafe-Inferred
LanguageGHC2021

HaskellWorks.Polysemy.Hedgehog.Process

Synopsis

Documentation

defaultExecConfig :: ExecConfig Source #

execFlex Source #

Arguments

:: Member (Embed IO) r 
=> Member Hedgehog r 
=> Member (Error GenericError) r 
=> Member (Error IOException) r 
=> Member Log r 
=> 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] 
-> Sem r (ExitCode, String, String)

exit code, stdout, stderr

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

execFlexOk :: Member (Embed IO) r => Member Hedgehog r => Member (Error GenericError) r => Member (Error IOException) r => Member Log r => String -> String -> [String] -> Sem r 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.

execOk :: Member (Embed IO) r => Member Hedgehog r => Member (Error GenericError) r => Member (Error IOException) r => Member Log r => ExecConfig -> String -> [String] -> Sem r 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.

execOk_ :: Member (Embed IO) r => Member Hedgehog r => Member (Error GenericError) r => Member (Error IOException) r => Member Log r => ExecConfig -> String -> [String] -> Sem r () Source #

Execute a process, returning ().

exec Source #

Arguments

:: Member (Embed IO) r 
=> Member Hedgehog r 
=> Member (Error GenericError) r 
=> Member (Error IOException) r 
=> Member Log r 
=> ExecConfig 
-> String

The binary to launch

-> [String]

The binary's arguments

-> Sem r (ExitCode, String, String)

exit code, stdout, stderr

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

procFlex Source #

Arguments

:: Member (Embed IO) r 
=> Member (Error GenericError) r 
=> Member (Error IOException) r 
=> Member Log r 
=> String

Cabal package name corresponding to the executable

-> String

Environment variable pointing to the binary to run

-> [String]

Arguments to the CLI command

-> Sem r 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.

procFlex' Source #

Arguments

:: Member (Embed IO) r 
=> Member (Error GenericError) r 
=> Member (Error IOException) r 
=> Member Log r 
=> ExecConfig 
-> String

Cabal package name corresponding to the executable

-> String

Environment variable pointing to the binary to run

-> [String]

Arguments to the CLI command

-> Sem r CreateProcess

Captured stdout

binFlex Source #

Arguments

:: Member (Embed IO) r 
=> Member (Error GenericError) r 
=> Member (Error IOException) r 
=> Member Log r 
=> String

Package name

-> String

Environment variable pointing to the binary to run

-> Sem r FilePath

Path to executable

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

waitSecondsForProcessOk :: Member Hedgehog r => Member (Embed IO) r => Member (Error GenericError) r => Member (Error IOException) r => Member Log r => Int -> ProcessHandle -> Sem r (Either TimedOut ExitCode) Source #

Wait a maximum of seconds secons for process to exit.