Closed rynbrd closed 2 years ago
:+1:
@BlueDragonX with your last commit, if the file does not already exist, an error is raised:
Error opening file: open /tmp/circle-junit.7fwGXom/go-report.xml: no such file or directory
The normal usage is:
go test -v | go-junit-report > report.xml
Why not use tee for this?
go test -v | tee report.txt | go-junit-report > report.xml
Or
go test -v | tee -a report.txt | go-junit-report > report.xml
Your usage of tee outputs to a file. My update outputs to stdout.
Doesn't matter much. I'm now tee'ing to an intermediate file and cat'ing that to this tool.
Oh, that makes sense. You can use bash process substitution for this:
go test -v | tee >(go-junit-report > report.xml)
We can add that to the README.
The problem with that solution is that exit codes will travel through the pipe.
set -o pipefail
fixes that too
A full example without pipefail might look like:
(go test -v 2>&1 | tee tests.log && exit ${PIPESTATUS[0]}) | ./go-junit-report --package-name=golang.test.unit --set-exit-code > tests.junit.xml
How to use this on Windows builds?
I think flag to print input to stdout will help with cross platform scripts. Eg /dev/stderr
does not exist on Windows.
Thanks for the PR. The recently released v2.0.0 supports writing output to a file and writing the input to stdout. I no longer intend to maintain the old v1 branch, so I'm closing this PR.
I'd like to have the option to print the
go test
output as well as generate the report. This does that.This functionality is important because the regular
go test
output includes more details.