Skip to content

Commit

Permalink
clean up test flags and processing
Browse files Browse the repository at this point in the history
  • Loading branch information
verdverm committed Sep 9, 2020
1 parent 079c913 commit 57d6d6f
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
3 changes: 2 additions & 1 deletion lib/cuetils/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ func GetByAttrKeys(val cue.Value, attr string, all, any []string) ([]KeyVal, err
hasattr := false
for _, A := range attrs {
// does it have an "@<attr>(...)"
if A.Name() == attr {
if A.Name() == attr {

vals := A.Vals()

// must match all
Expand Down
4 changes: 2 additions & 2 deletions lib/test/from.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ func RunTestFromArgsFlags(args []string, cmdflags flags.TestFlagpole) (error) {
}

// Get test suites from top level
suites, err := getValueTestSuites(crt.CueValue, "suites", cmdflags.Suite)
suites, err := getValueTestSuites(crt.CueValue, cmdflags.Suite)
if err != nil {
return err
}

// find tests in suites
for s, suite := range suites {
ts, err := getValueTestSuiteTesters(suite.Value, suite.Name, cmdflags.Tester)
ts, err := getValueTestSuiteTesters(suite.Value, cmdflags.Tester)
if err != nil {
return err
}
Expand Down
11 changes: 9 additions & 2 deletions lib/test/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ func RunSuites(suites []Suite, verbose int) (TS Stats, err error) {

// loop over tests
for s, S := range suites {
// Short circuit for empty suites
if len(S.Tests) == 0 {
continue
}

// set start time
S.Stats.Start = time.Now()

Expand All @@ -25,8 +30,10 @@ func RunSuites(suites []Suite, verbose int) (TS Stats, err error) {
S.Errors = append(S.Errors, err)
}

// set the element again because of Go copy
// update total time
S.Stats.Time += T.Stats.Time

// set the element because of Go value copy in the loop header
S.Tests[t] = T
}

Expand All @@ -48,7 +55,7 @@ func RunTest(T *Tester, verbose int) (err error) {
// stats work
T.Stats.Start = time.Now()

// TODO< find and possibly skip
// TODO find and possibly skip
skip := T.Value.Lookup("skip")
if skip.Exists() {
doskip, err := skip.Bool()
Expand Down
6 changes: 3 additions & 3 deletions lib/test/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ type Suite struct {
Errors []error
}

func getValueTestSuites(val cue.Value, name string, labels []string) ([]Suite, error) {
vals, err := cuetils.GetByAttrKeys(val, "test", []string{"suite"}, labels)
func getValueTestSuites(val cue.Value, labels []string) ([]Suite, error) {
vals, err := cuetils.GetByAttrKeys(val, "test", append(labels, "suite"), nil)
suites := []Suite{}
for _, v := range vals {
suites = append(suites, Suite{Name: v.Key, Value: v.Val})
Expand Down Expand Up @@ -59,7 +59,7 @@ type Tester struct {
Errors []error
}

func getValueTestSuiteTesters(val cue.Value, name string, labels []string) ([]Tester, error) {
func getValueTestSuiteTesters(val cue.Value, labels []string) ([]Tester, error) {
vals, err := cuetils.GetByAttrKeys(val, "test", labels, []string{})
testers := []Tester{}
for _, v := range vals {
Expand Down
4 changes: 0 additions & 4 deletions test.cue
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,10 @@ hls: {

script: #GoBashTest @test(bash,test,script)
script: {
skip: true
dir: "script"
}
scriptC: #GoBashCover @test(bash,cover,script)
scriptC: {
skip: true
dir: "script"
}
}
Expand All @@ -105,12 +103,10 @@ lib: {

st: #GoBashTest @test(bash,test,st)
st: {
skip: true
dir: "lib/structural"
}
stC: #GoBashCover @test(bash,cover,st)
stC: {
skip: true
dir: "lib/structural"
}

Expand Down

0 comments on commit 57d6d6f

Please sign in to comment.