Skip to content

Commit

Permalink
XXX
Browse files Browse the repository at this point in the history
  • Loading branch information
adombeck committed Nov 4, 2024
1 parent 032d19e commit fb35bd4
Showing 1 changed file with 41 additions and 2 deletions.
43 changes: 41 additions & 2 deletions tools/gotestfmt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ done

LOGFILE="${LOGFILE:-$(mktemp -t gotestfmt.XXXXXX.log)}"
echo >&2 "Logging to $LOGFILE"
STDOUT_FILE=${LOGFILE}.raw
STDERR_FILE=$(mktemp -t gotestfmt.XXXXXX.stderr)
STDOUT_FILE=$(mktemp -t gotestfmt.XXXXXX.stdout)

strip_empty_coverage_lines() {
# This strips empty coverage lines from the output of `go test -cover -json`,
Expand All @@ -51,4 +52,42 @@ copy_output() {
tee "$STDOUT_FILE"
}

copy_output | strip_empty_coverage_lines | copy_to_logfile | gotestfmt --hide all <&0
copy_output | strip_empty_coverage_lines | copy_to_logfile | gotestfmt --hide all <&0 2> "$STDERR_FILE" || exit_code=$?

if [ -n "${GITHUB_WORKFLOW:-}" ]; then
echo "::group::stderr"
cat "$STDERR_FILE"
echo "::endgroup::"
echo "::group::stdout"
cat "$STDOUT_FILE"
echo "::endgroup::"
else
echo "##### Beginning of stderr #####"
cat "$STDERR_FILE"
echo "##### End of stderr #####"
echo "##### Beginning of stdout #####"
cat "$STDOUT_FILE"
echo "##### End of stdout #####"
fi

## If an error message was printed to stderr, that's an indicator that
## parsing the JSON output failed, so we print the raw output for debugging.
#if [ -n "${exit_code:-}" ] && [ -s "$STDERR_FILE" ]; then
# if [ -n "${GITHUB_WORKFLOW:-}" ]; then
# echo "::group::stderr"
# cat "$STDERR_FILE"
# echo "::endgroup::"
# echo "::group::stdout"
# cat "$STDOUT_FILE"
# echo "::endgroup::"
# else
# echo "##### Beginning of stderr #####"
# cat "$STDERR_FILE"
# echo "##### End of stderr #####"
# echo "##### Beginning of stdout #####"
# cat "$STDOUT_FILE"
# echo "##### End of stdout #####"
# fi
#fi

exit "${exit_code:-0}"

0 comments on commit fb35bd4

Please sign in to comment.