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

Strottie cpp cobertura

Open strottie opened this issue 1 year ago • 3 comments

The main goal is to add Cobertura support in C/C++ languages.

Cobertura was supported for PHP only but the implementation was skipping elements of the XML (when entering children, it would start with a "next" call and skip the first child). The custom APIs of the XML parsing implementation was very hard to follow so I reimplemented in a more structured top-down approach.

The new parser also supports extracting branch coverage information. Cobertura is now supported for C/C++ and PHP.

strottie avatar Jan 08 '24 20:01 strottie

Thank you for the PR. I tried running the PHP integration tests from this repo https://github.com/andythigpen/nvim-coverage-tests and it looks like there may be problems with the changes:

Fail    ||      languages.php places signs
            .../start/nvim-coverage/lua/coverage/parsers/corbertura.lua:53: error was NULL
            
            stack traceback:
                .../start/nvim-coverage/lua/coverage/parsers/corbertura.lua:53: in function 'update_coverage_with_current_line'
                .../start/nvim-coverage/lua/coverage/parsers/corbertura.lua:147: in function 'process_coverage_packages_element'
                .../start/nvim-coverage/lua/coverage/parsers/corbertura.lua:216: in function 'parser'
                ...te/pack/packer/start/nvim-coverage/lua/coverage/util.lua:129: in function 'cobertura_to_table'
                ...acker/start/nvim-coverage/lua/coverage/languages/php.lua:24: in function 'load'
                ...te/pack/packer/start/nvim-coverage/lua/coverage/init.lua:46: in function 'load_lang'
                ...te/pack/packer/start/nvim-coverage/lua/coverage/init.lua:77: in function 'load'
                /test/languages/php_spec.lua:26: in function </test/languages/php_spec.lua:22>

andythigpen avatar Mar 24 '24 15:03 andythigpen

Thanks Andrew for pointing at the UT, I'll investigate and get back with a fix.

strottie avatar Mar 26 '24 00:03 strottie

I've started investigating but I didn't get far yet because of issues getting the tests to run at all...

  • Packer is unable to install the xmlreader rock because it doesn't understand the new LuaJIT 2.1.x versioning scheme (see https://github.com/wbthomason/packer.nvim/issues/1266 -- but the mentioned --rolling21 option was never implemented, was not made public, or I didn't understand the workaround?!)
  • If I replace packer (now unmaintained) with Lazy:
    • I added a rockspec to nvim-coverage so Lazy can find the lua-xmlreader dependency
    • The Ubuntu luarocks package doesn't support the --dev argument used by Lazy
    • Not installing the luarocks package and letting Lazy use hererocks works and xmlreader gets installed
  • plenary's latest implementation runs each test in a very "minimal" environment, where rtp and package.path are not appropriate to let php_spec.lua require coverage or xmlreader
  • Doing require 'plugins' within the test isn't enough
  • Only the PlenaryBustedDirectory command has an opts argument that allows setting { minimal = false }, but that's not compatible with how the UT scripts are setup
  • ...

I'll continue fighting my way through when time permits again. Perhaps I'll hardcode rtp and package.path. Perhaps I can force loading an older plenary version.

Any idea is welcome.

Cheers.

P.S. My issues are not limited to running the PHP tests: e.g., Python tests have similar issues,

strottie avatar Aug 08 '24 01:08 strottie