go: cuelang.org/go/internal/cuetxtar Index | Files

package cuetxtar

import "cuelang.org/go/internal/cuetxtar"

Index

Package Files

txtar.go

func Load Uses

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.

type Test Uses

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

    // Buffer is used to write the test results that will be compared to the
    // golden file.
    *bytes.Buffer

    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 Uses

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 Uses

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

func (*Test) RawInstances Uses

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 Uses

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 Uses

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 Uses

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

func (*Test) WriteErrors Uses

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

WriteErrors writes strings and

func (*Test) WriteFile Uses

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

Write file in a directory.

type TxTarTest Uses

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 Uses

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.

Package cuetxtar imports 16 packages (graph) and is imported by 1 packages. Updated 2020-09-28. Refresh now. Tools for package owners.