我正在使用 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 命令,如下所示:
我尝试了很多定义在 从 Rakefile 执行 bash 命令
好吧,留下评论的人肯定引导我走向正确的方向。结果是通过在我的project.yml中定义[:tools] test_compiler并使用系统“ceedling test:all”而不是sh“ceedling test:all”来执行测试。我不确定为什么我必须定义 ceedling 编译器选项,但我认为 Chiperific 走在正确的轨道上。从 rakefile 运行可能没有 Ceedling 期望的环境变量。