Skip to content

Instantly share code, notes, and snippets.

@jahkeup
Created June 30, 2021 17:55
Show Gist options
  • Select an option

  • Save jahkeup/bc906fb0e5e3fa2fed3280e45c1a96fa to your computer and use it in GitHub Desktop.

Select an option

Save jahkeup/bc906fb0e5e3fa2fed3280e45c1a96fa to your computer and use it in GitHub Desktop.
go-test2json helper
#!/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