test-reporter icon indicating copy to clipboard operation
test-reporter copied to clipboard

gcov: error due to branch coverage (?): Error: strconv.Atoi: parsing "46*": invalid syntax

Open blueyed opened this issue 6 years ago • 0 comments

Running ./cc-test-reporter -d format-coverage -t gcov -o build/codeclimate.gcov.json ./build/CMakeFiles/awesome.dir results in:

DEBU[0000] coverage path ./build/CMakeFiles/awesome.dir
DEBU[0000] using formatter gcov
DEBU[0000] checking search path ./build/CMakeFiles/awesome.dir for GCov formatter
DEBU[0000] checking search path ./ for GCov formatter
INFO[0000] trimming with prefix /home/daniel/src/awesome/
DEBU[0000] getting fallback blob_id for source file build/awesome.c
Error: strconv.Atoi: parsing "46*": invalid syntax
Usage:
…

The error appears to be caused by "46*" in the .gcov file:

        -:   75:void
function awesome_atexit called 46 returned 100% blocks executed 62%
       46:   76:awesome_atexit(bool restart)
        -:   77:{
       46:   78:    lua_State *L = globalconf_get_lua_State();
call    0 returned 100%
       46:   79:    lua_pushboolean(L, restart);
call    0 returned 100%
       46:   80:    signal_object_emit(L, &global_signals, "exit", 1);
        -:   81:
        -:   82:    /* Move clients where we want them to be and keep the stacking order intact */
      46*:   83:    foreach(c, globalconf.stack)
call    0 returned 100%
branch  1 never executed
branch  2 never executed
branch  3 never executed
branch  4 never executed
branch  5 taken 0% (fallthrough)
branch  6 taken 100%
        -:   84:    {

This might be related to branch coverage, but is also there when using just gcov, without -b:

        -:   75:void
       46:   76:awesome_atexit(bool restart)
        -:   77:{
       46:   78:    lua_State *L = globalconf_get_lua_State();
       46:   79:    lua_pushboolean(L, restart);
       46:   80:    signal_object_emit(L, &global_signals, "exit", 1);
        -:   81:
        -:   82:    /* Move clients where we want them to be and keep the stacking order intact */
      46*:   83:    foreach(c, globalconf.stack)
        -:   84:    {

I could not find any documentation on how gcov should be invoked for Code Climate (C/C++), and if branch coverage is supported.

Also it was a bit tedious to figure out that apparently the directory with .gcov files is expected.

foreach is a macro:

#define foreach(var, array) \
    for(int __foreach_index_##var = 0; \
        __foreach_index_##var < (array).len; \
        __foreach_index_##var = (array).len) \
        for(typeof((array).tab) var = &(array).tab[__foreach_index_##var];  \
            (__foreach_index_##var < (array).len) &&                        \
            (var = &(array).tab[__foreach_index_##var]);                    \
            ++__foreach_index_##var)

Code Climate Test Reporter 0.6.3 (91112eb12ecb3c1cd1b91632a5fe120d6dfdc188 @ 2018-09-05T16:50:58+0000) gcov (GCC) 8.2.1 20181127

blueyed avatar Jan 09 '19 16:01 blueyed