nvim-coverage icon indicating copy to clipboard operation
nvim-coverage copied to clipboard

Ruby coverage file path default

Open borisrorsvort opened this issue 2 years ago • 8 comments

Seems the default cov file generated by simplecov is coverage/.resultset.json Tried with https://github.com/vicentllongo/simplecov-json that generate nvim-coverage current ruby cov path, but I get a error when loading the file. I also tried with renaming the default resultset to coverage and get the same error upon load.

https://github.com/andythigpen/nvim-coverage/blob/866008dc05bb71132e69c70aac19566d24d790d9/lua/coverage/config.lua#L102

the error:

Error executing vim.schedule lua callback: ...cker/start/nvim-coverage/lua/coverage/languages/ruby.lua:12: bad argument #1 to 'pairs' (table expected, got nil)
stack traceback:
        [C]: in function 'pairs'
        ...cker/start/nvim-coverage/lua/coverage/languages/ruby.lua:12: in function 'sign_list'
        ...te/pack/packer/start/nvim-coverage/lua/coverage/init.lua:51: in function 'callback'
        ...te/pack/packer/start/nvim-coverage/lua/coverage/util.lua:9: in function 'safe_decode'
        ...cker/start/nvim-coverage/lua/coverage/languages/ruby.lua:42: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

borisrorsvort avatar Jan 09 '23 11:01 borisrorsvort

The .resultset.json file appears to be a slightly different format than the SimpleCov::Formatter::JSONFormatter. There's an example in the integration test repo here: https://github.com/andythigpen/nvim-coverage-tests/blob/fe826486a0cd05c08e098836e80bad8483764d50/languages/ruby/spec/spec_helper.rb#L5-L6

JSONFormatter outputs to coverage/coverage.json by default. The docs can be found here: https://github.com/simplecov-ruby/simplecov#json-formatter

andythigpen avatar Jan 11 '23 02:01 andythigpen

Why not supporting the default formatter which is also json?

borisrorsvort avatar Jan 20 '23 09:01 borisrorsvort

I was not aware of the .resultset.json file when I added ruby support. That file appears to be part of the "merge test results" feature of simplecov. At least from what I can tell from this test case.

PRs are welcome if you'd like to add support for using that though. If you decide to go that route, it probably makes sense to make the option configurable so anyone currently using the JSONFormatter can continue to do so.

andythigpen avatar Jan 21 '23 19:01 andythigpen

@andythigpen Will try :) any idea about the error mentioned on top ?

borisrorsvort avatar Jan 23 '23 08:01 borisrorsvort

The error is due to the difference in formats mentioned above. The ruby module expects there to be a "coverage" field in the JSON object, which is not present at the top-level of the .resultset.json format.

andythigpen avatar Jan 29 '23 19:01 andythigpen

@andythigpen i get the same error using the coverage.json from the json formatter.

borisrorsvort avatar Jan 30 '23 07:01 borisrorsvort

Can you provide a small sample project that demonstrates the issue? Unfortunately I'm not able to reproduce it.

andythigpen avatar Jan 30 '23 13:01 andythigpen

I ran into a similar issue with reading the output from the JSON formatter myself. It turns out there are two gems that generate JSON output for simplecov (simplecov-json and simplecov_json_formatter) and they have different formats.

@andythigpen Your integration test pointed me to the simplecov_json_formatter as the correct gem to work with nvim-coverage. Thank you!

noahsettersten avatar Apr 18 '23 11:04 noahsettersten