gtr,parser/gotest: move Event and building a report to parser/gotest

The Parse method now directly returns a report, rather than a list of
events that then need to be converted into a report. As part of this
change, the Event struct has also been moved to the gotest package. It's
now the responsibility of the parser to construct a gtr.Report.
This commit is contained in:
Joël Stemmer
2022-03-14 23:17:57 +00:00
parent 832cc97037
commit c78e04707f
9 changed files with 272 additions and 252 deletions

View File

@ -26,18 +26,17 @@ type ReportBuilder struct {
coverage float64 // coverage percentage
// default values
packageName string
PackageName string
}
// NewReportBuilder creates a new ReportBuilder.
func NewReportBuilder(packageName string) *ReportBuilder {
func NewReportBuilder() *ReportBuilder {
return &ReportBuilder{
tests: make(map[int]Test),
benchmarks: make(map[int]Benchmark),
buildErrors: make(map[int]Error),
runErrors: make(map[int]Error),
nextId: 1,
packageName: packageName,
}
}
@ -54,7 +53,7 @@ func (b *ReportBuilder) newId() int {
// benchmark did not end with a summary.
func (b *ReportBuilder) flush() {
if len(b.tests) > 0 || len(b.benchmarks) > 0 {
b.CreatePackage(b.packageName, "", 0, "")
b.CreatePackage(b.PackageName, "", 0, "")
}
}