ruby 从Rakefile运行Ceedling

wb1gzix0  于 12个月前  发布在  Ruby
关注(0)|答案(1)|浏览(92)

我正在使用ceedling编写单元测试。我还在项目的顶层使用rakefile来自动执行各种任务。我也想用它来自动运行ceedling。当我试图这样做时,我的rakefile和ceedling之间似乎存在冲突。
我有以下项目结构:

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

我的rakefile有一个执行以下操作的命令:

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

当我执行这个rake命令时,我得到以下错误:

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

编辑:原生shell是bash,但我已经尝试了各种ruby调用来运行bash命令,如下所示:

  • sh
  • %x
  • 系统

我尝试了很多定义在Execute bash commands from a Rakefile

q5lcpyga

q5lcpyga1#

好吧,所以那些留下评论的人肯定把我引向了正确的方向。结果是,通过在我的项目.yml中定义[:tools] test_compiler并使用system“ceedling test:all”而不是sh“ceedling test:all”来执行测试。我不知道为什么我必须定义ceedling编译器选项,但我认为Chiperific是在正确的轨道上。从rakefile运行可能没有Ceedling期望的环境变量。

相关问题