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

Ceedling 0.32 - EXCEPTION: no implicit conversion of nil into String

tyler-macinnis opened this issue · comments

I am using the latest Ceedling 0.32 Pre-release and constantly get the following error when trying to use Ceedling (clobber, clean, test, gcov, etc.):

🚧 Loaded project configuration at default location using ./project.yml

🧨 EXCEPTION: no implicit conversion of nil into String

I'm not sure what is causing it, but the issue occurs across all of my projects using the latest Ceedling Pre-release.

The previous Pre-release doesn't have this issue so it's some change since then that's causing it.

Are you able to share your project.yml file with us (either pasting here or sending it to us privately to look at?)

It occurs across all my project. This project.yml is the shortest so I'll use it.

---
# 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: TRUE
  :use_test_preprocessor: TRUE
  :build_root: build
  #  :release_build: TRUE
  :test_file_prefix: test_
  :which_ceedling: gem
  :ceedling_version: 0.31.1
  :default_tasks:
    - test:all
  :compile_threads: :auto
  :test_threads: :auto

:test_build:
  :graceful_fail: true # Ceedling terminates with happy `exit(0)` even if test cases fail
#  :use_assembly: TRUE

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

:extension:
  :object: .p1
  :executable: .elf
  :assembly: .s

:environment:
  - :XC8_VERSION: "2.40"
  - :MPLABX_VERSION: "5.50"

:paths:
  :test:
    - +:test/**
    - -:support
  :source:
    - ../modbus-port/**
    - ../modbus/**
  :include:
    - ../modbus-port/**
    - ../modbus/**
    - ../mcc_generated_files/**
  :support:
    - support
  :libraries: []

:files:
  :source:
    - ../relay_app.c
    - ../main.c
  :include:
    - ../relay_app.h

:defines:
  :test:
    :*:
      - TEST

:cmock:
  :defines:
    - CMOCK_MEM_DYNAMIC
  :mock_prefix: mock_
  :when_no_prototypes: :warn
  :enforce_strict_ordering: TRUE
  :treat_externs: :include
  :includes:
    - <stdbool.h>
    - <stdint.h>
  :plugins:
    - :ignore
    - :callback
    - :expect_any_args
  :treat_as:
    uint8: HEX8
    uint16: HEX16
    uint32: UINT32
    int8: INT8
    bool: UINT8

:unity:
  :defines:
    - UNITY_EXCLUDE_FLOAT
    - UNITY_INCLUDE_PRINT_FORMATTED
    - UNITY_INCLUDE_EXEC_TIME

# 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:
  :summaries: FALSE
  :utilities:
    - gcovr
  :reports:
    - HtmlBasic
    - HtmlDetailed
    - Cobertura
    - JSON
  :gcovr:
    :report_root: "../" # The root directory of your source files.
    :xml_pretty: true # Set to 'true' to pretty-print the Cobertura XML report, otherwise set to 'false'. Defaults to disabled.
    :cobertura_pretty: true
    :json_pretty: true # Set to 'true' to pretty-print the JSON report, otherwise set 'false'. Defaults to disabled.
    :html_medium_threshold: 75 # If the coverage is below MEDIUM, the value is marked as low coverage in the HTML report.
    :html_high_threshold: 90 # If the coverage is below HIGH, the value is marked as medium coverage in the HTML report.
    :keep: false # Keep gcov files after processing.

#: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: "-l${1}"
  :path_flag: "-L ${1}"
  :system: [] # for example, you might list 'm' to grab the math library
  :test: []
  :release: []

:report_tests_log_factory:
  # Any one or all four of the following...
  :reports:
    - json
    - junit
    - html

:plugins:
  :load_paths:
    - plugins
  :enabled:
    #- beep                           # beeps when finished, so you don't waste time waiting for ceedling
    - module_generator               # handy for quickly creating source, header, and test templates
    - gcov                           # test coverage using gcov. Requires gcc, gcov, and a coverage analyzer like gcovr
    #- bullseye                       # test coverage using bullseye. Requires bullseye for your platform
    #- command_hooks                  # write custom actions to be called at different points during the build process
    - compile_commands_json_db          # generate a compile_commands.json file
    #- dependencies                   # automatically fetch 3rd party libraries, etc.
    #- subprojects                    # managing builds and test for static libraries
    #- fake_function_framework        # use FFF instead of CMock

    # Report options (You'll want to choose one stdout option, but may choose multiple stored options if desired)
    #- test_suite_reporter
    - report_tests_pretty_stdout
    - report_tests_raw_output_log
    - report_tests_log_factory
    #- report_tests_ide_stdout
    #- report_tests_gtestlike_stdout
    #- teamcity_tests_report
    #- warnings_report

Another one of my project that's also failing, with a similar 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: TRUE
  :use_test_preprocessor: TRUE
  :build_root: build
  #  :release_build: TRUE
  :test_file_prefix: test_
  :which_ceedling: gem
  :ceedling_version: 0.31.1
  :default_tasks:
    - test:all
  :compile_threads: :auto
  :test_threads: :auto

:test_build:
  :graceful_fail: true # Ceedling terminates with happy `exit(0)` even if test cases fail
#  :use_assembly: TRUE

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

:environment:

:extension:
  :executable: .out

:paths:
  :test:
    - +:test/**
    - -:support
  :source:
    - ../Dependencies/**
  :include:
    - ../Dependencies/**
    - ../Common/**
  :support:
    - support
  :libraries: []

:defines:
  :test:
    :*:
      - STM32H750xx

:cmock:
  :defines:
    - CMOCK_MEM_DYNAMIC
  :mock_prefix: mock_
  :when_no_prototypes: :warn
  :enforce_strict_ordering: TRUE
  :treat_externs: :include
  :includes:
    - <stdbool.h>
    - <stdint.h>
  :plugins:
    - :ignore
    - :callback
    - :ignore_arg
    - :expect_any_args
    - :return_thru_ptr
  :treat_as:
    uint8: HEX8
    uint16: HEX16
    uint32: UINT32
    int8: INT8
    bool: UINT8

:unity:
  :defines:
    - UNITY_INCLUDE_PRINT_FORMATTED
    - UNITY_INCLUDE_EXEC_TIME

# 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:
  :summaries: FALSE
  :utilities:
    - gcovr
  :reports:
    - HtmlBasic
    - HtmlDetailed
    - Cobertura
    - JSON
  :gcovr:
    :report_root: "../" # The root directory of your source files.
    :xml_pretty: true # Set to 'true' to pretty-print the Cobertura XML report, otherwise set to 'false'. Defaults to disabled.
    :cobertura_pretty: true
    :json_pretty: true # Set to 'true' to pretty-print the JSON report, otherwise set 'false'. Defaults to disabled.
    :html_medium_threshold: 75 # If the coverage is below MEDIUM, the value is marked as low coverage in the HTML report.
    :html_high_threshold: 90 # If the coverage is below HIGH, the value is marked as medium coverage in the HTML report.
    :keep: false # Keep gcov files after processing.

#: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

:tools_test_linker:
  :arguments:
    - -lm # link math library
:tools_gcov_linker:
  :arguments:
    - -lm # link math library

# 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: "-l${1}"
  :path_flag: "-L ${1}"
  :system: [] # for example, you might list 'm' to grab the math library
  :test: []
  :release: []

:report_tests_log_factory:
  # Any one or all four of the following...
  :reports:
    - json
    - junit
    - html

:plugins:
  :load_paths:
    - plugins
  :enabled:
    #- beep                           # beeps when finished, so you don't waste time waiting for ceedling
    - module_generator               # handy for quickly creating source, header, and test templates
    - gcov                           # test coverage using gcov. Requires gcc, gcov, and a coverage analyzer like gcovr
    #- bullseye                       # test coverage using bullseye. Requires bullseye for your platform
    #- command_hooks                  # write custom actions to be called at different points during the build process
    - compile_commands_json_db          # generate a compile_commands.json file
    #- dependencies                   # automatically fetch 3rd party libraries, etc.
    #- subprojects                    # managing builds and test for static libraries
    #- fake_function_framework        # use FFF instead of CMock

    # Report options (You'll want to choose one stdout option, but may choose multiple stored options if desired)
    #- test_suite_reporter
    - report_tests_pretty_stdout
    - report_tests_raw_output_log
    - report_tests_log_factory
    #- report_tests_ide_stdout
    #- report_tests_gtestlike_stdout
    #- teamcity_tests_report
    #- warnings_report

:flags:
  :test:
    :compile:
      :*:
        # Disable cast to/from pointer from/to integer of different size warnings
        # see https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
        - -Wno-int-to-pointer-cast
        - -Wno-pointer-to-int-cast
        - -Wno-incompatible-pointer-types
  :gcov:
    :compile:
      :*:
        # Disable cast to/from pointer from/to integer of different size warnings
        # see https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
        - -Wno-int-to-pointer-cast
        - -Wno-pointer-to-int-cast
        - -Wno-incompatible-pointer-types

Thanks. I'll start digging through those to see if there is anything obvious that has changed that you might be configuring wrong. In the meantime, have you attempted to do ceedling debug clobber? I suspect it's failing so early this won't help, but it MIGHT tell us what line is failing and give a backtrace.

Just tried it and gives the exact same result as ceedling clobber.

@mvandervoord I will not the following I just discovered in case its relevant.

When I comment out the :graceful_fail: true # Ceedling terminates with happyexit(0) even if test cases fail, I get a different error

🧨 EXCEPTION: undefined method `[]' for nil:NilClass

@mvandervoord Replacing the :project: section with the default that is provided by a new project fixed the issue. Not sure what, but I think it was something in there and I'm trying to figure out now just out of curiosity.

It's when this is missing that causes the issue:

:use_mocks: TRUE

I believe it was? It seems to work for me just fine.

So sorry @tyler-macinnis. You found a bug in how a new configuration set up ordering is working. We'll get that fixed promptly.

Yes ‘:auto’ is a recognized and documented setting for multi-threading.

@mkarlesky It's understandable given that I'm using the prerelease. It just took me a moment to figure out what was causing it and wanted to bring it to attention. 👍

And thank you for doing that, @tyler-macinnis! It was a subtle bug that had no test coverage. It was the sort of thing that helped unearth a handful of issues that were also lurking. The latest prerelease build should fix the problem. And, there's some extra validation checking and debug logging to prevent cryptic failures of the sort in the future. Of course, it's entirely possible that the various improvements have caused new bugs, and so the cycle continues…

FYI—We've greatly improved the command line (though we've not taken it quite as far as we want to). The old and quite limited options for debugging and verbose logging are much improved but work differently now. You can add --verbosity obnoxious (-v 4) or --verbosity debug (-v 5) to your build tasks. If you had done so here (ceedling clobber -v 5 or ceedling test:foo --verbosity debug), you would have seen a backtrace for the exception you noted that pointed to a problem in trying to create a directory path from a nil value.