Skip to content

Commit 83ca558

Browse files
committed
parser/gotest: Return created id from CreateTest method
1 parent 50c1179 commit 83ca558

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

parser/gotest/report_builder.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,13 @@ func (b *reportBuilder) Build() gtr.Report {
108108

109109
// CreateTest adds a test with the given name to the report, and marks it as
110110
// active.
111-
func (b *reportBuilder) CreateTest(name string) {
111+
func (b *reportBuilder) CreateTest(name string) int {
112112
if parentID, ok := b.findTestParentID(name); ok {
113113
b.parentIDs[parentID] = struct{}{}
114114
}
115115
id := b.newID()
116116
b.tests[id] = gtr.NewTest(id, name)
117+
return id
117118
}
118119

119120
// PauseTest marks the active context as no longer active. Any results or
@@ -140,8 +141,7 @@ func (b *reportBuilder) EndTest(name, result string, duration time.Duration, lev
140141
// test did not exist, create one
141142
// TODO: Likely reason is that the user ran go test without the -v
142143
// flag, should we report this somewhere?
143-
b.CreateTest(name)
144-
id = b.lastID
144+
id = b.CreateTest(name)
145145
}
146146

147147
t := b.tests[id]
@@ -164,8 +164,7 @@ func (b *reportBuilder) End() {
164164
func (b *reportBuilder) BenchmarkResult(name string, iterations int64, nsPerOp, mbPerSec float64, bytesPerOp, allocsPerOp int64) {
165165
id, ok := b.findTest(name)
166166
if !ok || b.tests[id].Result != gtr.Unknown {
167-
b.CreateTest(name)
168-
id = b.lastID
167+
id = b.CreateTest(name)
169168
}
170169

171170
benchmark := Benchmark{iterations, nsPerOp, mbPerSec, bytesPerOp, allocsPerOp}

0 commit comments

Comments
 (0)