Issue Details (XML | Word | Printable)

Key: HUDSON-5235
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: stephenconnolly
Reporter: jbargiel
Votes: 1
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Hudson

Cobertura returns "Source code is unavailable." for XML from gcovr

Created: 11/Jan/10 02:05 PM   Updated: 11/Mar/10 05:50 PM   Resolved: 11/Mar/10 05:50 PM
Component/s: cobertura
Affects Version/s: None
Fix Version/s: current

Environment: Linux Fedora 5 / i386


 Description  « Hide

Cobertura is unable to display painted source code when code coverage XML is generated from the Unix command line "gcovr -x" and the plugin configuration is set to correct xml report pattern. Error is:

Source code is unavailable. Some possible reasons are:

  • This is not the most recent build (to save on disk space, this plugin only keeps the most recent build's source code).
  • Cobertura found the source code but did not provide enough information to locate the source code.
  • Cobertura could not find the source code, so this plugin has no hope of finding it.

The code coverage XML data file is located in the same directory as the source file.
Note that the Trend diagram, Package Coverage Summary, File Coverage Summary, Class Coverage Summary display normally.



Sort Order: Ascending order - Click to sort in descending order
davidmc24 added a comment - 05/Feb/10 09:33 AM

At the time when you experienced this issue, was the project's build "unstable" (yellow ball icon)? If so, this is likely a duplicate of issue 4803.


plamot added a comment - 08/Feb/10 02:35 AM

actually it doesn't work with stable project either.

I tried different ways to invoque gcovr:

If I use the "-r" option which define the root project (it will set the source section in the generated cobertura report and files path are relative), cobertura fails during the build, the report is created but sources aren't available

+ gcovr -x -r /var/lib/hudson/jobs/testgcov/workspace -o coverage.xml
HERE gcov --branch-counts --branch-probabilities --preserve-paths main
Publishing Cobertura coverage report...
Publishing Cobertura coverage results...
ERROR: ERROR: Failure to paint /var/lib/hudson/jobs/testgcov/workspace/main.cpp to /var/lib/hudson/jobs/testgcov/cobertura
java.io.IOException: Failed to mkdirs:
at hudson.FilePath.mkdirs(FilePath.java:739)
at hudson.plugins.cobertura.renderers.SourceCodePainter.paintSourceCode(SourceCodePainter.java:39)
at hudson.plugins.cobertura.renderers.SourceCodePainter.invoke(SourceCodePainter.java:122)
at hudson.plugins.cobertura.renderers.SourceCodePainter.invoke(SourceCodePainter.java:17)
at hudson.FilePath.act(FilePath.java:676)
at hudson.FilePath.act(FilePath.java:660)
at hudson.plugins.cobertura.CoberturaPublisher.perform(CoberturaPublisher.java:276)
at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:36)
at hudson.model.AbstractBuild$AbstractRunner.perform(AbstractBuild.java:583)
at hudson.model.AbstractBuild$AbstractRunner.performAllBuildStep(AbstractBuild.java:564)
at hudson.model.AbstractBuild$AbstractRunner.performAllBuildStep(AbstractBuild.java:551)
at hudson.model.Build$RunnerImpl.post2(Build.java:152)
at hudson.model.AbstractBuild$AbstractRunner.post(AbstractBuild.java:535)
at hudson.model.Run.run(Run.java:1202)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:122)

without the -r (the sources path section isn't defined and files path are full path), there is no error during the build but sources aren't available

coverage.xml is generated at the root directory of my build (here hudson/jobs/testgcov/workspace/coverage.xml)
I can provide versions of generated cobertura report if needed

I use version 0.8.1 of the plugin


davidmc24 added a comment - 08/Feb/10 10:36 AM

Based on that error message, it looks like the plugin is failing when it attempts to create the directory "/var/lib/hudson/jobs/testgcov/cobertura". If you create that directory manually, does it change the behavior?


plamot added a comment - 09/Feb/10 01:19 AM

the folder already exists. If I remove it, it is recreated and I have the same error message


plamot added a comment - 09/Feb/10 01:51 AM

alright, I think I've found the problem,

the way gcovr fill the field filename of nodes "class" is a little buggy, causing filename begining by "/"

<class branch-rate="0.5" complexity="0.0" filename="/main.cpp" line-rate="0.714285714286" name="main_cpp">

it seems that hudson plugin doesn't like this, I think it try to create folder with empty name.

It might be resolved by changing in gcovr plugin, in function print_xml_report

c.setAttribute("filename", dir+os.sep+fname)
by
c.setAttribute("filename", os.path.join(dir, fname))


jbargiel added a comment - 11/Mar/10 05:49 PM - edited

This has been solved.

The XML data, generated by gcovr, must be modified to include the node <sources> (under the node <coverage>) with the appropriate sub-nodes <source>, as in:

<coverage>
<sources>
<source>path1</source>
<source>path2</source>
</sources>
...

where path1 and path2 are relative paths off of your repository root view.

Furthermore, the node <class>, attribute "filename" in the generated XML (under the nodes <classes>) must be modified to just include the source code file name found in any of the relative paths, as in:

<classes>
<class branch-rate="0.0" filename="filename.cpp" name="filename_cpp" ... >
...


jbargiel added a comment - 11/Mar/10 05:50 PM

See previous posting.