cuetxtar

package
v0.4.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load added in v0.2.2

func Load(a *txtar.Archive, dir string, args ...string) []*build.Instance

Load loads the intstances of a txtar file. By default, it only loads files in the root directory. Relative files in the archive are given an absolution location by prefixing it with dir.

Types

type Test

type Test struct {
	// Allow Test to be used as a T.
	*testing.T

	Archive *txtar.Archive

	// The absolute path of the current test directory.
	Dir string
	// contains filtered or unexported fields
}

A Test represents a single test based on a .txtar file.

A Test embeds *testing.T and should be used to report errors.

A Test also embeds a *bytes.Buffer which is used to report test results, which are compared against the golden file for the test in the TxTar archive. If the test fails and the update flag is set to true, the Archive will be updated and written to disk.

func (*Test) Bool

func (t *Test) Bool(key string) bool

Bool searches for a line starting with #key: value in the comment and returns true if the key exists and the value is true.

func (*Test) HasTag

func (t *Test) HasTag(key string) bool

func (*Test) RawInstances

func (t *Test) RawInstances(args ...string) []*build.Instance

RawInstances returns the intstances represented by this .txtar file. The returned instances are not checked for errors.

func (*Test) Rel

func (t *Test) Rel(filename string) string

Rel converts filename to a normalized form so that it will given the same output across different runs and OSes.

func (*Test) ValidInstances

func (t *Test) ValidInstances(args ...string) []*build.Instance

ValidInstances returns the valid instances for this .txtar file or skips the test if there is an error loading the instances.

func (*Test) Value

func (t *Test) Value(key string) (value string, ok bool)

func (*Test) Write added in v0.3.0

func (t *Test) Write(b []byte) (n int, err error)

func (*Test) WriteErrors

func (t *Test) WriteErrors(err errors.Error)

WriteErrors writes strings and

func (*Test) WriteFile added in v0.3.0

func (t *Test) WriteFile(f *ast.File)

Write file in a directory.

func (*Test) Writer added in v0.3.0

func (t *Test) Writer(name string) io.Writer

Writer returns a Writer with the given name.

type TxTarTest

type TxTarTest struct {
	// Run TxTarTest on this directory.
	Root string

	// Name is a unique name for this test. The golden file for this test is
	// derived from the out/<name> file in the .txtar file.
	//
	// TODO: by default derive from the current base directory name.
	Name string

	// If Update is true, TestTxTar will update the out/Name file if it differs
	// from the original input. The user must set the output in Gold for this
	// to be detected.
	Update bool

	// Skip is a map of tests to skip to their skip message.
	Skip map[string]string

	// ToDo is a map of tests that should be skipped now, but should be fixed.
	ToDo map[string]string
}

A TxTarTest represents a test run that process all CUE tests in the txtar format rooted in a given directory.

func (*TxTarTest) Run

func (x *TxTarTest) Run(t *testing.T, f func(tc *Test))

Run runs tests defined in txtar files in root or its subdirectories. Only tests for which an `old/name` test output file exists are run.

Jump to

Keyboard shortcuts

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