Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
3
Help us understand the problem. What is going on with this article?
@masayuki_oguni

Cプログラムをguardを使って開発する

More than 5 years have passed since last update.

概要

  • 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

これでファイルの変更を検知してビルドやテストが実行されます。

参考資料

3
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
3
Help us understand the problem. What is going on with this article?