概要
- Cのプログラムを作成する際に、guardを使用してファイルの変更を検知して、ビルド、テスト実行を繰り返す。
利点
- ファイルの変更を検知した時点でビルドとテストが行われるので、コンパイルエラーやテストが落ちたことがすぐわかる
構築手順
rubyの環境は作成済みとします
1. Gemfileを作成
source 'https://rubygems.org'
gem 'guard'
gem 'guard-shell'
2.インストール
bundle install
3.Guardfile作成
bundle exec guard init
# A sample Guardfile
# More info at https://github.com/guard/guard#readme
# Add files and commands to this file, like the example:
# watch(%r{file/path}) { `command(s)` }
#
guard 'shell' do
watch(/(.*).txt/) {|m| `tail #{m[0]}` }
end
例
guard 'shell' do
watch(%r{^.+\.(h|c)$}) do
`make test`
end
end
4.Guardを起動します。
bundle exec guard
これでファイルの変更を検知してビルドやテストが実行されます。
参考資料
http://stackoverflow.com/questions/9673629/using-ruby-guard-gem-to-monitor-c-files