exectest

package
v0.0.0-...-8610112 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Command

func Command(t test.T, main func()) *exec.Cmd

Command builds an exec.Cmd that will run the given function as an external executable.

This operates by re-running the test executable to run only the current test, and hijacking that test execution to run the main function.

cmd := Command(t, func() { fmt.Println("hello") })
got, err := cmd.Output()
...
fmt.Println(string(got) == "hello\n") // true

func StartWithOutput

func StartWithOutput(t test.T, cmd *exec.Cmd) io.Reader

StartWithOutput starts the given command, and returns an io.Reader that reads from both, its stdout and stderr.

At test end, the system will ensure that the command finished running.

Types

This section is empty.

Jump to

Keyboard shortcuts

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