4 ms·
Just run "make cover" :) It does exactly what you want, and it handles overlapping coverage blocks (if two packages have tests that run the same portion of cod
by FiloSottile 10y ago
Just run "make cover" :)
It does exactly what you want, and it handles overlapping coverage blocks (if two packages have tests that run the same portion of code), which just concatenating will mess up. (It uses gocovmerge behind the scenes, but it will be hidden from you.)
- weitzj 10y agoAwesome! It would be nice to include something like go2xunit so you can hook the results up to the Jenkins coverage reports.
- FiloSottile 10y agoWe do that on the Cloudflare CI, but I deemed it too specific for hellogopher. (I can be convinced otherwise.) Instead, you run hellogopher with CI=1, and it drops logs and artifacts in fixed locations, that you can then post-process as you like.
- weitzj 10y agoAh. OK. Yeah. That works as well for me. Thank you
- weitzj 10y agoFor Jenkins compatible Junit test results you must run the concatenated stdout of your `go test` through: go2xunit -input "${test_outfile}" -output "${GO_TEST_JUNIT_FILENAME}" For Jenkins compatible coverage reports you must concatenate all cover profiles and use `gocov` for conversion: echo "creating coverage report" all_coverage_rawfile=$(mktemp tmptest.XXX) # concatenate all raw report echo -e "mode: atomic\n$(cat *.coverraw | grep -v 'mode: atomic')" > "${all_coverage_rawfile}" go tool cover -html="${all_coverage_rawfile}" -o "${GO_COVERAGE_FILENAME_HTML}" gocov convert "${all_coverage_rawfile}" | gocov-xml > "${GO_COVERAGE_FILENAME_XML}" Edit: fix typo