@@ -108,12 +108,13 @@ func (b *reportBuilder) Build() gtr.Report {
108
108
109
109
// CreateTest adds a test with the given name to the report, and marks it as
110
110
// active.
111
- func (b * reportBuilder ) CreateTest (name string ) {
111
+ func (b * reportBuilder ) CreateTest (name string ) int {
112
112
if parentID , ok := b .findTestParentID (name ); ok {
113
113
b .parentIDs [parentID ] = struct {}{}
114
114
}
115
115
id := b .newID ()
116
116
b .tests [id ] = gtr .NewTest (id , name )
117
+ return id
117
118
}
118
119
119
120
// 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
140
141
// test did not exist, create one
141
142
// TODO: Likely reason is that the user ran go test without the -v
142
143
// flag, should we report this somewhere?
143
- b .CreateTest (name )
144
- id = b .lastID
144
+ id = b .CreateTest (name )
145
145
}
146
146
147
147
t := b .tests [id ]
@@ -164,8 +164,7 @@ func (b *reportBuilder) End() {
164
164
func (b * reportBuilder ) BenchmarkResult (name string , iterations int64 , nsPerOp , mbPerSec float64 , bytesPerOp , allocsPerOp int64 ) {
165
165
id , ok := b .findTest (name )
166
166
if ! ok || b .tests [id ].Result != gtr .Unknown {
167
- b .CreateTest (name )
168
- id = b .lastID
167
+ id = b .CreateTest (name )
169
168
}
170
169
171
170
benchmark := Benchmark {iterations , nsPerOp , mbPerSec , bytesPerOp , allocsPerOp }
0 commit comments