Search code examples
rubyrakeceedling

Run Ceedling from Rakefile


I am using ceedling to write unit tests. I also utilize a rakefile at the top level of my project to automate a variety of tasks. I would like to also use it to automate running ceedling. When I attempt to do so, there seems to be a conflict between my rakefile and ceedling.

I have the following project structure:

Project
  -> src
    -> project.yml
    -> test
    -> src.c
    -> src.h
    -> build
  -> rakefile.rb
  -> build

My rakefile has a command that does the following:

desc "Run Unit Test"
task :unit do
   Dir.chdir('src') do
      sh "ceedling test:all"
   end
end

When I execute this rake command, I get the following errors:

ERROR: Required config file entry [:tools][:test_compiler][:executable] does not exist.
ERROR: Required config file entry [:tools][:test_file_preprocessor][:executable] does not exist.
ERROR: Required config file entry [:tools][:test_includes_preprocessor][:executable] does not exist.
/var/lib/gems/3.0.0/gems/ceedling-0.31.1/lib/ceedling/configurator.rb:309:in `validate': unhandled exception
    from /var/lib/gems/3.0.0/gems/ceedling-0.31.1/lib/ceedling/setupinator.rb:32:in `do_setup'
    from /var/lib/gems/3.0.0/gems/ceedling-0.31.1/lib/ceedling/rakefile.rb:47:in `<top (required)>'
    from /var/lib/gems/3.0.0/gems/ceedling-0.31.1/lib/ceedling.rb:66:in `load'
    from /var/lib/gems/3.0.0/gems/ceedling-0.31.1/lib/ceedling.rb:66:in `load_project'
    from /var/lib/gems/3.0.0/gems/ceedling-0.31.1/bin/ceedling:329:in `<top (required)>'
    from /usr/local/bin/ceedling:25:in `load

EDIT: Native shell is bash, but I have tried a variety of ruby calls to run the bash command such as the following:

  • sh
  • %x
  • system

I tried a lot defined in Execute bash commands from a Rakefile


Solution

  • Ok so the folks that left comments definitely steered me in the right direction. Turns out by defining [:tools] test_compiler in my project.yml and using system "ceedling test:all" instead of sh "ceedling test:all" executes the tests. I'm not sure why I have to define the ceedling compiler options, but I think Chiperific was on the right track. Running from a rakefile may not have the environment variables that Ceedling expects.