end2end

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Matcher

type Matcher struct {
	// Matches is a counter of matches for this matcher.
	// Expected to be set by the user.
	Matches int
	// contains filtered or unexported fields
}

Matcher is a single parsed magic comment that is used to match tested program output.

func (*Matcher) IsMatched

func (m *Matcher) IsMatched() bool

IsMatched reports whether m is matched at least once.

func (*Matcher) Match

func (m *Matcher) Match(s string) bool

Match tries to match s string against matcher pattern.

func (*Matcher) MatchWithLine

func (m *Matcher) MatchWithLine(s string, line int) bool

MatchWithLine does text+position matching.

Like Match, but also checks that m.Position().Line is equal to the provided line argument.

func (*Matcher) Position

func (m *Matcher) Position() token.Position

Position returns matcher comment text position.

func (*Matcher) Text

func (m *Matcher) Text() string

Text returns the matcher comment text.

type TestFile

type TestFile struct {
	// Matchers is a mapping from source code line to the
	// list of matchers for it.
	Matchers map[int][]*Matcher
	// contains filtered or unexported fields
}

TestFile represents parsed end2end test file.

func ParseTestFile

func ParseTestFile(filename string) (*TestFile, error)

ParseTestFile parses file at specified path using the parser with default settings.

func (*TestFile) Text

func (f *TestFile) Text() string

Text returns source code file contents that were used to create f.

type TestParser

type TestParser struct {
	// MatcherRE is used to distinguish comments that describe matchers
	// and also to capture their text.
	//
	// Regexp must include 2 capture groups:
	//	1. Matches [=~]. This determines the matcher kind (text or regexp)
	//	2. Matches text being matched. Usually something like ".*"
	//
	// If nil, defaultMatcherRE is used. You can use it as an example.
	MatcherRE *regexp.Regexp
}

TestParser is a end2end source file parser.

func (*TestParser) ParseFile

func (p *TestParser) ParseFile(filename string, r io.Reader) (*TestFile, error)

ParseFile parses everything from r using filename to make associations.

Jump to

Keyboard shortcuts

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