Commit Graph

66 Commits

Author SHA1 Message Date
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
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
4ce910564c parser/gotest: timestampFunc should always be set, skip nil check 2022-08-13 21:59:50 +01:00
1c826cb28d parser/gotest: Switch to output collector for active id tracking 2022-08-13 20:50:39 +01:00
83ca558534 parser/gotest: Return created id from CreateTest method 2022-08-13 20:50:39 +01:00
50c1179050 parser/gotest: Remove benchmark specific methods from reportBuilder 2022-08-13 20:50:39 +01:00
9d434fa4b4 parser/gotest: Implement active id tracking in output collector 2022-08-13 20:50:39 +01:00
d6bf22343d parser/gotest: Move event processing into reportBuilder 2022-08-13 20:48:36 +01:00
ddf6b16828 Replace += 1 with ++ 2022-08-13 20:48:31 +01:00
5616b5e921 Add missing godoc on exported types 2022-08-11 00:47:46 +01:00
d75fb6d4c3 parser/gotest: Remove unused runErrors field from reportBuilder 2022-07-20 14:29:24 +01:00
01f2cdde22 parser/gotest: Use the new LimitedLineReader in the gotest parser 2022-07-18 23:02:22 +01:00
3e3223a05b parser/gotest: Create LimitedLineReader 2022-07-18 22:38:36 +01:00
80a51f2ed0 parser/gotest: Move const declaration to top of file 2022-07-18 22:37:49 +01:00
7fde4641ac Use ioutil package for compatibility with Go 1.13
We specify 1.13 in go.mod, so we should make sure it can be built and
tested on that version. Let's keep using the ioutil package for now,
since it was only deprecated from 1.16.
2022-07-01 22:53:57 +01:00
f643780c47 parser/gotest: Add tests for internal package collector 2022-06-26 14:23:58 +01:00
079e5ce7ea parser/gotest: Add support for parsing lines longer than 64K
The gotest parser used a bufio.Scanner to read its input, which
prevented us from reading lines larger than 64K.

In order to support reading larger lines, bufio.Scanner has been
replaced with bufio.Reader. The maximum line size has been increased to
4MiB and instead of returning an error when reading lines that exceed
the maximum size, we truncate that line and continue parsing.

Fixes #135
2022-06-26 00:45:06 +01:00
7875e13422 parser/gotest: Move NewParser function below Parser struct 2022-06-26 00:43:55 +01:00
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
da6551b8c0 gtr,parser/gotest: Remove gtr.Benchmark and use gtr.Test for all tests 2022-06-15 23:46:40 +01:00
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
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
5331b9b8d6 parser/gotest: Create output collector that preserves the line order 2022-06-08 23:01:01 +01:00
d2480a6059 parser/gotest: Skip ID 0 when searching for existing tests or benchmarks 2022-06-08 23:01:01 +01:00
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
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
84074a188c parser/gotest: remove debugging printf from reportBuilder 2022-05-22 00:50:12 +01:00
1b7027fde7 parser/gotest: add SubtestMode to configure how to deal with subtests 2022-05-22 00:32:17 +01:00
6c038bc425 parser/gotest: never reset nextID in report builder to ensure unique ids 2022-05-21 23:29:24 +01:00
01f41237f7 parser/gotest: continue with next item when we find a test or benchmark 2022-05-21 23:19:41 +01:00
b5d2695c26 parser/gotest: return a separate bool instead of a negative id in find* 2022-05-21 22:26:00 +01:00
f97910c4b9 parser/gotest: Make reportBuilder options private 2022-05-21 22:16:55 +01:00
ae7e71c599 parser/gotest: rename Id -> ID 2022-05-21 18:48:07 +01:00
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
df7394c77c Fix cmp.Diff argument order in tests 2022-05-13 21:45:38 +01:00
d84b066208 Move packages out of pkg/ 2022-04-20 19:39:05 +01:00
01c1e1fc30 Remove v1 parser and formatter packages
These packages are no longer used in go-junit-report and are no longer
maintained. They are still available in the most recent v1 version in
case you rely on them.
2022-03-22 22:05:16 +00:00
1b8b67371c Report testsuite failures even if all tests succeeded
Fixes #87
2019-10-03 23:53:41 +01:00
6315b3013b Parse package name output when test binary name is included
Sometimes, the text after "# " shows the name of the test binary
("<package>.test") in addition to the package
e.g.: "# package/name [package/name.test]".
This change ensures that the packages' build outputs are associated
correctly in this case.
2019-09-18 17:44:54 -07:00
9c3d9dadf6 Include test output and stdout in test failures 2018-12-21 13:39:33 -05:00
b4d81a975b Regex captures benchmarks with or without CPU suffix. 2018-06-07 22:19:32 -07:00
56afb484ae Move -count parameter to bench example and a little cleanup 2018-06-03 22:49:01 +01:00
1c2c0a00fe Adds multi-package benchmark support, simplifies merge benchmark averaging. Addressing code review comments. 2018-06-03 12:28:48 -07:00
260b47cabe Addressing code review comments.
Mainly:
* Moving the averaging/merging of benchmarks from the parser to the formatter package
* Tightening up the regex so it only captures the numeric values (no more of trimming spaces and the ns/op)
* Deleting the writing up in xml file the benchmark memory sections of B/op and Allocs/op

Also added a test case for parseNanoseconds().
2018-05-29 21:05:13 -07:00
b2f467b67c Adds ability to parse benchmarking information, and (optional) with memory information and with -count specified. Includes a number of unit tests. Issue #70. 2018-05-22 20:18:03 -07:00
1ce4b93a20 Deprecated Time field, use a time.Duration instead.
The parser.Package.Time and parser.Test.Time fields are currently still
supported, but will be removed in the future.
2018-04-21 18:15:02 +01:00
6e1ccef4d8 Add support for cached tests 2018-04-21 18:15:02 +01:00
766f2ff9bb Merge pull request #67 from mattdelco/upstream 2018-03-17 19:42:25 +00:00
d9db44172d Remove \s* prefix from regexStatus 2018-02-03 23:50:50 +00:00
0e171eb667 [rvelaz] Fix test report when the program writes to stdout 2018-01-05 17:25:13 +01:00