Created
June 30, 2021 17:55
-
-
Save jahkeup/bc906fb0e5e3fa2fed3280e45c1a96fa to your computer and use it in GitHub Desktop.
go-test2json helper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # | |
| # collect-go-test-results.sh - build summary JSON from go test output | |
| # | |
| # usage: | |
| # | |
| # ./collect-go-test-results.sh # no flags, reads from STDIN | |
| # | |
| # example: | |
| # | |
| # ./collect-go-test-results.sh < ../some-go-test-output.txt | |
| # | |
| go tool test2json | | |
| jq -sS ' | |
| map( | |
| select(.Action == "pass" or .Action == "fail" or .Action == "skip")) | |
| | group_by(.Action) | |
| | map({(.[0].Action): map(.Test) | unique | sort }) | |
| | add | |
| | { summary: to_entries | |
| | map({(.key): .value | length}) | |
| | add | |
| } as $sum | |
| | . * $sum' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment