Skip to content

Conversation

@heuristicus
Copy link
Contributor

@heuristicus heuristicus commented Apr 20, 2022

I have a slightly weird setup for my ros workspaces where I have a directory where all my git repositories live, and then I selectively symlink them into workspaces as needed, rather than cloning independently for each workspace.

I tried using this tool to generate coverage, but was confused when it seemed that the reports were always empty. I manually checked the output and confirmed that the .coverage file correctly included all the files that were in the repo.

However, source directories which were symlinked would cause mismatch between the paths generated in the coverage and the --include argument. The paths in the coverage are always the real path to files, whereas the source directory might be a symlink.

For example, I have a test repo in a workspace at /home/michal/robots/michal/catkin_ws/src/ros_coverage_example, which is symlinked from /home/michal/git/independent/ros_coverage_example.

The current command generated in order to create the report is

cd /home/michal/.ros && /usr/bin/python3-coverage report --include */home/michal/robots/michal/catkin_ws/src/ros_coverage_example* --omit */ros_coverage_example/test*

But its result is empty with the given include arg because of the symlink

The coverage report contains the coverage information, but under the filename of the real directory.

michal@vetinari ~/.ros $ coverage report --include */home/michal/git/independent/ros_coverage_example/src*
Name                                                                                        Stmts   Miss  Cover
---------------------------------------------------------------------------------------------------------------
/home/michal/git/independent/ros_coverage_example/src/ros_coverage_example/my_code.py          29      8    72%
/home/michal/git/independent/ros_coverage_example/src/ros_coverage_example/my_code_ros.py      21      3    86%
---------------------------------------------------------------------------------------------------------------
TOTAL                                                                                          50     11    78%

This PR fixes the mismatch by changing the include argument so that it uses the real path of the package.

Source directories which were symlinked would cause mismatch between the paths
generated in the coverage and the --include argument. The paths in the coverage
are always the real path to files, whereas the source directory might be a
symlink.
@mikeferguson mikeferguson merged commit fff78dd into mikeferguson:master Jun 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants