ThrowTheSwitch / Ceedling

Ruby-based unit testing and build system for C projects

Home Page:http://throwtheswitch.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How can I ignore the build path of code coverage report? (I'm using GCOV)

mvrebolo opened this issue · comments

Hello all,

I would like to remove the build path from my code coverage report, how can I do it? Take a look one report with build paths:
image

I have hidden names because it is confidential.

I would like to remove the paths "unit_test/build/..." from the report.

I'm using this command: "ceedling gcov:all utils:gcov"

This is my project.yml:

---

# Notes:
# Sample project C code is not presently written to produce a release artifact.
# As such, release build options are disabled.
# This sample, therefore, only demonstrates running a collection of unit tests.

:project:
  :use_exceptions: FALSE
  :use_test_preprocessor: TRUE
  :use_auxiliary_dependencies: TRUE
  :build_root: unit_test\build
#  :release_build: TRUE
  :test_file_prefix: test_
  :which_ceedling: gem
  :default_tasks:
    - test:all

#:test_build:
#  :use_assembly: TRUE

#:release_build:
#  :output: MyApp.out
#  :use_assembly: FALSE

:environment:

:extension:
  :executable: .out

:paths:
  :test:
    - +:unit_test\test\**
  :source:
    - Software\**

:defines:
  # in order to add common defines:
  #  1) remove the trailing [] from the :common: section
  #  2) add entries to the :common: section (e.g. :test: has TEST defined)
  :common: &common_defines []
  :test:
    - *common_defines
    - UNITY_INCLUDE_PRINT_FORMATTED
  :test_preprocess:
    - *common_defines

:cmock:
  :mock_prefix: mock_
  :when_no_prototypes: :warn
  :enforce_strict_ordering: TRUE
  :plugins:
    - :ignore
    - :callback
  :treat_as:
    uint8:    HEX8
    uint16:   HEX16
    uint32:   UINT32
    int8:     INT8
    bool:     UINT8

# Add -gcov to the plugins list to make sure of the gcov plugin
# You will need to have gcov and gcovr both installed to make it work.
# For more information on these options, see docs in plugins/gcov
:gcov:
    :html_report: TRUE
    :html_report_type: detailed
    :html_medium_threshold: 75
    :html_high_threshold: 90
    :xml_report: TRUE
    
#:tools:
# Ceedling defaults to using gcc for compiling, linking, etc.
# As [:tools] is blank, gcc will be used (so long as it's in your system path)
# See documentation to configure a given toolchain for use

# LIBRARIES
# These libraries are automatically injected into the build process. Those specified as
# common will be used in all types of builds. Otherwise, libraries can be injected in just
# tests or releases. These options are MERGED with the options in supplemental yaml files.
:libraries:
  :placement: :end
  :flag: "${1}"  # or "-L ${1}" for example
  :test: []
  :release: []

:plugins:
  :load_paths:
    - "#{Ceedling.load_path}"
  :enabled:
    - gcov
    - xml_tests_report
    - stdout_pretty_tests_report
    - module_generator
...

Thanks.

Not sure what you want - just not display the directories, or you want to remove the unit test files from report (since those are not production code).

For removing the unit test files you should use:

:gcov:
  :gcovr:
    :report_exclude: "^unit_test/.*"

For removing directory prefix (according to genhtml --help) you should add a --prefix argument to it, something like:

:gcov:
  :report_generator:
    :custom_args:
      - --prefix unit_test

I am reading this from the plugins/gcov/README.md (https://github.com/ThrowTheSwitch/Ceedling/tree/master/plugins/gcov#reportgenerator-configuration)

Hello @Letme

I would like to remove the unit test files, as the first option that you sent me. It worked, thanks very much!

About the second option: "For removing directory prefix...", I didn't understand what you wanted to mean, can you explain me what it means, please?

Some people do not want to have whole path to the file displayed there and the prefix removes that part. Let's say you have:

src/component_name/somefile.c and you do not care about that src, so you can remove it and then you can see more explicit component list in the report.

Please do not forget to close the issue when it is fully resolved (we need a bit of cleanup in issues in this repo)

Hmm I got it, Thanks Letme, I will try this second suggestion and improve my report! Thanks.

Hello @Letme , can you give an example how can I remove directory prefix? I have tried here but It didn't work...

For example, lets suppose this patht:
Software/logic.c

In my case, I added it to project.yml:

:gcov:
  :report_generator:
    :custom_args:
      - --prefix Software

But the report continues with: "Software/logic.c" and not only "logic.c"

Thanks