<commit_before># go-junit-report

go-junit-report is a tool that converts [`go test`] output to an XML report,
suitable for applications that expect JUnit-style XML reports (e.g. [Jenkins]).

The test output [parser] and JUnit report [formatter] are also available as Go
packages.

[![Build status][github-actions-badge]][github-actions-link]

## Install from package (recommended)

Pre-built packages for Windows, macOS and Linux are found on the [Releases]
page.

## Install from source

Download and install the latest stable version from source by running:

```bash
go install github.com/jstemmer/go-junit-report@latest
```

## Usage

go-junit-report reads the full `go test` output from stdin and writes JUnit
compatible XML to stdout. In order to capture build errors as well as test
output, redirect both stdout and stderr to go-junit-report.

```bash
go test -v 2>&1 | go-junit-report > report.xml
```

Parsing benchmark output is also supported, for example:

```bash
go test -v -bench . -count 5 2>&1 | go-junit-report > report.xml
```

If you want go-junit-report to exit with a non-zero exit code when it encounters
build errors or test failures, set the `-set-exit-code` flag.

Run `go-junit-report -help` for a list of all supported flags.

## Contributing

See [CONTRIBUTING.md].

[`go test`]: https://pkg.go.dev/cmd/go#hdr-Test_packages
[Jenkins]: https://www.jenkins.io/
[parser]: https://pkg.go.dev/github.com/jstemmer/go-junit-report/parser
[formatter]: https://pkg.go.dev/github.com/jstemmer/go-junit-report/formatter
[github-actions-badge]: https://github.com/jstemmer/go-junit-report/actions/workflows/main.yml/badge.svg
[github-actions-link]: https://github.com/jstemmer/go-junit-report/actions
[Releases]: https://github.com/jstemmer/go-junit-report/releases
[CONTRIBUTING.md]: https://github.com/jstemmer/go-junit-report/blob/master/CONTRIBUTING.md
<commit_msg>Update README.md for changes made in v2<commit_after># go-junit-report

go-junit-report is a tool that converts [`go test`] output to a JUnit compatible
XML report, suitable for use with applications such as [Jenkins].

[![Build status][github-actions-badge]][github-actions-link]

The test output parser and JUnit XML report generator are also available as Go
packages. This can be helpful if you want to create your own custom JUnit
reports for example. See the package documentation on pkg.go.dev for more
information:

- [go-junit-report/v2/pkg/parser/gotest]
- [go-junit-report/v2/pkg/junit]

## Install from package (recommended)

Pre-built packages for Windows, macOS and Linux are found on the [Releases]
page.

## Install from source

Download and install the latest stable version from source by running:

```bash
go install github.com/jstemmer/go-junit-report@latest
```

## Usage

By default, go-junit-report reads the `go test -v` output generated by the
standard library [testing] package from `stdin` and writes a JUnit XML report to
`stdout`. Go benchmark output and general Go build and runtime errors are also
supported. Note that in order to capture build and runtime errors, `stderr`
needs to be redirected to go-junit-report as well.

### Examples

Run tests for all packages in the current directory and its subdirectories,
write the output to a file called `report.xml` and exit with a non-zero exit
code when encountering any test failures or build errors.

```bash
go test -v 2>&1 ./... | go-junit-report -set-exit-code > report.xml
```

Run benchmarks for the package in the current directory, write the output to a
file called `report.xml`.

```bash
go test -v -bench . -count 5 2>&1 | go-junit-report -out report.xml
```

Read test input from a file called `tests.txt`, copy the input directly to
stdout and write the report to a file called `report.xml`.

```bash
go-junit-report -in tests.txt -iocopy -out report.xml
```

### Options

Run `go-junit-report -help` for a list of all supported options.

| Flag                  | Description                                                                     |
| --------------------  | -----------                                                                     |
| `-in file`            | read go test log from `file`                                                    |
| `-iocopy`             | copy input to stdout; can only be used in conjunction with -out                 |
| `-no-xml-header`      | do not print xml header                                                         |
| `-out file`           | write XML report to `file`                                                      |
| `-package-name name`  | specify a default package name to use if output does not contain a package name |
| `-prop key=value`     | add property to generated report; properties should be specified as `key=value` |
| `-set-exit-code`      | set exit code to 1 if tests failed                                              |
| `-version`            | print version and exit                                                          |

## Contributing

See [CONTRIBUTING.md].

[`go test`]: https://pkg.go.dev/cmd/go#hdr-Test_packages
[Jenkins]: https://www.jenkins.io/
[github-actions-badge]: https://github.com/jstemmer/go-junit-report/actions/workflows/main.yml/badge.svg
[github-actions-link]: https://github.com/jstemmer/go-junit-report/actions
[go-junit-report/v2/pkg/parser/gotest]: https://pkg.go.dev/github.com/jstemmer/go-junit-report/v2/pkg/parser/gotest
[go-junit-report/v2/pkg/junit]: https://pkg.go.dev/github.com/jstemmer/go-junit-report/v2/pkg/junit
[Releases]: https://github.com/jstemmer/go-junit-report/releases
[testing]: https://pkg.go.dev/testing
[CONTRIBUTING.md]: https://github.com/jstemmer/go-junit-report/blob/master/CONTRIBUTING.md

{'fraction_non_alphanumeric': 0.1171123929382975, 'fraction_numerical': 0.003146303093864709, 'mean_word_length': 2.7521311475409838, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, 'https://': 17, 'lorem ipsum': 0, 'www.': 2, 'xml': 10}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4057168', 'n_tokens_mistral': 1708, 'n_tokens_neox': 1633, 'n_words': 573}