From 83ca558534f7df07134c62c369119f44222ca865 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=ABl=20Stemmer?= Date: Sat, 13 Aug 2022 17:08:43 +0100 Subject: [PATCH] parser/gotest: Return created id from CreateTest method --- parser/gotest/report_builder.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/parser/gotest/report_builder.go b/parser/gotest/report_builder.go index d979c21..a2d6721 100644 --- a/parser/gotest/report_builder.go +++ b/parser/gotest/report_builder.go @@ -108,12 +108,13 @@ func (b *reportBuilder) Build() gtr.Report { // CreateTest adds a test with the given name to the report, and marks it as // active. -func (b *reportBuilder) CreateTest(name string) { +func (b *reportBuilder) CreateTest(name string) int { if parentID, ok := b.findTestParentID(name); ok { b.parentIDs[parentID] = struct{}{} } id := b.newID() b.tests[id] = gtr.NewTest(id, name) + return id } // 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 // test did not exist, create one // TODO: Likely reason is that the user ran go test without the -v // flag, should we report this somewhere? - b.CreateTest(name) - id = b.lastID + id = b.CreateTest(name) } t := b.tests[id] @@ -164,8 +164,7 @@ func (b *reportBuilder) End() { func (b *reportBuilder) BenchmarkResult(name string, iterations int64, nsPerOp, mbPerSec float64, bytesPerOp, allocsPerOp int64) { id, ok := b.findTest(name) if !ok || b.tests[id].Result != gtr.Unknown { - b.CreateTest(name) - id = b.lastID + id = b.CreateTest(name) } benchmark := Benchmark{iterations, nsPerOp, mbPerSec, bytesPerOp, allocsPerOp}