shell

package
v0.18.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 25, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package shell allows to run commands in a shell.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetExitCodeForRunCommandError

func GetExitCodeForRunCommandError(err error) (int, error)

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

func RunCommand(t *testing.T, command Command)

RunCommand runs a shell command and redirects its stdout and stderr to the stdout of the atomic script itself.

func RunCommandAndGetOutput

func RunCommandAndGetOutput(t *testing.T, command Command) string

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

func RunCommandAndGetOutputE(t *testing.T, command Command) (string, error)

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

func RunCommandAndGetStdOut(t *testing.T, command Command) string

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

func RunCommandAndGetStdOutE(t *testing.T, command Command) (string, error)

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.

func RunCommandE

func RunCommandE(t *testing.T, command Command) error

RunCommandE runs a shell command and redirects its stdout and stderr to the stdout of the atomic script itself.

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
	OutputMaxLineSize int               // The max line size of stdout and stderr (in bytes)
}

Command is a simpler struct for defining commands than Go's built-in Cmd.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL