Documentation ¶
Index ¶
- func Load(a *txtar.Archive, dir string, args ...string) []*build.Instance
- type Test
- func (t *Test) Bool(key string) bool
- func (t *Test) HasTag(key string) bool
- func (t *Test) RawInstances(args ...string) []*build.Instance
- func (t *Test) Rel(filename string) string
- func (t *Test) ValidInstances(args ...string) []*build.Instance
- func (t *Test) Value(key string) (value string, ok bool)
- func (t *Test) Write(b []byte) (n int, err error)
- func (t *Test) WriteErrors(err errors.Error)
- func (t *Test) WriteFile(f *ast.File)
- func (t *Test) Writer(name string) io.Writer
- type TxTarTest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 ¶
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) RawInstances ¶
RawInstances returns the intstances represented by this .txtar file. The returned instances are not checked for errors.
func (*Test) Rel ¶
Rel converts filename to a normalized form so that it will given the same output across different runs and OSes.
func (*Test) ValidInstances ¶
ValidInstances returns the valid instances for this .txtar file or skips the test if there is an error loading the instances.
func (*Test) WriteErrors ¶
WriteErrors writes strings and
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.