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

ReportGenerator with GCC v6.3.0

RobertZickler opened this issue · comments

Running with ceedling version (0.32.0-9b8d8a9):

    Ceedling:: 0.32.0
       CMock:: 2.5.4
       Unity:: 2.5.4
  CException:: 1.3.3

ReportGenerator 5.2.3.0

and (latest MinGW)

C:\MinGW\bin>gcov -v
gcov (MinGW.org GCC-6.3.0-1) 6.3.0

-> this is probably an issue. But see later on.

I configured gcov like:

:gcov:
  :utilities:
    - ReportGenerator
  :reports:
    - HtmlDetailed
  :report_generator:
    :verbosity: Verbose

As the documentation lists all :report_generator: options as optional.

This gives the error:

NoMethodError ==> undefined method `each' for nil
C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/ceedling-0.32.0/plugins/gcov/lib/reportgenerator_reportinator.rb:58:in `block in generate_reports': undefined method `each' for nil (NoMethodError)
        from C:/Ruby33-x64/lib/ruby/3.3.0/benchmark.rb:313:in `realtime'
        from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/ceedling-0.32.0/plugins/gcov/lib/reportgenerator_reportinator.rb:39:in `generate_reports'
        from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/ceedling-0.32.0/plugins/gcov/lib/gcov.rb:136:in `block in generate_coverage_reports'
        from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/ceedling-0.32.0/plugins/gcov/lib/gcov.rb:131:in `each'
        from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/ceedling-0.32.0/plugins/gcov/lib/gcov.rb:131:in `generate_coverage_reports'
        from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/ceedling-0.32.0/plugins/gcov/lib/gcov.rb:102:in `post_build'
        from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/ceedling-0.32.0/lib/ceedling/plugin_manager.rb:119:in `block in execute_plugins'
        from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/ceedling-0.32.0/lib/ceedling/plugin_manager.rb:114:in `each'
        from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/ceedling-0.32.0/lib/ceedling/plugin_manager.rb:114:in `execute_plugins'
        from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/ceedling-0.32.0/lib/ceedling/plugin_manager.rb:91:in `post_build'
        from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/ceedling-0.32.0/lib/ceedling/rakefile.rb:126:in `block in <top (required)>'

I had to append :gcov_exclude: [] and :custom_args: []:

:gcov:
  :utilities:
    - ReportGenerator
  :reports:
    - HtmlDetailed
  :report_generator:
    :verbosity: Verbose
    :gcov_exclude: []   # <--
    :custom_args: []    # <--

So they seem to be mandatory.

But now the next error gets thrown:

Running ReportGenerator Coverage Reports
----------------------------------------
Generating HtmlDetailed coverage report in './build/artifacts/gcov/ReportGenerator'...
ERROR: Shell command failed.
> Shell executed command:
'gcov.exe -b -c -r -x "./build/gcov/out/test_my_file/my_file.gcno"'
> Produced output:
gcov.exe: invalid option -- x
Usage: gcov [OPTION]... SOURCE|OBJ...

Print code coverage information.

  -h, --help                      Print this help, then exit
  -a, --all-blocks                Show information for every basic block
  -b, --branch-probabilities      Include branch probabilities in output
  -c, --branch-counts             Output counts of branches taken
                                    rather than percentages
  -d, --display-progress          Display progress information
  -f, --function-summaries        Output summaries for each function
  -i, --intermediate-format       Output .gcov file in intermediate text format
  -l, --long-file-names           Use long output file names for included
                                    source files
  -m, --demangled-names           Output demangled function names
  -n, --no-output                 Do not create an output file
  -o, --object-directory DIR|FILE Search for object files in DIR or called FILE
  -p, --preserve-paths            Preserve all pathname components
  -r, --relative-only             Only show data for relative sources
  -s, --source-prefix DIR         Source prefix to elide
  -u, --unconditional-branches    Show unconditional branch counts too
  -v, --version                   Print version number, then exit

For bug reporting instructions, please see:
<http://gcc.gnu.org/bugs.html>.
> And exited with status: [1].

Exception raised in plugin `gcov` within build hook :post_build

Ceedling operations completed in 3.29 seconds
ShellExecutionException ==> 'Default Gcov Report' (gcov.exe) exited with an error
C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/ceedling-0.32.0/lib/ceedling/tool_executor.rb:73:in `exec': 'Default Gcov Report' (gcov.exe) exited with an error (ShellExecutionException)
        from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/ceedling-0.32.0/plugins/gcov/lib/reportgenerator_reportinator.rb:211:in `run_gcov'
        from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/ceedling-0.32.0/plugins/gcov/lib/reportgenerator_reportinator.rb:79:in `block (2 levels) in generate_reports'
        from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/ceedling-0.32.0/plugins/gcov/lib/reportgenerator_reportinator.rb:75:in `each'
        from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/ceedling-0.32.0/plugins/gcov/lib/reportgenerator_reportinator.rb:75:in `block in generate_reports'
        from C:/Ruby33-x64/lib/ruby/3.3.0/benchmark.rb:313:in `realtime'
        from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/ceedling-0.32.0/plugins/gcov/lib/reportgenerator_reportinator.rb:39:in `generate_reports'
        from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/ceedling-0.32.0/plugins/gcov/lib/gcov.rb:136:in `block in generate_coverage_reports'
        from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/ceedling-0.32.0/plugins/gcov/lib/gcov.rb:131:in `each'
        from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/ceedling-0.32.0/plugins/gcov/lib/gcov.rb:131:in `generate_coverage_reports'
        from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/ceedling-0.32.0/plugins/gcov/lib/gcov.rb:102:in `post_build'
        from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/ceedling-0.32.0/lib/ceedling/plugin_manager.rb:119:in `block in execute_plugins'
        from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/ceedling-0.32.0/lib/ceedling/plugin_manager.rb:114:in `each'
        from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/ceedling-0.32.0/lib/ceedling/plugin_manager.rb:114:in `execute_plugins'
        from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/ceedling-0.32.0/lib/ceedling/plugin_manager.rb:91:in `post_build'
        from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/ceedling-0.32.0/lib/ceedling/rakefile.rb:126:in `block in <top (required)>'

When I remove -x from

respectively in "C:\Ruby33-x64\lib\ruby\gems\3.3.0\gems\ceedling-0.32.0\plugins\gcov\config\defaults_gcov.rb" this gets solved and a report is generated

This is due to the gcov version 6.3.0 not having

-x, --hash-filenames Hash long pathnames

I installed GCC from https://www.msys2.org/ with version 13.2.0 and the later issue is solved.

So there should be some minimum GCC version documented and ReportGenerator options markt as mandatory. Or did I overlook something?

Sorry if I mixed two separable issues into one.

Hi, @RobertZickler. So sorry for this trouble, but thank you so much for exercising the pre-release of 0.32 and providing this detailed issue report.

We put a ton of work into updating and improving the gcov plugin. It seems to be one of the most used aspects of Ceedling and also frequently garners quite a number of support requests. ReportGenerator has not been exercised all that much after all these code changes, and you've help find some obvious gaps.

You also make a great recommendation. Specific supported versions for gcov, gcovr, and ReportGenerator are something we need to document. Especially gcov and gcovr have had breaking changes / updates in recent years after periods of relative stability.

We'll put some work into fixing the bugs you found and exercising ReportGenerator more. We'll also put some working into version support and documentation.

As it turns out, more recent pre-release versions of Ceedling already (perhaps unknowingly) fixed the bugs related to :gcov_exclude and :custom_args. The fix was simple. These configuration options were simply added to the plugin defaults such that they are always present with an empty array if they are not set by the user.

Before the next big release of Ceedling is pushed out, we will update the Gcov plugin README with some tool version information.