Rakefile から Ceedling を実行する
概要
ceedling を使用して単体テストを作成しています。また、プロジェクトのトップレベルで rakefile を利用して、さまざまなタスクを自動化しています。ランニングシードリングの自動化にも使っていきたいと思っています。そうしようとすると、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
編集:ネイティブシェルはbashですが、次のようなbashコマンドを実行するためにさまざまなruby呼び出しを試しました。
Rakefileからbashコマンドを実行するで定義されている多くのことを試しました
解決策
コメントを残した人たちは間違いなく私を正しい方向に導いてくれました。 project.yml で [:tools] test_compiler を定義し、sh “ceedling test:all” の代わりにシステム “ceedling test:all” を使用すると、テストが実行されることがわかりました。なぜ ceedling コンパイラ オプションを定義する必要があるのかわかりませんが、Chiperific は正しい方向に進んでいたと思います。 rakefile からの実行には、Ceedling が予期する環境変数がない可能性があります。