路径修复在Codecov:一些文件工作,其他不



我有一个项目,随便玩玩c++测试覆盖率。(https://github.com/adomasbaliuka/test_repository,问题是指提交58e2802f76e8eb7819209c9d518b0ffe76690d15和ca36a4fd0e38bc47204a155614c498936d43dc90)

问题涉及GitHub和Codecov。所以也许我应该问他们的支持,但StackOverflor有标签的这些东西,所以我认为它是好的。

使用编解码的覆盖率。io正在工作(https://app.codecov.io/gh/adomasbaliuka/test_repository)。但是,我希望看到实际的源代码和行覆盖率来测试codecov.io的这个特性。它在我的一个文件上工作得很好(test/test_main.cpp),但我不能让它在其他源文件上工作(src/version/version.cpp),即使编解码。io正确显示路径和上传的codecov.xml文件中的路径(我在CI运行中打印到控制台,因此它们也可以在GitHub Actions中查看)在概念上看起来完全相同:

(codecov.xml文件内容:

)
<?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>

特别地,xml中的文件路径是test_repository/tests/test_main.cpptest_repository/src/version/version.cpp。我完全不明白编解码的问题或区别。

codecov内部。io,点击文件src/version/version.cpp给我一个错误

GitHub API: Not Found

我试着做一些"路径修复",正如codecov建议的那样。这意味着包含一个顶级文件codecov.yml。我把

放到这个文件中
fixes:
- "test_repository/::"

我假设它将存储库的名称替换为"nothing"在小路上。这样做的结果是第一个文件仍然可以工作,而对于第二个文件,错误消息变为

好吧,这很尴尬,看起来我们有一个错误。

我不依赖于让这个功能在我所有的文件上工作,但是这种行为(文件之间的差异)对我来说很奇怪。什么好主意吗?

Tom来自Codecov。我想你可能需要做

fixes:
- "::/test_repository"

但我要完全诚实地说,我认为你根本不需要路径修复。

答案是有问题的文件甚至根本不在存储库中。它由CMake生成("配置"),以便包含从git信息中提取的当前版本。

事后回想起来,我的问题真的很愚蠢,我很抱歉浪费了大家的时间。不幸的是,这个问题中可能没有什么你可以从中学到的。

最新更新