Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruby coverage file path default #17

Open
borisrorsvort opened this issue Jan 9, 2023 · 8 comments
Open

Ruby coverage file path default #17

borisrorsvort opened this issue Jan 9, 2023 · 8 comments

Comments

@borisrorsvort
Copy link

borisrorsvort commented Jan 9, 2023

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.

coverage_file = "coverage/coverage.json",

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>
@andythigpen
Copy link
Owner

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

@borisrorsvort
Copy link
Author

Why not supporting the default formatter which is also json?

@andythigpen
Copy link
Owner

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.

@borisrorsvort
Copy link
Author

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

@andythigpen
Copy link
Owner

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.

@borisrorsvort
Copy link
Author

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

@andythigpen
Copy link
Owner

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

@noahsettersten
Copy link

noahsettersten commented Apr 18, 2023

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants