Reportgenerator: Cobertura: invalid error messages on file path

Created on 22 Nov 2017  路  12Comments  路  Source: danielpalme/ReportGenerator

Hi

When usig a Cobertura report, ReportGenerator emits messages like

 File 'users\fandre\documents\git\feature-gradle\xml\src\xmlexception.cpp' does not exist (any more).
 File 'users\fandre\documents\git\feature-gradle\xml\src\xmlfilter.cpp' does not exist (any more).
 File 'users\fandre\documents\git\feature-gradle\xml\src\xmlfilterimpl.cpp' does not exist (any more).

Those file are really alive with the path displayed except that the drive letter is missing. Thus, effectivly, the files with those paths do not exist, but their paths is missing the drive letter. It seems ReportGenerator is missing to take the <source> element into account.

<coverage line-rate="0.28407097905705148" branch-rate="0" complexity="0" branches-covered="0" branches-valid="0" timestamp="0" lines-covered="0" lines-valid="0" version="0">
  <sources>
    <source>c:</source>
    <source>f:</source>
  </sources>

        <class name="xmlexception.cpp" filename="users\fandre\documents\git\feature-gradle\xml\src\xmlexception.cpp" line-rate="1" branch-rate="0" complexity="0">
          <methods/>
          <lines>
            <line number="26" hits="1"/>
          </lines>
        </class>
bug

All 12 comments

@zosrothko

The <source> elements are taken into account by ReportGenerator.

If a single <source> element exists in the Cobertura file, then all _filenames_ are modified to start with that path.
If several <source> elements exist, then ReportGenerator iterates through all elements and modifies the _filenames_ to the first path that exists on disk.
In your case neither "c:\users\fandre\documents\git\feature-gradle\xml\src\xmlexception.cpp" nor "f:\users\fandre\documents\git\feature-gradle\xml\src\xmlexception.cpp" seem to exist on your disk.

In that case the _filename_ attribute is not modified and you get the mentioned warnings.

Can you please check if really both files do not exist:
c:\users\fandre\documents\git\feature-gradle\xml\src\xmlexception.cpp
f:\users\fandre\documents\git\feature-gradle\xml\src\xmlexception.cpp

Here you find the relevant source code of the path mapping:
https://github.com/danielpalme/ReportGenerator/blob/master/src/ReportGenerator.Console/Parser/Preprocessing/CoberturaReportPreprocessor.cs#L46

The file C:\users\fandre\documents\git\feature-gradle\xml\src\xmlexception.cpp exists but not the f::\users\fandre\documents\git\feature-gradle\xml\src\xmlexception.cppsince I do not have any disk labeled by F:

C:\Users\fandre\Documents\git\feature-gradle\XML\src>dir xmlexce*.cpp
 Le volume dans le lecteur C n鈥檃 pas de nom.
 Le num茅ro de s茅rie du volume est FCD5-3FB3

 R茅pertoire de C:\Users\fandre\Documents\git\feature-gradle\XML\src

25/10/2017  12:54               453 XMLException.cpp
               1 fichier(s)              453 octets
               0 R茅p(s)  139聽744聽669聽696 octets libres

C:\Users\fandre\Documents\git\feature-gradle\XML\src>

Forgot to mention that the Cobertura report is produced by the GitHub projet OpenCppCoverage

I will add some debug messages to find the root cause.
Will come back to you within the next days.

Could you please create the same report using this debug release:

DebugBuild_Issue115.zip

It would be great if you could post the log output in the console window.

Did you have a chance to try the debug build?

I will do the this weekend...too busy right now

Great. No need to hurry.

Here the test with the Issue115 binaries
ReportCoverage.log

@danielpalme I would like to give ReportGenerator a try. I am currently using OpenCppCoverage 0.9.7.0 to generate Cobertura XML reports, e.g.:

<?xml version="1.0" encoding="utf-8"?>
<coverage line-rate="0.95652173913043481" branch-rate="0" complexity="0" branches-covered="0" branches-valid="0" timestamp="0" lines-covered="22" lines-valid="23" version="0">
  <sources>
    <source>C:</source>
  </sources>
  <packages>
    <package name="C:\Users\Florian\CMakeBuilds\f79b87fd-4472-6039-9ba0-7d965c139278\build\x64-Debug\bin\test\personal_name_test.exe" line-rate="0.95652173913043481" branch-rate="0" complexity="0">
      <classes>
        <class name="personal_name.hpp" filename="Users\Florian\QsyncCloud\Documents\slides-cpp-testing\cpp-example-googletest\include\fw\greeter\personal_name.hpp" line-rate="0.95652173913043481" branch-rate="0" complexity="0">
          <methods/>
          <lines>
            <line number="49" hits="1"/>
            <line number="50" hits="1"/>
            <line number="51" hits="1"/>
            <line number="52" hits="1"/>
            <line number="53" hits="1"/>
            <line number="54" hits="1"/>
            <line number="56" hits="1"/>
            <line number="58" hits="1"/>
            <line number="60" hits="1"/>
            <line number="62" hits="1"/>
            <line number="63" hits="1"/>
            <line number="64" hits="1"/>
            <line number="65" hits="0"/>
            <line number="66" hits="1"/>
            <line number="68" hits="1"/>
            <line number="71" hits="1"/>
            <line number="72" hits="1"/>
            <line number="73" hits="1"/>
            <line number="76" hits="1"/>
            <line number="78" hits="1"/>
            <line number="79" hits="1"/>
            <line number="80" hits="1"/>
            <line number="83" hits="1"/>
          </lines>
        </class>
      </classes>
    </package>
  </packages>
</coverage>

ReportGenerator is invoked as follows:

ReportGenerator.exe -reports:personal_name_cobertura.xml -targetdir:ReportGenerator/report -reporttypes:HTML HTMLSummary HTMLInline HtmlInline_AzurePipelines HtmlInline_AzurePipelines_Dark HTMLChart MHTML Cobertura SonarQube XML XMLSummary Latex LatexSummary TeamCitySummary TextSummary CsvSummary PngChart Badges -historydir:ReportGenerator/history -verbosity:Warning

And the following warning is printed to the console:

File 'C:Users\Florian\QsyncCloud\Documents\slides-cpp-testing\cpp-example-googletest\include\fw\greeter\personal_name.hpp' does not exist (any more).

There seems to be an issue regarding file name concatenation and/or the input XML generated by OpenCppCoverage is invalid (I have no experience with that format).

@FlorianWolters
Please try again with release 4.1.4:
https://www.nuget.org/packages/ReportGenerator/4.1.4

@danielpalme Works! I've been able to integrate CMake, Google Test, OpenCppCoverage and ReportGenerator now.

Thanks!

Was this page helpful?
0 / 5 - 0 ratings