28 Commits

Author SHA1 Message Date
Joël Stemmer
81e5aaaaf1 parser/gotest: Make sure every build error is processed
Make sure we don't ignore any build error that did not belong to a
package. This isn't expected to normally happen, but we need to handle
it anyway to prevent accidentally ignoring potential errors.

Refs #145
2022-09-17 01:09:15 +01:00
Joël Stemmer
cb3436fc5f parser/gotest: Do not ignore failures in a test summary
The ReportBuilder ignores summary results if we never collected any
events for that package. While under normal circumstances we wouldn't
expect this to happen (unless some output was lost or due to a bug in
go-junit-report), we should at the very least make sure that failed
results are not ignored.

Refs #145
2022-09-17 00:06:11 +01:00
Joël Stemmer
9357c180d4 parser/gotest: Add support for processing events for different packages
The reportBuilder assumed we were always processing events for a single
package at a time. This is not true however when running `go test -json
-race` for example. In order to properly support processing events from
different packages we now have packageBuilders per package name.

Fixes #134
2022-08-15 22:35:27 +01:00
Joël Stemmer
2af321a697 parser/gotest: Refactor benchmark grouping
The only reason groupBenchmarksByName needed the reportBuilder receiver
was to access its output collector. By passing the output explicitly to
the groupBenchmarksByName function we can remove the reportBuilder
dependency.
2022-08-15 22:05:38 +01:00
Joël Stemmer
b73e4a9ed5 parser/gotest: Remove unnecessary if statement when creating a package
We only execute this branch when we've captured some global output, so
no need to check that again.
2022-08-13 22:06:49 +01:00
Joël Stemmer
4ce910564c parser/gotest: timestampFunc should always be set, skip nil check 2022-08-13 21:59:50 +01:00
Joël Stemmer
1c826cb28d parser/gotest: Switch to output collector for active id tracking 2022-08-13 20:50:39 +01:00
Joël Stemmer
83ca558534 parser/gotest: Return created id from CreateTest method 2022-08-13 20:50:39 +01:00
Joël Stemmer
50c1179050 parser/gotest: Remove benchmark specific methods from reportBuilder 2022-08-13 20:50:39 +01:00
Joël Stemmer
d6bf22343d parser/gotest: Move event processing into reportBuilder 2022-08-13 20:48:36 +01:00
Joël Stemmer
ddf6b16828 Replace += 1 with ++ 2022-08-13 20:48:31 +01:00
Joël Stemmer
d75fb6d4c3 parser/gotest: Remove unused runErrors field from reportBuilder 2022-07-20 14:29:24 +01:00
Joël Stemmer
8648745762 parser/gotest: Don't ignore output when there were no tests
In some cases we may have captured some output for a package that didn't
have any tests. We should include it in the generated report as it may
contain useful information.
2022-06-26 00:43:05 +01:00
Joël Stemmer
da6551b8c0 gtr,parser/gotest: Remove gtr.Benchmark and use gtr.Test for all tests 2022-06-15 23:46:40 +01:00
Joël Stemmer
46e0aed494 gtr: Also look at failures in benchmarks when creating a package
When we encounter a failure but there was not failing test, we create a
failing dummy test in the report. This is to prevent the failure from
being overlooked.

The case where the output contained a failing benchmark was not handled
correctly, resulting in a dummy test failure being added to the report
unnecessarily.
2022-06-13 00:47:28 +01:00
Joël Stemmer
cb055227b7 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.
2022-06-08 23:01:01 +01:00
Joël Stemmer
d2480a6059 parser/gotest: Skip ID 0 when searching for existing tests or benchmarks 2022-06-08 23:01:01 +01:00
Joël Stemmer
2f7bf7c3bc parser/gotest: Set unique Test, Benchmark and Error ID's
This will be used later to collect and store output for the right tests.
2022-06-08 23:01:01 +01:00
Joël Stemmer
c87388ae59 parser/gotest,junit: Move benchmark grouping to parser/gotest package
Having multiple benchmarks for a single name is something specific to
the gotest output, so grouping benchmarks by name is not something that
belongs in the junit package.
2022-06-08 23:01:01 +01:00
Joël Stemmer
84074a188c parser/gotest: remove debugging printf from reportBuilder 2022-05-22 00:50:12 +01:00
Joël Stemmer
1b7027fde7 parser/gotest: add SubtestMode to configure how to deal with subtests 2022-05-22 00:32:17 +01:00
Joël Stemmer
6c038bc425 parser/gotest: never reset nextID in report builder to ensure unique ids 2022-05-21 23:29:24 +01:00
Joël Stemmer
01f41237f7 parser/gotest: continue with next item when we find a test or benchmark 2022-05-21 23:19:41 +01:00
Joël Stemmer
b5d2695c26 parser/gotest: return a separate bool instead of a negative id in find* 2022-05-21 22:26:00 +01:00
Joël Stemmer
f97910c4b9 parser/gotest: Make reportBuilder options private 2022-05-21 22:16:55 +01:00
Joël Stemmer
ae7e71c599 parser/gotest: rename Id -> ID 2022-05-21 18:48:07 +01:00
Joël Stemmer
a4c479dbbb gtr: Reset builder state after the end of a test or benchmark
The consequence of this is that any output emitted after the test or
benchmark result, will no longer belong to the last test. Instead it
will be appended to the global log. This is necessary to correctly
attribute output to the correct test or benchmark, for example in cases
where both tests and benchmarks appear.

In the past, Go test output printed test logs after the test result.
However, from Go 1.14 this behaviour was changed and test logs are now
printed before the test result.

With this commit, we effectively no longer support the old behaviour in
Go1.13 and earlier. The output will still appear in the generated
report, however it will no longer belong to the correct test.
2022-05-14 23:25:41 +01:00
Joël Stemmer
d84b066208 Move packages out of pkg/ 2022-04-20 19:39:05 +01:00