Code Monkey home page Code Monkey logo

Comments (8)

krocard avatar krocard commented on August 16, 2024

The problem was that gcov was first run without the -p (preserve-paths) option by the build system and then with the option by cpp-coveralls. As a result 2 types of .gcov were generated: with and without full path. This seems to confuse cpp-coveralls.

from cpp-coveralls.

krocard avatar krocard commented on August 16, 2024

The issue is still present, I was looking at the CHANGED tab instead of the ALL tab. All 0 code headers are still marked at 0%.

from cpp-coveralls.

MartinDelille avatar MartinDelille commented on August 16, 2024

👍

from cpp-coveralls.

krocard avatar krocard commented on August 16, 2024

TLTR: cpp-coveralls is not to blame, it is the server that needs to be fixed.

cpp-coveralls sends only covered and uncovered lines, it is coveralls server that calculates the coverage ration per file.

Running cpp-coveralls on a toy example:

FROM ubuntu
RUN apt-get update
RUN apt-get install -y python-pip gcc git
RUN pip install cpp-coveralls
WORKDIR /home

RUN echo 'class C {}; '              > empty.hpp
RUN echo 'int f() { return 0; }'     > main.hpp
RUN echo '#include "empty.hpp"'      > main.cpp
RUN echo '#include "main.hpp"'      >> main.cpp
RUN echo 'int main() { return 0; }' >> main.cpp
RUN g++ --coverage main.cpp && ./a.out
RUN coveralls --dryrun --verbose --gcov-options '\-lp'

Outputs (after formating) :

{ 'service_name': 'travis-ci',
  'git': {...},
  'source_files': [
    {'source': u'int f() { return 0; }\n',
               'name': 'main.hpp', 'coverage': [0]},
    {'source': u'#include "main.hpp"\n int main() { return 0; }\n',
               'name': 'main.cpp', 'coverage': [None, 1]}],
    {'source': u'class C {}; \n',
               'name': 'empty.hpp', 'coverage': [None]}],
  'service_job_id': ''}
}

As you can see each line has a corresponding coverage: the number of time executed or None if it is not an executable line.
See the official api documentation for more information about coveralls post format.

A file with 0 code line will be reported as a list of None not as a 0% or 100% covered file. As a result this issue can not be fix in cpp-coveralls. The statistic generator (on coveralls server) has to change it's coverage rate algorithm.

from cpp-coveralls.

krocard avatar krocard commented on August 16, 2024

I sent an email to coveralls. I hope they will be able to change this annoying behaviour.

from cpp-coveralls.

eddyxu avatar eddyxu commented on August 16, 2024

@krocard Sorry for the late reply. This is a awesome work. Thank you so much!

from cpp-coveralls.

krocard avatar krocard commented on August 16, 2024

Thanks @eddyxu, I hope it will motivate coveralls to address this issue.

from cpp-coveralls.

krocard avatar krocard commented on August 16, 2024

It seems that it is now fixed. coveralls now correctly displays 0 relevant line files as 100% covered!

from cpp-coveralls.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.