ThrowTheSwitch / Ceedling

Ruby-based unit testing and build system for C projects
http://throwtheswitch.org
Other
596 stars 246 forks source link

`EXCEPTION: undefined method '[]' for nil` in release candidate #908

Closed Julian-Wollersberger closed 4 months ago

Julian-Wollersberger commented 4 months ago

I was very excited to try out the release candidate, but sadly, I couldn't get it to work.

When I try to run any ceedling command in my project, I get the following error:
EXCEPTION: undefined method '[]' for nil

I have tried it with two ruby versions, deleted stuff from the project config, and tried it with an empty project. As long as the minimal things are configured, it fails with that error. In a project created with ceedling new, it works though.

My only suspicion is that my project was created with ceedling 0.30.0 and somehow messed with the environment.

Details

Full output:

ceedling --verbosity obnoxious test:all
Loaded project configuration at default location using ./project.yml
 > Defaulting to running Ceedling from Gem

Validating configuration contains minimum required sections...

Project Configuration Handling
------------------------------
Processing Unity configuration...

Plugin Handling
---------------
Discovering all plugins...

Assembling Default Settings
---------------------------
Collecting default tool configurations...

EXCEPTION: undefined method `[]' for nil

I don't know to to make ruby emit a full stack trace here.

Minimized project.yml (Can't publish the full config sadly)

:project:
  :build_root: build 

:paths:
  :test:
    - "aaaaaaaaaaaaaaaaa"

  :source:
    - "bbbbbbbbbbbbbbbbb" 

Versions:
Old ruby: ruby 3.0.4p208 (2022-04-12 revision 3fa771dded) [i386-mingw32]
New ruby: ruby 3.3.4 (2024-07-09 revision be1089c8ec) [x64-mingw-ucrt]
Ceedling installed with gem install ceedling --local .\ceedling-1.0.0-28f9e30.gem

ceedling --version
Welcome to Ceedling!

   Ceedling => 1.0.0
      CMock => 2.5.4
      Unity => 2.6.0
 CException => 1.3.4

OS is Windows 10. Commands ran in PowerShell.

mkarlesky commented 4 months ago

Hi, @Julian-Wollersberger. Thank you so much for this report. Could you run ceedling --verbosity debug test:all and post the full backtrace. That'll tell us where the problem is.

Julian-Wollersberger commented 4 months ago

Of course:

ceedling --verbosity debug test:all    
Loaded project configuration at default location using ./project.yml
 > Defaulting to running Ceedling from Gem

Validating configuration contains minimum required sections...

Project Configuration Handling
------------------------------
Processing Unity configuration...

Plugin Handling
---------------
Discovering all plugins...

Assembling Default Settings
---------------------------
Collecting default tool configurations...

EXCEPTION: undefined method `[]' for nil
Backtrace ==>
C:/Program Files (x86)/Ruby/lib/ruby/gems/3.3.0/gems/ceedling-1.0.0/lib/ceedling/configurator.rb:99:in `merge_tools_defaults': undefined method `[]' for nil (NoMethodError)
        C:/Program Files (x86)/Ruby/lib/ruby/gems/3.3.0/gems/ceedling-1.0.0/lib/ceedling/setupinator.rb:105:in `do_setup'
        C:/Program Files (x86)/Ruby/lib/ruby/gems/3.3.0/gems/ceedling-1.0.0/lib/ceedling/rakefile.rb:65:in `<top (required)>'
        <internal:C:/Program Files (x86)/Ruby/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:136:in `require'
        <internal:C:/Program Files (x86)/Ruby/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:136:in `require'
        C:/Program Files (x86)/Ruby/lib/ruby/gems/3.3.0/gems/ceedling-1.0.0/bin/cli_helper.rb:127:in `load_ceedling'
        C:/Program Files (x86)/Ruby/lib/ruby/gems/3.3.0/gems/ceedling-1.0.0/bin/cli_handler.rb:199:in `build'
        C:/Program Files (x86)/Ruby/lib/ruby/gems/3.3.0/gems/ceedling-1.0.0/bin/cli.rb:312:in `build'
        C:/Program Files (x86)/Ruby/lib/ruby/gems/3.3.0/gems/thor-1.3.1/lib/thor/command.rb:28:in `run'
        C:/Program Files (x86)/Ruby/lib/ruby/gems/3.3.0/gems/thor-1.3.1/lib/thor/invocation.rb:127:in `invoke_command'
        C:/Program Files (x86)/Ruby/lib/ruby/gems/3.3.0/gems/thor-1.3.1/lib/thor.rb:527:in `dispatch'
        C:/Program Files (x86)/Ruby/lib/ruby/gems/3.3.0/gems/ceedling-1.0.0/bin/cli.rb:92:in `start'
        C:/Program Files (x86)/Ruby/lib/ruby/gems/3.3.0/gems/ceedling-1.0.0/bin/ceedling:125:in `<top (required)>'
        C:/Program Files (x86)/Ruby/bin/ceedling:32:in `load'
        C:/Program Files (x86)/Ruby/bin/ceedling:32:in `<main>'
Julian-Wollersberger commented 4 months ago

Following that stack trace, I added this to my project file:

:test_build:
  :use_assembly: FALSE

:cmock:
  :unity_helper_path: []

This gets me further into the validaton 👍

Now I can rework my option:foo stuff into mixins :)

mkarlesky commented 4 months ago

Ah ha. Thank you for this. @Julian-Wollersberger, you helped uncover a subtle bug in the new and improved defaults handling!

mkarlesky commented 4 months ago

@Julian-Wollersberger I believe the most recent prerelease fixes the problem. You won't need the :test_build and :cmock settings you added to work around the bug.

I'm going to close this issue. Please reopen if the issue is not resolved.

Julian-Wollersberger commented 4 months ago

Yes, it works now. Thanks!