Commit Graph

322 Commits

Author SHA1 Message Date
832cc97037 parser/gotest: refactor parser so Parse is no longer a top level func
Making Parse a method on a Parser struct makes it possible to later
define an common parser interface.
2022-03-22 22:05:23 +00:00
0e7d095a28 gtr: add documentation to exported types and methods 2022-03-22 22:05:23 +00:00
5e492f8212 gtr: rename Package.AddProperty to Package.SetProperty
Properties are stored in a map, so SetProperty better reflects its
behaviour.
2022-03-22 22:05:23 +00:00
24c2ee41ce parser/gotest: refactor tests to run one test per input line 2022-03-22 22:05:23 +00:00
01e84dfcf5 Print arguments when non-flag arguments were set 2022-03-22 22:05:23 +00:00
884279de84 Deprecate the -go-version flag
The `-go-version` flag is used to set the `go.version` property in the
generated XML file. In v2 we no longer want a flag dedicated to a
specific property. Instead, the -prop flag has been introduced to set
arbitrary properties in the generated report.

If the `-go-version` flag is set, we'll still add a `go.version`
property to the report but also print a warning. This flag will be
removed completely in the future.
2022-03-22 22:05:23 +00:00
c50f4331dc Add -prop flag to add properties to a generated report
The value of the -prop flag should be specified as key=value. The -prop
flag only supports specifying one property at a time. To add multiple
properties, add a `-prop key=value` argument for each property.
2022-03-22 22:05:23 +00:00
10affc0da1 Store arbitrary key/value properties in Report 2022-03-22 22:05:23 +00:00
9aa9bd94d8 gtr: Remove unnecessary TODO
There's no need (yet) to check if output is potentially a build error,
as build errors are currently handled separately by the parser/gotest
package.
2022-03-22 22:05:23 +00:00
a77bfe0f1c gtr,junit: move creation of JUnit testsuites from gtr to junit
Package gtr shouldn't need to know about the existence of different
output formats like junit.
2022-03-22 22:05:23 +00:00
334044509c Remove custom properties parsed from test output
In the future it will be possible to add your own properties via
commandline flags.
2022-03-22 22:05:23 +00: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
a70d508a2e parser/gotest: support parsing test summaries when there were no tests 2022-03-20 22:35:50 +00:00
458fe89a9a Omit empty <properties> tag when there are no properties.
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.
2022-03-20 22:35:50 +00:00
43c784a63b Set non-zero exit code for build/run errors when using -set-exit-code 2022-03-20 22:35:50 +00:00
e6ab84c924 Add -iocopy flag to copy input to stdout
In order to use -iocopy to copy the input to stdout, you must provide a
file with the -out flag to write the XML report to.
2022-03-20 22:35:50 +00:00
aecba5f156 Add -in and -out flags to read input from file and write output to file 2022-03-20 22:35:50 +00:00
cbb95f301a Create exitf function to print message and exit with non-zero exit code 2022-03-20 22:35:50 +00:00
c8de8e11aa gtr: Remove unused findBenchmark function 2022-03-20 22:35:50 +00:00
0c57c726ce junit: Add documentation to the junit package 2022-03-20 22:35:50 +00:00
016e21634a gtr: Add documentation to ReportBuilder 2022-03-20 22:35:50 +00:00
6b85350845 parser/gotest: Refactor tests to test each line type specifically
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.
2022-03-20 22:35:50 +00:00
e2a7c1a394 parser/gotest: Add TODO to remove the build_output type 2022-03-20 22:35:50 +00:00
bab26d76b5 gtr: Write test output to JUnit SystemOut
Fixes #108
2022-03-20 22:35:50 +00:00
76f68922a2 junit: Output SystemOut and SystemErr contents as CDATA 2022-03-20 22:35:50 +00:00
7d75448298 gtr: Remove debug print 2022-03-20 22:35:50 +00:00
817a23b10d gtr: Handle end_test events without corresponding run_test event
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
2022-03-20 22:35:50 +00:00
014828bef4 junit: Correctly count skipped tests in junit Testsuite
Fixes #116
2022-03-20 22:35:50 +00:00
dde9ef5310 junit: Change JUnit Result Data field to cdata
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.
2022-03-20 22:35:50 +00:00
fc0a210dc9 junit: Make failures and errors required fields
Fixes #101
2022-03-20 22:35:50 +00:00
2ece8eae1a gtr: Set hostname and timestamp fields when creating JUnit Testsuite
Fixes #117
2022-03-20 22:35:50 +00:00
c3acdf13c2 parser/gotest: Remove unnecessary string concatenation in regexSummary 2022-03-20 22:35:50 +00:00
1069a04b9f parser/gotest: Fix failing build error test 2022-03-20 22:35:50 +00:00
cb7f773314 gtr: Add build error test case 2022-03-20 22:35:50 +00:00
80a9b62b38 gtr: Fix prefix trimming of test output 2022-03-20 22:35:50 +00:00
506a968ade gtr: Handle failed summary when no tests failed 2022-03-20 22:35:50 +00:00
4fdb6ca564 gtr: Move tests from build and runtime errors to end of junit report 2022-03-20 22:35:50 +00:00
8b3ee42692 Remove v1 parser and formatter tests from go-junit-report_test 2022-03-20 22:35:50 +00:00
d0cb4ab4a1 Remove unused toXML function from go-junit-report_test 2022-03-20 22:35:50 +00:00
0ff7cae1df Drop new properties when comparing against existing testdata 2022-03-20 22:35:50 +00:00
5007397e33 gtr: Reset active test when encountering a status line
This is to ensure that we don't append output lines that follow after a
status line to the last active test.
2022-03-20 22:35:50 +00:00
f7ae0905a2 gtr: Add support for pause/continue tests 2022-03-20 22:35:50 +00:00
c845dfac27 gtr: Correctly handle packages without tests 2022-03-20 22:35:50 +00:00
9167a5d41d gtr: Add support for runtime/init errors 2022-03-20 22:35:50 +00:00
ffc33941fa gtr, parser/gotest: Add support for build errors 2022-03-20 22:35:50 +00:00
b1b88456c1 gtr: Refactor ReportBuilder flush 2022-03-20 22:35:50 +00:00
52a5393fd3 gtr: Refactor ReportBuilder 2022-03-20 22:35:50 +00:00
3f9d5b62db gtr, parser/gotest: Move output formatting out of parser 2022-03-20 22:35:50 +00:00
08a21eb096 parser/gotest: Fix output trimming 2022-03-20 22:35:50 +00:00
1563e51b7c gtr: Fix testsuite duration 2022-03-20 22:35:50 +00:00