parser/gotest: Improve gotest output handling

The reportBuilder has been updated to use the ordered output collector
to keep track of go test output. This makes it possible to include
benchmark output in the generated report and makes sure that output is
preserved when deleting subtest parents from the report.
This commit is contained in:
Joël Stemmer
2022-06-08 22:51:54 +01:00
parent 5331b9b8d6
commit cb055227b7
5 changed files with 56 additions and 40 deletions

View File

@ -325,14 +325,17 @@ func TestReport(t *testing.T) {
func TestSubtestModes(t *testing.T) {
events := []Event{
{Type: "run_test", Name: "TestParent"},
{Type: "output", Data: "TestParent output"},
{Type: "output", Data: "TestParent before"},
{Type: "run_test", Name: "TestParent/Subtest#1"},
{Type: "output", Data: "Subtest#1 output"},
{Type: "run_test", Name: "TestParent/Subtest#2"},
{Type: "output", Data: "Subtest#2 output"},
{Type: "cont_test", Name: "TestParent"},
{Type: "output", Data: "TestParent after"},
{Type: "end_test", Name: "TestParent", Result: "PASS", Duration: 1 * time.Millisecond},
{Type: "end_test", Name: "TestParent/Subtest#1", Result: "FAIL", Duration: 2 * time.Millisecond},
{Type: "end_test", Name: "TestParent/Subtest#2", Result: "PASS", Duration: 3 * time.Millisecond},
{Type: "output", Data: "output"},
{Type: "summary", Result: "FAIL", Name: "package/name", Duration: 1 * time.Millisecond},
}
@ -356,7 +359,7 @@ func TestSubtestModes(t *testing.T) {
Name: "TestParent",
Duration: 1 * time.Millisecond,
Result: gtr.Pass,
Output: []string{"TestParent output"},
Output: []string{"TestParent before", "TestParent after"},
},
{
ID: 2,
@ -373,6 +376,7 @@ func TestSubtestModes(t *testing.T) {
Output: []string{"Subtest#2 output"},
},
},
Output: []string{"output"},
},
},
},
@ -402,6 +406,7 @@ func TestSubtestModes(t *testing.T) {
Output: []string{"Subtest#2 output"},
},
},
Output: []string{"TestParent before", "TestParent after", "output"},
},
},
},