You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

433 lines
15 KiB

11 months ago
  1. ceedling-gcov
  2. =============
  3. # Plugin Overview
  4. Plugin for integrating GNU GCov code coverage tool into Ceedling projects.
  5. Currently only designed for the gcov command (like LCOV for example). In the
  6. future we could configure this to work with other code coverage tools.
  7. This plugin currently uses [gcovr](https://www.gcovr.com/) and / or
  8. [ReportGenerator](https://danielpalme.github.io/ReportGenerator/)
  9. as utilities to generate HTML, XML, JSON, or Text reports. The normal gcov
  10. plugin _must_ be run first for these reports to generate.
  11. ## Installation
  12. gcovr can be installed via pip like so:
  13. ```sh
  14. pip install gcovr
  15. ```
  16. ReportGenerator can be installed via .NET Core like so:
  17. ```sh
  18. dotnet tool install -g dotnet-reportgenerator-globaltool
  19. ```
  20. It is not required to install both `gcovr` and `ReportGenerator`. Either utility
  21. may be installed to create reports.
  22. ## Configuration
  23. The gcov plugin supports configuration options via your `project.yml` provided
  24. by Ceedling.
  25. ### Utilities
  26. Gcovr and / or ReportGenerator may be enabled to create coverage reports.
  27. ```yaml
  28. :gcov:
  29. :utilities:
  30. - gcovr # Use gcovr to create the specified reports (default).
  31. - ReportGenerator # Use ReportGenerator to create the specified reports.
  32. ```
  33. ### Reports
  34. Various reports are available and may be enabled with the following
  35. configuration item. See the specific report sections in this README
  36. for additional options and information. All generated reports will be found in `build/artifacts/gcov`.
  37. ```yaml
  38. :gcov:
  39. # Specify one or more reports to generate.
  40. # Defaults to HtmlBasic.
  41. :reports:
  42. # Make an HTML summary report.
  43. # Supported utilities: gcovr, ReportGenerator
  44. - HtmlBasic
  45. # Make an HTML report with line by line coverage of each source file.
  46. # Supported utilities: gcovr, ReportGenerator
  47. - HtmlDetailed
  48. # Make a Text report, which may be output to the console with gcovr or a file in both gcovr and ReportGenerator.
  49. # Supported utilities: gcovr, ReportGenerator
  50. - Text
  51. # Make a Cobertura XML report.
  52. # Supported utilities: gcovr, ReportGenerator
  53. - Cobertura
  54. # Make a SonarQube XML report.
  55. # Supported utilities: gcovr, ReportGenerator
  56. - SonarQube
  57. # Make a JSON report.
  58. # Supported utilities: gcovr
  59. - JSON
  60. # Make a detailed HTML report with CSS and JavaScript included in every HTML page. Useful for build servers.
  61. # Supported utilities: ReportGenerator
  62. - HtmlInline
  63. # Make a detailed HTML report with a light theme and CSS and JavaScript included in every HTML page for Azure DevOps.
  64. # Supported utilities: ReportGenerator
  65. - HtmlInlineAzure
  66. # Make a detailed HTML report with a dark theme and CSS and JavaScript included in every HTML page for Azure DevOps.
  67. # Supported utilities: ReportGenerator
  68. - HtmlInlineAzureDark
  69. # Make a single HTML file containing a chart with historic coverage information.
  70. # Supported utilities: ReportGenerator
  71. - HtmlChart
  72. # Make a detailed HTML report in a single file.
  73. # Supported utilities: ReportGenerator
  74. - MHtml
  75. # Make SVG and PNG files that show line and / or branch coverage information.
  76. # Supported utilities: ReportGenerator
  77. - Badges
  78. # Make a single CSV file containing coverage information per file.
  79. # Supported utilities: ReportGenerator
  80. - CsvSummary
  81. # Make a single TEX file containing a summary for all files and detailed reports for each files.
  82. # Supported utilities: ReportGenerator
  83. - Latex
  84. # Make a single TEX file containing a summary for all files.
  85. # Supported utilities: ReportGenerator
  86. - LatexSummary
  87. # Make a single PNG file containing a chart with historic coverage information.
  88. # Supported utilities: ReportGenerator
  89. - PngChart
  90. # Command line output interpreted by TeamCity.
  91. # Supported utilities: ReportGenerator
  92. - TeamCitySummary
  93. # Make a text file in lcov format.
  94. # Supported utilities: ReportGenerator
  95. - lcov
  96. # Make a XML file containing a summary for all classes and detailed reports for each class.
  97. # Supported utilities: ReportGenerator
  98. - Xml
  99. # Make a single XML file containing a summary for all files.
  100. # Supported utilities: ReportGenerator
  101. - XmlSummary
  102. ```
  103. ### Gcovr HTML Reports
  104. Generation of Gcovr HTML reports may be modified with the following configuration items.
  105. ```yaml
  106. :gcov:
  107. # Set to 'true' to enable HTML reports or set to 'false' to disable.
  108. # Defaults to enabled. (gcovr --html)
  109. # Deprecated - See the :reports: configuration option.
  110. :html_report: [true|false]
  111. # Gcovr supports generating two types of HTML reports. Use 'basic' to create
  112. # an HTML report with only the overall file information. Use 'detailed' to create
  113. # an HTML report with line by line coverage of each source file.
  114. # Defaults to 'basic'. Set to 'detailed' for (gcovr --html-details).
  115. # Deprecated - See the :reports: configuration option.
  116. :html_report_type: [basic|detailed]
  117. :gcovr:
  118. # HTML report filename.
  119. :html_artifact_filename: <output>
  120. # Use 'title' as title for the HTML report.
  121. # Default is 'Head'. (gcovr --html-title)
  122. :html_title: <title>
  123. # If the coverage is below MEDIUM, the value is marked as low coverage in the HTML report.
  124. # MEDIUM has to be lower than or equal to value of html_high_threshold.
  125. # If MEDIUM is equal to value of html_high_threshold the report has only high and low coverage.
  126. # Default is 75.0. (gcovr --html-medium-threshold)
  127. :html_medium_threshold: 75
  128. # If the coverage is below HIGH, the value is marked as medium coverage in the HTML report.
  129. # HIGH has to be greater than or equal to value of html_medium_threshold.
  130. # If HIGH is equal to value of html_medium_threshold the report has only high and low coverage.
  131. # Default is 90.0. (gcovr -html-high-threshold)
  132. :html_high_threshold: 90
  133. # Set to 'true' to use absolute paths to link the 'detailed' reports.
  134. # Defaults to relative links. (gcovr --html-absolute-paths)
  135. :html_absolute_paths: [true|false]
  136. # Override the declared HTML report encoding. Defaults to UTF-8. (gcovr --html-encoding)
  137. :html_encoding: <html_encoding>
  138. ```
  139. ### Cobertura XML Reports
  140. Generation of Cobertura XML reports may be modified with the following configuration items.
  141. ```yaml
  142. :gcov:
  143. # Set to 'true' to enable Cobertura XML reports or set to 'false' to disable.
  144. # Defaults to disabled. (gcovr --xml)
  145. # Deprecated - See the :reports: configuration option.
  146. :xml_report: [true|false]
  147. :gcovr:
  148. # Set to 'true' to pretty-print the Cobertura XML report, otherwise set to 'false'.
  149. # Defaults to disabled. (gcovr --xml-pretty)
  150. :xml_pretty: [true|false]
  151. :cobertura_pretty: [true|false]
  152. # Cobertura XML report filename.
  153. :xml_artifact_filename: <output>
  154. :cobertura_artifact_filename: <output>
  155. ```
  156. ### SonarQube XML Reports
  157. Generation of SonarQube XML reports may be modified with the following configuration items.
  158. ```yaml
  159. :gcov:
  160. :gcovr:
  161. # SonarQube XML report filename.
  162. :sonarqube_artifact_filename: <output>
  163. ```
  164. ### JSON Reports
  165. Generation of JSON reports may be modified with the following configuration items.
  166. ```yaml
  167. :gcov:
  168. :gcovr:
  169. # Set to 'true' to pretty-print the JSON report, otherwise set 'false'.
  170. # Defaults to disabled. (gcovr --json-pretty)
  171. :json_pretty: [true|false]
  172. # JSON report filename.
  173. :json_artifact_filename: <output>
  174. ```
  175. ### Text Reports
  176. Generation of text reports may be modified with the following configuration items.
  177. Text reports may be printed to the console or output to a file.
  178. ```yaml
  179. :gcov:
  180. :gcovr:
  181. # Text report filename.
  182. # The text report is printed to the console when no filename is provided.
  183. :text_artifact_filename: <output>
  184. ```
  185. ### Common Report Options
  186. There are a number of options to control which files are considered part of
  187. the coverage report. Most often, we only care about coverage on our source code, and not
  188. on tests or automatically generated mocks, runners, etc. However, there are times
  189. where this isn't true... or there are times where we've moved ceedling's directory
  190. structure so that the project file isn't at the root of the project anymore. In these
  191. cases, you may need to tweak `report_include`, `report_exclude`, and `exclude_directories`.
  192. One important note about `report_root`: gcovr will take only a single root folder, unlike
  193. Ceedling's ability to take as many as you like. So you will need to choose a folder which is
  194. a superset of ALL the folders you want, and then use the include or exclude options to set up
  195. patterns of files to pay attention to or ignore. It's not ideal, but it works.
  196. Finally, there are a number of settings which can be specified to adjust the
  197. default behaviors of gcovr:
  198. ```yaml
  199. :gcov:
  200. :gcovr:
  201. # The root directory of your source files. Defaults to ".", the current directory.
  202. # File names are reported relative to this root. The report_root is the default report_include.
  203. :report_root: "."
  204. # Load the specified configuration file.
  205. # Defaults to gcovr.cfg in the report_root directory. (gcovr --config)
  206. :config_file: <config_file>
  207. # Exit with a status of 2 if the total line coverage is less than MIN.
  208. # Can be ORed with exit status of 'fail_under_branch' option. (gcovr --fail-under-line)
  209. :fail_under_line: 30
  210. # Exit with a status of 4 if the total branch coverage is less than MIN.
  211. # Can be ORed with exit status of 'fail_under_line' option. (gcovr --fail-under-branch)
  212. :fail_under_branch: 30
  213. # Select the source file encoding.
  214. # Defaults to the system default encoding (UTF-8). (gcovr --source-encoding)
  215. :source_encoding: <source_encoding>
  216. # Report the branch coverage instead of the line coverage. For text report only. (gcovr --branches).
  217. :branches: [true|false]
  218. # Sort entries by increasing number of uncovered lines.
  219. # For text and HTML report. (gcovr --sort-uncovered)
  220. :sort_uncovered: [true|false]
  221. # Sort entries by increasing percentage of uncovered lines.
  222. # For text and HTML report. (gcovr --sort-percentage)
  223. :sort_percentage: [true|false]
  224. # Print a small report to stdout with line & branch percentage coverage.
  225. # This is in addition to other reports. (gcovr --print-summary).
  226. :print_summary: [true|false]
  227. # Keep only source files that match this filter. (gcovr --filter).
  228. :report_include: "^src"
  229. # Exclude source files that match this filter. (gcovr --exclude).
  230. :report_exclude: "^vendor.*|^build.*|^test.*|^lib.*"
  231. # Keep only gcov data files that match this filter. (gcovr --gcov-filter).
  232. :gcov_filter: <gcov_filter>
  233. # Exclude gcov data files that match this filter. (gcovr --gcov-exclude).
  234. :gcov_exclude: <gcov_exclude>
  235. # Exclude directories that match this regex while searching
  236. # raw coverage files. (gcovr --exclude-directories).
  237. :exclude_directories: <exclude_dirs>
  238. # Use a particular gcov executable. (gcovr --gcov-executable).
  239. :gcov_executable: <gcov_cmd>
  240. # Exclude branch coverage from lines without useful
  241. # source code. (gcovr --exclude-unreachable-branches).
  242. :exclude_unreachable_branches: [true|false]
  243. # For branch coverage, exclude branches that the compiler
  244. # generates for exception handling. (gcovr --exclude-throw-branches).
  245. :exclude_throw_branches: [true|false]
  246. # Use existing gcov files for analysis. Default: False. (gcovr --use-gcov-files)
  247. :use_gcov_files: [true|false]
  248. # Skip lines with parse errors in GCOV files instead of
  249. # exiting with an error. (gcovr --gcov-ignore-parse-errors).
  250. :gcov_ignore_parse_errors: [true|false]
  251. # Override normal working directory detection. (gcovr --object-directory)
  252. :object_directory: <objdir>
  253. # Keep gcov files after processing. (gcovr --keep).
  254. :keep: [true|false]
  255. # Delete gcda files after processing. (gcovr --delete).
  256. :delete: [true|false]
  257. # Set the number of threads to use in parallel. (gcovr -j).
  258. :num_parallel_threads: <num_threads>
  259. # When scanning the code coverage, if any files are found that do not have
  260. # associated coverage data, the command will abort with an error message.
  261. :abort_on_uncovered: true
  262. # When using the ``abort_on_uncovered`` option, the files in this list will not
  263. # trigger a failure.
  264. # Ceedling globs described in the Ceedling packet ``Path`` section can be used
  265. # when directories are placed on the list. Globs are limited to matching directories
  266. # and not files.
  267. :uncovered_ignore_list: []
  268. ```
  269. ### ReportGenerator Configuration
  270. The ReportGenerator utility may be configured with the following configuration items.
  271. All generated reports may be found in `build/artifacts/gcov/ReportGenerator`.
  272. ```yaml
  273. :gcov:
  274. :report_generator:
  275. # Optional directory for storing persistent coverage information.
  276. # Can be used in future reports to show coverage evolution.
  277. :history_directory: <history_directory>
  278. # Optional plugin files for custom reports or custom history storage (separated by semicolon).
  279. :plugins: CustomReports.dll
  280. # Optional list of assemblies that should be included or excluded in the report (separated by semicolon)..
  281. # Exclusion filters take precedence over inclusion filters.
  282. # Wildcards are allowed, but not regular expressions.
  283. :assembly_filters: "+Included;-Excluded"
  284. # Optional list of classes that should be included or excluded in the report (separated by semicolon)..
  285. # Exclusion filters take precedence over inclusion filters.
  286. # Wildcards are allowed, but not regular expressions.
  287. :class_filters: "+Included;-Excluded"
  288. # Optional list of files that should be included or excluded in the report (separated by semicolon)..
  289. # Exclusion filters take precedence over inclusion filters.
  290. # Wildcards are allowed, but not regular expressions.
  291. :file_filters: "-./vendor/*;-./build/*;-./test/*;-./lib/*;+./src/*"
  292. # The verbosity level of the log messages.
  293. # Values: Verbose, Info, Warning, Error, Off
  294. :verbosity: Warning
  295. # Optional tag or build version.
  296. :tag: <tag>
  297. # Optional list of one or more regular expressions to exclude gcov notes files that match these filters.
  298. :gcov_exclude:
  299. - <exclude_regex1>
  300. - <exclude_regex2>
  301. # Optionally use a particular gcov executable. Defaults to gcov.
  302. :gcov_executable: <gcov_cmd>
  303. # Optionally set the number of threads to use in parallel. Defaults to 1.
  304. :num_parallel_threads: <num_threads>
  305. # Optional list of one or more command line arguments to pass to Report Generator.
  306. # Useful for configuring Risk Hotspots and Other Settings.
  307. # https://github.com/danielpalme/ReportGenerator/wiki/Settings
  308. :custom_args:
  309. - <custom_arg1>
  310. - <custom_arg2>
  311. ```
  312. ## Example Usage
  313. ```sh
  314. ceedling gcov:all utils:gcov
  315. ```
  316. ## To-Do list
  317. - Generate overall report (combined statistics from all files with coverage)
  318. ## Citations
  319. Most of the comment text which describes the options was taken from the
  320. [Gcovr User Guide](https://www.gcovr.com/en/stable/guide.html) and the
  321. [ReportGenerator Wiki](https://github.com/danielpalme/ReportGenerator/wiki).
  322. The text is repeated here to provide the most accurate option functionality.