shell

package
v2.0.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: Apache-2.0 Imports: 13 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 RunCommandContext

func RunCommandContext(t testing.TestingT, ctx context.Context, command *Command)

RunCommandContext is like RunCommand but includes a context.

func RunCommandContextAndGetOutput

func RunCommandContextAndGetOutput(t testing.TestingT, ctx context.Context, command *Command) string

RunCommandContextAndGetOutput is like RunCommandAndGetOutput but includes a context.

func RunCommandContextAndGetOutputE

func RunCommandContextAndGetOutputE(t testing.TestingT, ctx context.Context, command *Command) (string, error)

RunCommandContextAndGetOutputE is like RunCommandAndGetOutputE but includes a context.

func RunCommandContextAndGetStdOut

func RunCommandContextAndGetStdOut(t testing.TestingT, ctx context.Context, command *Command) string

RunCommandContextAndGetStdOut is like RunCommandAndGetStdOut but includes a context.

func RunCommandContextAndGetStdOutE

func RunCommandContextAndGetStdOutE(t testing.TestingT, ctx context.Context, command *Command) (string, error)

RunCommandContextAndGetStdOutE is like RunCommandAndGetStdOutE but includes a context.

func RunCommandContextAndGetStdOutErr

func RunCommandContextAndGetStdOutErr(t testing.TestingT, ctx context.Context, command *Command) (stdout string, stderr string)

RunCommandContextAndGetStdOutErr is like RunCommandAndGetStdOutErr but includes a context.

func RunCommandContextAndGetStdOutErrE

func RunCommandContextAndGetStdOutErrE(t testing.TestingT, ctx context.Context, command *Command) (stdout string, stderr string, err error)

RunCommandContextAndGetStdOutErrE is like RunCommandAndGetStdOutErrE but includes a context.

func RunCommandContextE

func RunCommandContextE(t testing.TestingT, ctx context.Context, command *Command) error

RunCommandContextE is like RunCommandE but includes a context.

Types

type Command

type Command struct {
	// Use the specified logger for the command's output. Use logger.Discard to not print the output while executing the command.
	Logger     *logger.Logger
	Stdin      io.Reader
	Env        map[string]string // Additional environment variables to set
	Command    string            // The command to run
	WorkingDir string            // The working directory
	Args       []string          // The args to pass to the command
}

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

type ErrWithCmdOutput

type ErrWithCmdOutput struct {
	Underlying error
	Output     *output
}

ErrWithCmdOutput wraps an underlying error with the captured stdout and stderr from the command that produced it.

func (*ErrWithCmdOutput) Error

func (e *ErrWithCmdOutput) Error() string

Jump to

Keyboard shortcuts

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