I have a project to casually play around with C++ test coverage. (https://github.com/adomasbaliuka/test_repository, question refers to commits 58e2802f76e8eb7819209c9d518b0ffe76690d15 and ca36a4fd0e38bc47204a155614c498936d43dc90)
The question concerns GitHub and Codecov.io, so maybe I should ask their support, but StackOverflor has tags for these things, so I assume it's OK.
The coverage with codecov.io is working (https://app.codecov.io/gh/adomasbaliuka/test_repository). However, I would like to see the actual source code and line coverage to also test this feature of codecov.io. It works fine on one of my files (test/test_main.cpp
) but I can't get it to work on the other source file (src/version/version.cpp
), even though codecov.io correctly displays both paths and the paths inside the uploaded codecov.xml
file (which I print to console in my CI runs, so they can also be viewed in the GitHub Actions) look conceptually exactly the same:
(codecov.xml
file contents:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE coverage SYSTEM 'http://cobertura.sourceforge.net/xml/coverage-04.dtd'>
<coverage line-rate="0.7613636363636364" branch-rate="0.33962264150943394" lines-covered="67" lines-valid="88" branches-covered="36" branches-valid="106" complexity="0.0" timestamp="1631309448" version="gcovr 4.2">
<sources>
<source>../../</source>
</sources>
<packages>
<package name="test_repository.build._deps.googletest-src.googletest.include.gtest" line-rate="0.2857142857142857" branch-rate="0.0" complexity="0.0">
<classes>
<class name="gtest_h" filename="test_repository/build/_deps/googletest-src/googletest/include/gtest/gtest.h" line-rate="0.2857142857142857" branch-rate="0.0" complexity="0.0">
<methods/>
<lines>
<line number="427" hits="0" branch="false"/>
<line number="435" hits="0" branch="false"/>
<line number="440" hits="0" branch="false"/>
<line number="441" hits="0" branch="false"/>
<line number="522" hits="0" branch="false"/>
<line number="2489" hits="2" branch="false"/>
<line number="2490" hits="2" branch="false"/>
</lines>
</class>
</classes>
</package>
<package name="test_repository.build._deps.googletest-src.googletest.include.gtest.internal" line-rate="0.85" branch-rate="0.2" complexity="0.0">
<classes>
<class name="gtest-internal_h" filename="test_repository/build/_deps/googletest-src/googletest/include/gtest/internal/gtest-internal.h" line-rate="0.8947368421052632" branch-rate="0.2" complexity="0.0">
<methods/>
<lines>
<line number="454" hits="8" branch="false"/>
<line number="461" hits="4" branch="false"/>
<line number="472" hits="4" branch="true" condition-coverage="50% (1/2)">
<conditions>
<condition number="0" type="jump" coverage="50%"/>
</conditions>
</line>
<line number="493" hits="4" branch="false"/>
<line number="494" hits="4" branch="false"/>
<line number="506" hits="16" branch="false"/>
<line number="508" hits="16" branch="true" condition-coverage="50% (1/2)">
<conditions>
<condition number="0" type="jump" coverage="50%"/>
</conditions>
</line>
<line number="521" hits="4" branch="false"/>
<line number="525" hits="4" branch="false"/>
<line number="527" hits="4" branch="false"/>
<line number="529" hits="4" branch="true" condition-coverage="33% (2/6)">
<conditions>
<condition number="0" type="jump" coverage="33%"/>
</conditions>
</line>
<line number="532" hits="0" branch="true" condition-coverage="0% (0/10)">
<conditions>
<condition number="0" type="jump" coverage="0%"/>
</conditions>
</line>
<line number="534" hits="4" branch="true" condition-coverage="50% (1/2)">
<conditions>
<condition number="0" type="jump" coverage="50%"/>
</conditions>
</line>
<line number="542" hits="4" branch="false"/>
<line number="546" hits="4" branch="false"/>
<line number="548" hits="4" branch="false"/>
<line number="550" hits="4" branch="true" condition-coverage="33% (2/6)">
<conditions>
<condition number="0" type="jump" coverage="33%"/>
</conditions>
</line>
<line number="553" hits="0" branch="true" condition-coverage="0% (0/10)">
<conditions>
<condition number="0" type="jump" coverage="0%"/>
</conditions>
</line>
<line number="555" hits="4" branch="true" condition-coverage="50% (1/2)">
<conditions>
<condition number="0" type="jump" coverage="50%"/>
</conditions>
</line>
</lines>
</class>
<class name="gtest-port_h" filename="test_repository/build/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h" line-rate="0.0" branch-rate="0.0" complexity="0.0">
<methods/>
<lines>
<line number="974" hits="0" branch="false"/>
</lines>
</class>
</classes>
</package>
<package name="test_repository.test_repository.src.version" line-rate="0.717391304347826" branch-rate="0.4107142857142857" complexity="0.0">
<classes>
<class name="version_cpp" filename="test_repository/test_repository/src/version/version.cpp" line-rate="0.717391304347826" branch-rate="0.4107142857142857" complexity="0.0">
<methods/>
<lines>
<line number="22" hits="3" branch="false"/>
<line number="24" hits="6" branch="true" condition-coverage="50% (1/2)">
<conditions>
<condition number="0" type="jump" coverage="50%"/>
</conditions>
</line>
<line number="25" hits="6" branch="false"/>
<line number="26" hits="3" branch="false"/>
<line number="27" hits="6" branch="true" condition-coverage="66% (4/6)">
<conditions>
<condition number="0" type="jump" coverage="66%"/>
</conditions>
</line>
<line number="28" hits="3" branch="true" condition-coverage="50% (1/2)">
<conditions>
<condition number="0" type="jump" coverage="50%"/>
</conditions>
</line>
<line number="30" hits="6" branch="false"/>
<line number="34" hits="1" branch="false"/>
<line number="36" hits="1" branch="true" condition-coverage="50% (1/2)">
<conditions>
<condition number="0" type="jump" coverage="50%"/>
</conditions>
</line>
<line number="37" hits="1" branch="false"/>
<line number="40" hits="1" branch="false"/>
<line number="42" hits="1" branch="true" condition-coverage="50% (1/2)">
<conditions>
<condition number="0" type="jump" coverage="50%"/>
</conditions>
</line>
<line number="43" hits="1" branch="false"/>
<line number="46" hits="1" branch="false"/>
<line number="48" hits="2" branch="true" condition-coverage="50% (1/2)">
<conditions>
<condition number="0" type="jump" coverage="50%"/>
</conditions>
</line>
<line number="50" hits="1" branch="true" condition-coverage="50% (1/2)">
<conditions>
<condition number="0" type="jump" coverage="50%"/>
</conditions>
</line>
<line number="52" hits="0" branch="false"/>
<line number="56" hits="2" branch="true" condition-coverage="50% (1/2)">
<conditions>
<condition number="0" type="jump" coverage="50%"/>
</conditions>
</line>
<line number="58" hits="1" branch="true" condition-coverage="50% (1/2)">
<conditions>
<condition number="0" type="jump" coverage="50%"/>
</conditions>
</line>
<line number="59" hits="0" branch="false"/>
<line number="62" hits="1" branch="true" condition-coverage="50% (1/2)">
<conditions>
<condition number="0" type="jump" coverage="50%"/>
</conditions>
</line>
<line number="63" hits="1" branch="true" condition-coverage="50% (1/2)">
<conditions>
<condition number="0" type="jump" coverage="50%"/>
</conditions>
</line>
<line number="64" hits="0" branch="false"/>
<line number="66" hits="1" branch="true" condition-coverage="50% (1/2)">
<conditions>
<condition number="0" type="jump" coverage="50%"/>
</conditions>
</line>
<line number="71" hits="1" branch="false"/>
<line number="73" hits="2" branch="true" condition-coverage="50% (1/2)">
<conditions>
<condition number="0" type="jump" coverage="50%"/>
</conditions>
</line>
<line number="75" hits="1" branch="true" condition-coverage="50% (1/2)">
<conditions>
<condition number="0" type="jump" coverage="50%"/>
</conditions>
</line>
<line number="77" hits="0" branch="false"/>
<line number="81" hits="2" branch="true" condition-coverage="50% (1/2)">
<conditions>
<condition number="0" type="jump" coverage="50%"/>
</conditions>
</line>
<line number="83" hits="1" branch="true" condition-coverage="50% (1/2)">
<conditions>
<condition number="0" type="jump" coverage="50%"/>
</conditions>
</line>
<line number="84" hits="1" branch="false"/>
<line number="87" hits="0" branch="true" condition-coverage="0% (0/2)">
<conditions>
<condition number="0" type="jump" coverage="0%"/>
</conditions>
</line>
<line number="89" hits="0" branch="true" condition-coverage="0% (0/2)">
<conditions>
<condition number="0" type="jump" coverage="0%"/>
</conditions>
</line>
<line number="90" hits="0" branch="false"/>
<line number="92" hits="0" branch="true" condition-coverage="0% (0/2)">
<conditions>
<condition number="0" type="jump" coverage="0%"/>
</conditions>
</line>
<line number="97" hits="1" branch="false"/>
<line number="99" hits="2" branch="true" condition-coverage="50% (1/2)">
<conditions>
<condition number="0" type="jump" coverage="50%"/>
</conditions>
</line>
<line number="101" hits="1" branch="true" condition-coverage="50% (1/2)">
<conditions>
<condition number="0" type="jump" coverage="50%"/>
</conditions>
</line>
<line number="103" hits="0" branch="false"/>
<line number="107" hits="2" branch="true" condition-coverage="50% (1/2)">
<conditions>
<condition number="0" type="jump" coverage="50%"/>
</conditions>
</line>
<line number="109" hits="1" branch="true" condition-coverage="50% (1/2)">
<conditions>
<condition number="0" type="jump" coverage="50%"/>
</conditions>
</line>
<line number="110" hits="1" branch="false"/>
<line number="113" hits="0" branch="true" condition-coverage="0% (0/2)">
<conditions>
<condition number="0" type="jump" coverage="0%"/>
</conditions>
</line>
<line number="115" hits="0" branch="true" condition-coverage="0% (0/2)">
<conditions>
<condition number="0" type="jump" coverage="0%"/>
</conditions>
</line>
<line number="116" hits="0" branch="false"/>
<line number="118" hits="0" branch="true" condition-coverage="0% (0/2)">
<conditions>
<condition number="0" type="jump" coverage="0%"/>
</conditions>
</line>
</lines>
</class>
</classes>
</package>
<package name="test_repository.test_repository.tests" line-rate="1.0" branch-rate="0.5" complexity="0.0">
<classes>
<class name="test_main_cpp" filename="test_repository/test_repository/tests/test_main.cpp" line-rate="1.0" branch-rate="0.5" complexity="0.0">
<methods/>
<lines>
<line number="12" hits="2" branch="false"/>
<line number="14" hits="2" branch="false"/>
<line number="15" hits="2" branch="false"/>
<line number="18" hits="8" branch="false"/>
<line number="21" hits="2" branch="false"/>
<line number="22" hits="2" branch="true" condition-coverage="50% (1/2)">
<conditions>
<condition number="0" type="jump" coverage="50%"/>
</conditions>
</line>
<line number="23" hits="2" branch="false"/>
<line number="24" hits="2" branch="false"/>
<line number="26" hits="8" branch="false"/>
<line number="27" hits="2" branch="true" condition-coverage="50% (2/4)">
<conditions>
<condition number="0" type="jump" coverage="50%"/>
</conditions>
</line>
<line number="28" hits="2" branch="true" condition-coverage="50% (2/4)">
<conditions>
<condition number="0" type="jump" coverage="50%"/>
</conditions>
</line>
<line number="30" hits="2" branch="false"/>
<line number="31" hits="2" branch="false"/>
<line number="32" hits="2" branch="false"/>
<line number="33" hits="2" branch="false"/>
</lines>
</class>
</classes>
</package>
</packages>
</coverage>
In particular, the paths of the files inside this xml
are test_repository/tests/test_main.cpp
and test_repository/src/version/version.cpp
. I totally don't understand the problem or difference that codecov.io could possibly see there.
Inside codecov.io, clicking on the file src/version/version.cpp
gives me an error
GitHub API: Not Found
I tried doing some "path fixing", as suggested by codecov.io, which means including a top level file codecov.yml
. I put inside this file
fixes:
- "test_repository/::"
which I assume replaces the name of the repository by "nothing" in the paths. The result of this was that the first file still worked, while for the second file the error message became
Well this is embarassing, looks like we had an error.
I don't depend on having this feature work on all my files, but this behaviour (difference between the files) is just bizarre to me. Any ideas?
Tom from Codecov here. I think you might need to do
fixes:
- "::/test_repository"
But I'll be totally honest, I don't think you need path fixes at all.