test_explorer

package
v1.0.52 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2024 License: MIT Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TestingItemKind_Dir  = "dir"
	TestingItemKind_File = "file"
	TestingItemKind_Case = "case"
)

Variables

This section is empty.

Functions

func Main

func Main(args []string, opts *Options) error

Types

type BaseRequest

type BaseRequest struct {
	Name string `json:"name"`
	File string `json:"file"`
}

type CallRecord added in v1.0.48

type CallRecord struct {
	Pkg        string        `json:"pkg"`
	Func       string        `json:"func"`
	File       string        `json:"file"`
	Line       int           `json:"line"`  // 1-based
	Start      int64         `json:"start"` // relative to request begin, as nanoseconds
	End        int64         `json:"end"`
	Args       interface{}   `json:"args"`
	MockStatus MockStatus    `json:"mockStatus"`
	Error      string        `json:"error"`  // has error, may be empty
	Panic      bool          `json:"panic"`  // has panic
	Result     interface{}   `json:"result"` // keyed by name, if no name, a slice
	Log        interface{}   `json:"log"`    // log set within request
	Children   []*CallRecord `json:"children"`
}

type CoverageConfig added in v1.0.51

type CoverageConfig struct {
	Disabled bool     `json:"disabled"`
	DiffWith string   `json:"diff_with"`
	Profile  string   `json:"profile"`
	Include  []string `json:"include"`
	Exclude  []string `json:"exclude"`
}

by default enabled

type DebugDestroyRequest added in v1.0.38

type DebugDestroyRequest struct {
	ID string `json:"id"`
}

type DebugPollRequest added in v1.0.38

type DebugPollRequest struct {
	ID string `json:"id"`
}

type DebugPollResponse added in v1.0.38

type DebugPollResponse struct {
	Events []*TestingItemEvent `json:"events"`
}

type DebugRequest added in v1.0.38

type DebugRequest struct {
	Item *TestingItem `json:"item"`
	Path []string     `json:"path"`
}

type DebugResponse added in v1.0.38

type DebugResponse struct {
	ID string `json:"id"`
}

type DestroySessionRequest added in v1.0.38

type DestroySessionRequest struct {
	ID string `json:"id"`
}

type DetailRequest

type DetailRequest struct {
	*BaseRequest
	Line int `json:"line"`
}

type DetailResponse

type DetailResponse struct {
	Content string `json:"content"`
}

type Event

type Event string
const (
	Event_ItemStatus  Event = "item_status"
	Event_MergeTree   Event = "merge_tree"
	Event_Output      Event = "output"
	Event_ErrorMsg    Event = "error_msg"
	Event_TestStart   Event = "test_start"
	Event_TestEnd     Event = "test_end"
	Event_UpdateTrace Event = "update_trace"
)

type FuncInfoExport added in v1.0.48

type FuncInfoExport struct {
	// FullName string
	Kind         FuncKind
	Pkg          string
	IdentityName string
	Name         string
	RecvType     string
	RecvPtr      bool

	// interface method?
	Interface bool
	Generic   bool
	Closure   bool
	Stdlib    bool

	File string
	Line int

	RecvName string
	ArgNames []string
	ResNames []string

	// is first argument ctx
	FirstArgCtx bool
	// last last result error
	LastResultErr bool
}

type FuncKind added in v1.0.48

type FuncKind string
const (
	FuncKind_Func   FuncKind = "func"
	FuncKind_Var    FuncKind = "var"
	FuncKind_VarPtr FuncKind = "var_ptr"
	FuncKind_Const  FuncKind = "const"
)

type GoConfig

type GoConfig struct {
	Min string `json:"min"`
	Max string `json:"max"`
}

type HideType added in v1.0.41

type HideType string
const (
	HideType_None     HideType = ""
	HideType_All      HideType = "all"
	HideType_Children HideType = "children"
)

type MockStatus added in v1.0.48

type MockStatus string
const (
	MockStatus_NormalResp  MockStatus = "normal_resp"
	MockStatus_NormalError MockStatus = "normal_error"
	MockStatus_MockResp    MockStatus = "mock_resp"
	MockStatus_MockError   MockStatus = "mock_error"
)

type Options

type Options struct {
	// by default go
	DefaultGoCommand string
	GoCommand        string
	ProjectDir       string
	Exclude          []string
	Flags            []string
	Args             []string

	// can be true,false
	Coverage string
	// --coverage-profile string
	CoverageProfile  string
	CoverageDiffWith string

	Config string
	Port   string
	Bind   string

	LogConsole bool

	Verbose bool
}

type PollSessionRequest

type PollSessionRequest struct {
	ID string `json:"id"`
}

type PollSessionResult

type PollSessionResult struct {
	Events []*TestingItemEvent `json:"events"`
}

type RootExport added in v1.0.48

type RootExport struct {
	// current executed function
	Begin    time.Time
	Children []*StackExport
}

type RootRecord added in v1.0.48

type RootRecord struct {
	Start time.Time // the absolute begin time
	Root  *CallRecord
}

type RunContext added in v1.0.38

type RunContext struct {
	ProjectDir    string
	AbsProjectDir string
	File          string
	RelPath       string
	Name          string
	Stdout        io.Writer
	Stderr        io.Writer

	GoCmd      string
	BuildFlags []string

	Env  []string
	Args []string
}

type RunRequest

type RunRequest struct {
	*BaseRequest
	Path    []string `json:"path"`
	Verbose bool     `json:"verbose"`
}

type RunResult

type RunResult struct {
	Status RunStatus `json:"status"`
	Msg    string    `json:"msg"`
}

type RunStatus

type RunStatus string
const (
	RunStatus_NotRun  RunStatus = "not_run"
	RunStatus_Success RunStatus = "success"
	RunStatus_Fail    RunStatus = "fail"
	RunStatus_Error   RunStatus = "error"
	RunStatus_Running RunStatus = "running"
	RunStatus_Skip    RunStatus = "skip"
)

type StackExport added in v1.0.48

type StackExport struct {
	FuncInfo *FuncInfoExport

	Begin int64 // us
	End   int64 // us

	Args    interface{}
	Results interface{}

	// is recorded as snapshot
	Snapshot bool

	Panic bool
	Error string

	Children []*StackExport
}

type StartSessionRequest

type StartSessionRequest struct {
	Item  *TestingItem `json:"item"`
	Path  []string     `json:"path"`
	Debug bool         `json:"debug"`
	Trace bool         `json:"trace"`
}

type StartSessionResult

type StartSessionResult struct {
	ID string `json:"id"`
}

type TestConfig

type TestConfig struct {
	Go      *GoConfig              `json:"go"`
	GoCmd   string                 `json:"go_cmd"`
	Exclude []string               `json:"exclude"`
	Env     map[string]interface{} `json:"env"`

	// test flags passed to go test
	// common usages:
	//   -p=12            parallel programs
	//   -parallel=12     parallel test cases within the same test
	// according to our test, -p is more useful than -parallel
	Flags []string `json:"flags"`
	Args  []string `json:"args"`

	BypassGoFlags bool `json:"bypass_go_flags"`

	MockRules []string        `json:"mock_rules"`
	Xgo       *XgoConfig      `json:"xgo,omitempty"`
	Coverage  *CoverageConfig `json:"coverage,omitempty"`
}

func (*TestConfig) CmdEnv

func (c *TestConfig) CmdEnv() []string

func (*TestConfig) GetGoCmd added in v1.0.38

func (c *TestConfig) GetGoCmd() string

type TestEvent

type TestEvent struct {
	Time    time.Time // encodes as an RFC3339-format string
	Action  TestEventAction
	Package string
	Test    string
	Elapsed float64 // seconds
	Output  string
}

from go/cmd/test2json

type TestEventAction

type TestEventAction string

see https://pkg.go.dev/cmd/test2json#hdr-Output_Format

const (
	TestEventAction_Start  TestEventAction = "start"
	TestEventAction_Run    TestEventAction = "run"
	TestEventAction_Pass   TestEventAction = "pass"
	TestEventAction_Pause  TestEventAction = "pause"
	TestEventAction_Cont   TestEventAction = "cont"
	TestEventAction_Bench  TestEventAction = "bench"
	TestEventAction_Output TestEventAction = "output"
	TestEventAction_Fail   TestEventAction = "fail"
	TestEventAction_Skip   TestEventAction = "skip"
)

type TestingItem

type TestingItem struct {
	Key string `json:"key"`
	// base name, e.g.: subcase if full name is TestSomething/subcase
	Name string `json:"name"`
	// base case name, e.g.:  TestSomething
	BaseCaseName string `json:"baseCaseName"` // the base case's name
	// full name, e.g.: TestSomething/subcase
	NameUnderPkg string          `json:"nameUnderPkg"` // the name under pkg
	RelPath      string          `json:"relPath"`
	File         string          `json:"file"`
	Line         int             `json:"line"`
	Kind         TestingItemKind `json:"kind"`
	Error        string          `json:"error"`

	// only if Kind==dir
	// indicating any file ends with _test.go
	// go only
	HasTestGoFiles bool `json:"hasTestGoFiles"`

	// valid for Kind==dir,file
	// indicating any cases belongs to this item
	// go only
	HasTestCases bool              `json:"hasTestCases"`
	State        *TestingItemState `json:"state"`

	Children []*TestingItem `json:"children"`
}

TestingItem describe a test item when invoked from sub dir, relPath is relative to the sub dir

func (*TestingItem) CloneSelf added in v1.0.41

func (c *TestingItem) CloneSelf() *TestingItem

clone excluding children

type TestingItemEvent

type TestingItemEvent struct {
	Event        Event         `json:"event"`
	Item         *TestingItem  `json:"item"`
	Path         []string      `json:"path"`
	Status       RunStatus     `json:"status"`
	Msg          string        `json:"msg"`
	LogConsole   bool          `json:"logConsole"`
	TraceRecords []*CallRecord `json:"traceRecords"`
}

type TestingItemKind

type TestingItemKind string

func (TestingItemKind) Order added in v1.0.41

func (c TestingItemKind) Order() int

type TestingItemState added in v1.0.41

type TestingItemState struct {
	Selected  bool      `json:"selected"`
	Expanded  bool      `json:"expanded"`
	Status    RunStatus `json:"status"`
	Debugging bool      `json:"debugging"`
	Logs      string    `json:"logs"`
	HideType  HideType  `json:"hideType"`
}

func (*TestingItemState) Clone added in v1.0.41

func (c *TestingItemState) Clone() *TestingItemState

type XgoConfig added in v1.0.48

type XgoConfig struct {
	AutoUpdate bool `json:"auto_update"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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