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

HaskellWorks.Polysemy.Hedgehog.Process

Synopsis

Documentation

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 HaskellWorks.Polysemy.Hedgehog.Process

Associated Types

type Rep ExecConfig :: Type -> Type #

Show ExecConfig Source # 
Instance details

Defined in HaskellWorks.Polysemy.Hedgehog.Process

Eq ExecConfig Source # 
Instance details

Defined in HaskellWorks.Polysemy.Hedgehog.Process

type Rep ExecConfig Source # 
Instance details

Defined in HaskellWorks.Polysemy.Hedgehog.Process

type Rep ExecConfig = D1 ('MetaData "ExecConfig" "HaskellWorks.Polysemy.Hedgehog.Process" "hw-polysemy-0.2.5.0-J9kaaFav8QWG5oNAyOWYmb-hedgehog" '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))))

execFlex Source #

Arguments

:: HasCallStack 
=> 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 :: HasCallStack => 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 :: HasCallStack => 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_ :: HasCallStack => 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

:: HasCallStack 
=> 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

:: HasCallStack 
=> 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

:: HasCallStack 
=> 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

:: HasCallStack 
=> 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 :: HasCallStack => Member Hedgehog r => Member (Embed IO) r => Member (Error GenericError) r => Member (Error IOException) r => Member Log r => Int -> ProcessHandle -> Sem r ExitCode Source #

Wait a maximum of seconds secons for process to exit.