Skip to content

Commit

Permalink
Add parallel testing output update - not publicly releaseable as it o…
Browse files Browse the repository at this point in the history
…verrides default behavior
  • Loading branch information
thogarty committed Aug 20, 2024
1 parent 85bf471 commit 69b4b0f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
go-junit-report
build/
.idea
1 change: 1 addition & 0 deletions parser/gotest/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ func (e *Event) applyMetadata(m *reader.Metadata) {
return
}
e.Package = m.Package
e.Name = m.Test
}
3 changes: 2 additions & 1 deletion parser/gotest/internal/reader/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type LineReader interface {
// Metadata contains metadata that belongs to a line.
type Metadata struct {
Package string
Test string
}

// LimitedLineReader reads lines from an io.Reader object with a configurable
Expand Down Expand Up @@ -117,6 +118,6 @@ func (r *JSONEventReader) ReadLine() (string, *Metadata, error) {
// Skip events without output
continue
}
return strings.TrimSuffix(event.Output, "\n"), &Metadata{Package: event.Package}, nil
return strings.TrimSuffix(event.Output, "\n"), &Metadata{Package: event.Package, Test: event.Test}, nil
}
}
12 changes: 9 additions & 3 deletions parser/gotest/report_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,13 @@ func (b *reportBuilder) ProcessEvent(ev Event) {
b.CreateBuildError(ev.Name)
case "output":
if ev.Package != "" {
b.getPackageBuilder(ev.Package).Output(ev.Data)
pb := b.getPackageBuilder(ev.Package)
testName, _, _ := strings.Cut(ev.Data, " ")
id, found := pb.findTest(testName)
if !found {
id, _ = pb.findTest(ev.Name)
}
pb.Output(id, ev.Data)
} else {
b.output.Append(ev.Data)
}
Expand Down Expand Up @@ -443,8 +449,8 @@ func (b *packageBuilder) Coverage(pct float64, packages []string) {
}

// Output appends data to the output of this package.
func (b *packageBuilder) Output(data string) {
b.output.Append(data)
func (b *packageBuilder) Output(id int, data string) {
b.output.AppendToID(id, data)
}

// findTest returns the id of the most recently created test with the given
Expand Down

0 comments on commit 69b4b0f

Please sign in to comment.