Documentation ¶
Overview ¶
Package shell allows to run commands in a shell.
Index ¶
- func GetExitCodeForRunCommandError(err error) (int, error)
- func RunCommand(t testing.TestingT, command Command)
- func RunCommandAndGetOutput(t testing.TestingT, command Command) string
- func RunCommandAndGetOutputE(t testing.TestingT, command Command) (string, error)
- func RunCommandAndGetStdOut(t testing.TestingT, command Command) string
- func RunCommandAndGetStdOutE(t testing.TestingT, command Command) (string, error)
- func RunCommandE(t testing.TestingT, command Command) error
- type Command
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetExitCodeForRunCommandError ¶
GetExitCodeForRunCommandError tries to read the exit code for the error object returned from running a shell command. This is a bit tricky to do in a way that works across platforms.
func RunCommand ¶
RunCommand runs a shell command and redirects its stdout and stderr to the stdout of the atomic script itself.
func RunCommandAndGetOutput ¶
RunCommandAndGetOutput runs a shell command and returns its stdout and stderr as a string. The stdout and stderr of that command will also be printed to the stdout and stderr of this Go program to make debugging easier.
func RunCommandAndGetOutputE ¶
RunCommandAndGetOutputE runs a shell command and returns its stdout and stderr as a string. The stdout and stderr of that command will also be printed to the stdout and stderr of this Go program to make debugging easier.
func RunCommandAndGetStdOut ¶ added in v0.17.2
RunCommandAndGetStdOut runs a shell command and returns solely its stdout (but not stderr) as a string. The stdout and stderr of that command will also be printed to the stdout and stderr of this Go program to make debugging easier. If there are any errors, fail the test.
func RunCommandAndGetStdOutE ¶ added in v0.17.2
RunCommandAndGetStdOutE runs a shell command and returns solely its stdout (but not stderr) as a string. The stdout and stderr of that command will also be printed to the stdout and stderr of this Go program to make debugging easier.
Types ¶
type Command ¶
type Command struct { Command string // The command to run Args []string // The args to pass to the command WorkingDir string // The working directory Env map[string]string // Additional environment variables to set // Use the specified logger for the command's output. Use logger.Discard to not print the output while executing the command. Logger *logger.Logger }
Command is a simpler struct for defining commands than Go's built-in Cmd.