run

package
v0.7.11-27-gdbee4fb3 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2022, Unikraft GmbH and The KraftKit Authors. Licensed under the BSD-3-Clause License (the "License"). You may not use this file expect in compliance with the License.

Index

Constants

This section is empty.

Variables

View Source
var PrepareCmd = func(cmd *exec.Cmd) Runnable {
	return &cmdWithStderr{cmd}
}

PrepareCmd extends exec.Cmd with extra error reporting features and provides a hook to stub command execution in tests

Functions

func BootArgsPrepare added in v0.6.7

func BootArgsPrepare(args ...string) string

BootArgsPrepare prepares the boot arguments for the unikernel. Because of double parsing we need to be careful to escape each argument with either single or double quotes before merging them together.

Types

type CmdError

type CmdError struct {
	Stderr *bytes.Buffer
	Args   []string
	Err    error
}

CmdError provides more visibility into why an exec.Cmd had failed

func (CmdError) Error

func (e CmdError) Error() string

type CommandCallback

type CommandCallback func([]string)

type CommandStubber

type CommandStubber struct {
	// contains filtered or unexported fields
}

CommandStubber stubs out invocations to external commands.

func Stub

func Stub() (*CommandStubber, func(T))

Stub installs a catch-all for all external commands invoked from kraftkit. It returns a restore func that, when invoked from tests, fails the current test if some stubs that were registered were never matched.

func (*CommandStubber) Register

func (cs *CommandStubber) Register(pattern string, exitStatus int, output string, callbacks ...CommandCallback)

Register a stub for an external command. Pattern is a regular expression, output is the standard output from a command. Pass callbacks to inspect raw arguments that the command was invoked with.

type Runnable

type Runnable interface {
	Output() ([]byte, error)
	Run() error
}

Runnable is typically an exec.Cmd or its stub in tests

type T

type T interface {
	Helper()
	Errorf(string, ...interface{})
}

Jump to

Keyboard shortcuts

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