The ReportBuilder was made specifically for building a gtr.Report from
parsed go test output. At this point it's unclear whether this will be
reusable if we ever introduce other parser. For now let's move it closer
to where it's used and let's not make it part of the public API yet.
In cases where a test result is not found, for example when a panic
happened, a dummy failing test is added to the report. Since we don't
know exactly what failed, its error message was simply "Run error". This
has been renamed to "Runtime error".
By default, the current local time is used when generating a Report. The
TimestampFunc Option makes it possible to override this default
behaviour. This can for example be used in tests to make sure the
timestamp is a fixed point in time.
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.
Go doesn't omit empty parent tags for empty values[1], so we'll work
around this for now by creating a pointer to the property slice.
[1]: https://github.com/golang/go/issues/7233.
This makes the tests more focused on each distinct type of line that is
recognized. Maintaining and extending these tests will also be less work
going forward.
When running `go test` without the `-v` flag, the output may not contain
everything that we expect. For example, no output is generated for
passing tests. Even for a failing test the output does not contain a
`=== RUN` line.
Currently, this resulted in us ignoring the test result since we
couldn't find an existing test to assign this result to. We should
however handle this situation gracefully, and just assume a test exists
when only encountering a test result line.
References #109
The Result Data field contains the test output that was read from stdin.
This used to be a chardata field, which escapes many characters in the
resulting XML. Writing this output with <![CDATA[]]> tags makes the raw
XML output much easier to read in e.g. a text editor.