Open tnir opened 2 years ago
Looks relevant to #488 to me.
@tnir
Thank you for the workaround in https://github.com/codeclimate/test-reporter/issues/495#issue-1291907813
:memo: jq 'walk(try .lines // .)' coverage/.resultset.json
also works for me.
Currently simplecov formatter checks .meta.simplecov_version
value in .resultset.json
and changes its behavior depending whether the version is above 0.18.0.
However, apparently simplecov does not output .meta.simplecov_version
to .resultset.json
as far as I confirmed.
If .meta.simplecov_version
does not exist, the program uses legacy formatter that does not support .lines
.
https://github.com/codeclimate/test-reporter/blob/22de46aa5f20cd3598fd28c76021c1a3e145bb9d/formatters/simplecov/json_formatter.go#L85 https://github.com/codeclimate/test-reporter/blob/22de46aa5f20cd3598fd28c76021c1a3e145bb9d/formatters/simplecov/json_formatter.go#L35-L46
However, apparently simplecov does not output .meta.simplecov_version to .resultset.json as far as I confirmed.
After a further investigation, I found simplecov writes coverage/coverage.json
only when CC_TEST_REPORTER_ID
environment variable is set (this feature was introduced in https://github.com/simplecov-ruby/simplecov/pull/950).
And cc-test-reporter format-coverage --input-type=simplecov
reads coverage/coverage.json
at first and fallbacks to coverage/.resultset.json
if the former does not exist.
So another possible workaround would be setting environment variable before testing.
CC_TEST_REPORTER_ID=xxx bundle exec rake test
What happens
cc-test-reporter format-coverage
fails with coverage results from SimpleCov 0.21.2 and minitest 5.16.1 as follows:Why
The following results should be handled without any error:
Currently it work well with the following results:
Workaround
jq 'map_values(. | map_values(if type=="object" then map_values(.lines) else . end))' coverage/.resultset.json
helped me work well.Environments