xmake-io / xmake

🔥 A cross-platform build utility based on Lua
https://xmake.io
Apache License 2.0
10.04k stars 785 forks source link

Add support for code coverage of C++ code #586

Closed tapika closed 4 years ago

tapika commented 5 years ago

Is your feature request related to a problem? Please describe.

To have proper unit testing best approach is to use code coverage, which is apparently different for different compiler. It would be perfect if code coverage would work out of box in compiler independent manner.

See related information on reddit: https://developercommunity.visualstudio.com/content/problem/669232/linux-projects-incremental-build-does-not-recogniz.html

it would be good if code coverage tool would be able to work with report generator: https://github.com/danielpalme/ReportGenerator

As it's more or less compiler independent.

waruqi commented 5 years ago

You can add mode.coverage rule to enable coverage for different compiler. It support gcc/clang now. You can improve the following code to support more compilers.

https://github.com/xmake-io/xmake/blob/b7d21719c405866e1ebc6597cba561c577850ae6/xmake/rules/mode/xmake.lua#L115

add_rules("mode.coverage")
target("test")
    -- ...
xmake f -m coverage 
xmake
tapika commented 5 years ago

How about microsoft compiler ?

waruqi commented 5 years ago

Currently not supported, if you are interested, you can try to improve the following code.

https://github.com/xmake-io/xmake/blob/b7d21719c405866e1ebc6597cba561c577850ae6/xmake/rules/mode/xmake.lua#L115

tapika commented 5 years ago

May be not related to subject - but is it possible to debug xmake lua scripts using Visual studio or Visual studio code ?

waruqi commented 5 years ago

May be not related to subject - but is it possible to debug xmake lua scripts using Visual studio or Visual studio code ?

I don't know, you can install a vscode/lua plugin to try it, usually I call print directly to debug