cmdtest

package
v0.0.0-...-3a12293 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: AGPL-3.0, Apache-2.0, CC-BY-SA-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package cmdtest provides tools for testing command line tools.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LeakCheck

func LeakCheck(c *check.C) func()

LeakCheck tests for output being leaked to os.Stdout and os.Stderr that should be sent elsewhere (e.g., the stdout and stderr streams passed to a cmd.RunFunc).

It redirects os.Stdout and os.Stderr to a tempfile, and returns a func, which the caller is expected to defer, that restores os.* and checks that the tempfile is empty.

Example:

func (s *Suite) TestSomething(c *check.C) {
	defer cmdtest.LeakCheck(c)()
	// ... do things that shouldn't print to os.Stderr or os.Stdout
}

Types

This section is empty.

Jump to

Keyboard shortcuts

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