Skip to content

Commit

Permalink
Handle duplicate test names
Browse files Browse the repository at this point in the history
  • Loading branch information
jdeppe-pivotal committed Nov 25, 2020
1 parent 82cd838 commit 7248b3c
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions cmd/core/hangs.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import (
)

type ProgressHangs struct {
tests map[string]string
tests map[string][]string
startTime *string
endTime *string
}

func NewProgressHangs() *ProgressHangs {
ph := &ProgressHangs{}
ph.tests = make(map[string]string)
ph.tests = make(map[string][]string)
return ph
}

Expand All @@ -30,20 +30,37 @@ func (this *ProgressHangs) ProcessLine(line string) {
state := parts[3]

if state == "Starting" {
this.tests[testName] = timeStamp
var val []string
var ok bool
if val, ok = this.tests[testName]; !ok {
val = make([]string, 0)
}

val = append(val, timeStamp)
this.tests[testName] = val

if this.startTime == nil {
this.startTime = &timeStamp
}
} else if state == "Completed" {
delete(this.tests, testName)
val := this.tests[testName]
lenVal := len(val)

if lenVal == 1 {
delete(this.tests, testName)
} else {
val = val[0:lenVal-1]
this.tests[testName] = val
}
}
}

func (this *ProgressHangs) Results() {
fmt.Printf("Started @ %s\n", *this.startTime)
for k, v := range this.tests {
fmt.Printf("%s %s\n", v, k)
for _, t := range v {
fmt.Printf("%s %s\n", t, k)
}
}
fmt.Printf("Ended @ %s\n", *this.endTime)

Expand Down

0 comments on commit 7248b3c

Please sign in to comment.