{"id":13649533,"url":"https://github.com/mikeferguson/code_coverage","last_synced_at":"2025-04-22T14:32:00.119Z","repository":{"id":36086681,"uuid":"137146254","full_name":"mikeferguson/code_coverage","owner":"mikeferguson","description":"ROS package to run coverage testing","archived":false,"fork":false,"pushed_at":"2023-08-29T21:16:09.000Z","size":45,"stargazers_count":37,"open_issues_count":8,"forks_count":25,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-11-10T00:33:08.049Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"CMake","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mikeferguson.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.rst","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2018-06-13T01:26:14.000Z","updated_at":"2024-08-25T03:23:31.000Z","dependencies_parsed_at":"2024-02-03T11:47:56.566Z","dependency_job_id":null,"html_url":"https://github.com/mikeferguson/code_coverage","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikeferguson%2Fcode_coverage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikeferguson%2Fcode_coverage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikeferguson%2Fcode_coverage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikeferguson%2Fcode_coverage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mikeferguson","download_url":"https://codeload.github.com/mikeferguson/code_coverage/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250259081,"owners_count":21401037,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T02:00:18.302Z","updated_at":"2025-04-22T14:31:54.936Z","avatar_url":"https://github.com/mikeferguson.png","language":"CMake","funding_links":[],"categories":["Development Environment","Code Testing"],"sub_categories":["Unit and Integration Test","Extracting data"],"readme":"# code_coverage\n\nROS package to run coverage testing\n\n## Examples\n\n * The [robot_calibration](https://github.com/mikeferguson/robot_calibration) package uses this to generate coverage for C++ code using Travis-CI and Codecov.io\n\n## Usage\nTo use this with your ROS package:\n\n * Add code_coverage as a test depend in your package.xml\n * Update your CMakeLists.txt, in the testing section add the following. **NOTE** the order of test targets and coverage macros:\n   ```cmake\n   if(CATKIN_ENABLE_TESTING AND ENABLE_COVERAGE_TESTING)\n     find_package(code_coverage REQUIRED)\n     # Add compiler flags for coverage instrumentation before defining any targets\n     APPEND_COVERAGE_COMPILER_FLAGS()\n   endif()\n   \n   # Add your targets here\n   \n   if (CATKIN_ENABLE_TESTING)\n     # Add your tests here\n   \n     # Create a target ${PROJECT_NAME}_coverage_report\n     if(ENABLE_COVERAGE_TESTING)\n       set(COVERAGE_EXCLUDES \"*/${PROJECT_NAME}/test*\" \"*/${PROJECT_NAME}/other_dir_i_dont_care_about*\")\n       add_code_coverage(\n         NAME ${PROJECT_NAME}_coverage_report\n         DEPENDENCIES _run_tests_${PROJECT_NAME}\n       )\n     endif()\n   endif()\n   ```\n* **Note**: The variable `COVERAGE_EXCLUDES` must have some content!\n* Now you can build and run the tests (you need a debug build to get reasonable coverage numbers):\n\n  - if using CATKIN_MAKE:\n  ```\n      catkin_make -DENABLE_COVERAGE_TESTING=ON -DCMAKE_BUILD_TYPE=Debug\n      catkin_make -DENABLE_COVERAGE_TESTING=ON -DCMAKE_BUILD_TYPE=Debug PACKAGE_NAME_coverage_report\n  ```\n  - if using CATKIN_TOOLS:\n  ```\n    catkin config --cmake-args -DENABLE_COVERAGE_TESTING=ON -DCMAKE_BUILD_TYPE=Debug\n    catkin build\n    catkin build PACKAGE_NAME -v --no-deps --catkin-make-args PACKAGE_NAME_coverage_report \n  ```\n\n* The output will print where the coverage report is located\n\n## Python rostest Support\n\nWhile the C++ interface and Python-based unit tests require no\nmodification to get coverage information, Python-based nodes\nrun from rostest launch files need a bit of additional\ninstrumentation turned on:\n\n```xml\n\u003claunch\u003e\n\n    \u003c!-- Add an argument to the launch file to turn on coverage --\u003e\n    \u003carg name=\"coverage\" default=\"false\"/\u003e\n\n    \u003c!-- This fancy line forces nodes to generate coverage --\u003e\n    \u003carg name=\"pythontest_launch_prefix\" value=\"$(eval 'python-coverage run -p' if arg('coverage') else '')\"/\u003e\n\n    \u003c!-- This node will NOT generate coverage information --\u003e\n    \u003cnode pkg=\"example_pkg\" name=\"publisher_node\" type=\"publisher_node.py\" /\u003e\n\n    \u003c!-- But this node WILL generate coverage --\u003e\n    \u003cnode pkg=\"example_pkg\" name=\"subscriber_node\" type=\"subscriber_node.py\"\n          launch-prefix=\"$(arg pythontest_launch_prefix)\" /\u003e\n\n    \u003c!-- The test can also generate coverage information if you include the launch-prefix --\u003e\n    \u003ctest time-limit=\"10\" test-name=\"sample_rostest\" pkg=\"example_pkg\" type=\"sample_rostest.py\"\n          launch-prefix=\"$(arg pythontest_launch_prefix)\" /\u003e\n\n\u003c/launch\u003e\n```\n\nIn the CMakeLists, you will need to pass this argument:\n\n```cmake\nadd_rostest(example_rostest.test ARGS coverage:=ENABLE_COVERAGE_TESTING)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikeferguson%2Fcode_coverage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmikeferguson%2Fcode_coverage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikeferguson%2Fcode_coverage/lists"}