main shinobi / tests / runner / types.go
  1package main
  2
  3import (
  4	"bytes"
  5	"encoding/json"
  6	"fmt"
  7	"regexp"
  8)
  9
 10var makefilenamepattern = regexp.MustCompile(`\bt\d{3}\.mk\b`)
 11
 12type optionvalue struct {
 13	Shell string
 14	Args  []string
 15}
 16
 17func (o *optionvalue) UnmarshalJSON(data []byte) error {
 18	data = bytes.TrimSpace(data)
 19	if len(data) == 0 || bytes.Equal(data, []byte("null")) {
 20		return nil
 21	}
 22
 23	switch data[0] {
 24	case '[':
 25		return json.Unmarshal(data, &o.Args)
 26	case '"':
 27		return json.Unmarshal(data, &o.Shell)
 28	default:
 29		return fmt.Errorf("unsupported options value: %s", string(data))
 30	}
 31}
 32
 33type setupentry struct {
 34	Kind    string `json:"kind"`
 35	Mode    string `json:"mode"`
 36	MTime   int64  `json:"mtime"`
 37	Path    string `json:"path"`
 38	Content string `json:"content"`
 39	Target  string `json:"target"`
 40}
 41
 42type casemetadata struct {
 43	Case           string             `json:"case"`
 44	Category       string             `json:"category"`
 45	Command        string             `json:"command"`
 46	CompareOutput  bool               `json:"compare_output"`
 47	Cwd            string             `json:"cwd"`
 48	Description    string             `json:"description"`
 49	Details        string             `json:"details"`
 50	Env            map[string]*string `json:"env"`
 51	ExpectedExit   int                `json:"expected_exit"`
 52	MakefileName   string             `json:"makefile_name"`
 53	Options        optionvalue        `json:"options"`
 54	OptionsMode    string             `json:"options_mode"`
 55	OutputMode     string             `json:"output_mode"`
 56	Setup          []setupentry       `json:"setup"`
 57	Stdin          string             `json:"stdin"`
 58	Suite          string             `json:"suite"`
 59	TimeoutSeconds int                `json:"timeout_seconds"`
 60}
 61
 62type testcase struct {
 63	Meta         casemetadata
 64	RelPath      string
 65	MakeContents string
 66	ExpectedOut  string
 67}
 68
 69type suiteconfig struct {
 70	reporoot  string
 71	casesroot string
 72	makepath  string
 73	workroot  string
 74	temproot  string
 75	jobs      int
 76	keep      bool
 77	verbose   bool
 78	detail    bool
 79	list      bool
 80}
 81
 82type caseresult struct {
 83	Test          testcase
 84	Passed        bool
 85	ExitMatched   bool
 86	OutputMatched bool
 87	ExtraTmp      bool
 88}
 89
 90type categorysummary struct {
 91	Name        string
 92	Results     []caseresult
 93	PassedCases int
 94	FailedCases int
 95}
 96
 97type progressline struct {
 98	name         string
 99	totalcases   int
100	progresscols int
101	printedcols  int
102}