ritesting

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2020 License: MIT Imports: 4 Imported by: 0

README

GoDoc Build Status Coverage Status Go Report Card

redirect_tty

This will temporarily redirect the process TTY resources to support writing unit-tests directly against main() functions.

handled_exit

Can switch between os.Exit() and panicing a return-code. Supports testing main(). Requires calls to os.Exit() to call Exit() here instead.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DisableMarshaledExits

func DisableMarshaledExits()

DisableMarshaledExits disables exit marshaling.

func EnableMarshaledExits

func EnableMarshaledExits()

EnableMarshaledExits enables exit marshaling.

func Exit

func Exit(returnCode int)

Exit will marshal an exit into a panic if marshaling is turned on. If not turned on, forward through to `os.Exit()`.

func IsTtyRedirected

func IsTtyRedirected() bool

IsTtyRedirected returns whether the TTY is currently redirected.

func RedirectTty

func RedirectTty()

RedirectTty redirects STDIN, STDOUT, and STDERR to alternative resources. This allows us to create unit-tests for executables by directly calling their main() entrypoints.

func RestoreAndDumpTty

func RestoreAndDumpTty()

RestoreAndDumpTty restores original TTY resources but not before grabbing their screen output and then printing it before returning.

func RestoreTty

func RestoreTty()

RestoreTty restores original TTY resources.

func StderrReader

func StderrReader() *os.File

StderrReader returns a reader that can be used to read STDERR output (if redirected).

func StdinWriter

func StdinWriter() *os.File

StdinWriter returns a writer that can be used to feed STDIN data (if redirected).

func StdoutReader

func StdoutReader() *os.File

StdoutReader returns a reader that can be used to read STDOUT output (if redirected).

Types

This section is empty.

Jump to

Keyboard shortcuts

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