v.io: v.io/x/ref/test/goroutines Index | Files

package goroutines

import "v.io/x/ref/test/goroutines"

Index

Package Files

goroutines.go

func Format Uses

func Format(gs ...*Goroutine) []byte

Format formats Goroutines back into the normal string representation.

func NoLeaks Uses

func NoLeaks(t ErrorReporter, wait time.Duration) func()

NoLeaks helps test that a test isn't leaving extra goroutines after it finishes.

The normal way to use it is: func TestFoo(t *testing.T) {

defer goroutines.NoLeaks(t, time.Second)()

... Normal test code here ...

}

The test will fail if there are goroutines running at the end of the test that weren't running at the beginning. Since testing for goroutines being finished can be racy, the detector can wait the specified duration for the set of goroutines to return to the initial set.

type ErrorReporter Uses

type ErrorReporter interface {
    Errorf(format string, args ...interface{})
}

ErrorReporter is used by NoLeaks to report errors. testing.T implements this interface and is normally passed.

type Frame Uses

type Frame struct {
    Call   string
    File   string
    Line   int
    Offset int
}

Frame represents a single stack frame.

type Goroutine Uses

type Goroutine struct {
    ID      int
    State   string
    Stack   []*Frame
    Creator *Frame
}

func Get Uses

func Get() ([]*Goroutine, error)

Get gets a set of currently running goroutines and parses them into a structured representation.

func Parse Uses

func Parse(buf []byte, ignore bool) ([]*Goroutine, error)

Parse parses a stack trace into a structure representation.

Package goroutines imports 9 packages (graph). Updated 2020-09-08. Refresh now. Tools for package owners.