test2json

package
v0.0.0-...-b04d5d2 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2024 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Possible values for Event.Action.
	ActionBench  = "bench"
	ActionCont   = "cont"
	ActionFail   = "fail"
	ActionOutput = "output"
	ActionPass   = "pass"
	ActionPause  = "pause"
	ActionRun    = "run"
	ActionSkip   = "skip"
)
View Source
const (
	PackageFullPath = modulePath + "/go/" + packageName
	TestName        = "TestCase"
	FailText        = "the test failed"

	ContentFail TestContent = `package test2json_test

import "testing"

func TestCase(t *testing.T) {
	t.Fatalf("the test failed")
}`
	ContentPass TestContent = `package test2json_test

import "testing"

func TestCase(t *testing.T) {
	t.Log("the test passed")
}`
	ContentSkip TestContent = `package test2json_test

import "testing"

func TestCase(t *testing.T) {
	t.Skip("no thanks!")
}`
	ContentNested TestContent = `` /* 476-byte string literal not displayed */

)

Variables

This section is empty.

Functions

func EventStream

func EventStream(r io.Reader) <-chan *Event

EventStream returns a channel which emits Events as they appear on the given io.Reader.

func SetupTest

func SetupTest(content TestContent) (tmpDir string, cleanup func(), err error)

SetupTest sets up a temporary directory containing a test file with the given content so that the caller may run `go test` in the returned directory. Returns the directory path and a cleanup function, or any error which occurred. SetupTest is intended to be used with any of the Content provided above, in which case EventStream/ParseEvent should generate the corresponding sequence of Events from above.

Types

type Event

type Event struct {
	Time    time.Time `json:",omitempty"`
	Action  string
	Package string  `json:",omitempty"`
	Test    string  `json:",omitempty"`
	Elapsed float64 `json:",omitempty"`
	Output  string  `json:",omitempty"`
}

Event represents a test event.

func ParseEvent

func ParseEvent(s string) (*Event, error)

type TestContent

type TestContent string

Jump to

Keyboard shortcuts

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