forked from wezm/wezm.net
Add automatically-build-and-test-with-guard
This commit is contained in:
parent
c75ee670c6
commit
6279931338
2 changed files with 48 additions and 0 deletions
|
@ -0,0 +1,36 @@
|
||||||
|
I'm currently working on a [node.js][node] module ([node-genx]) with a C++ component.
|
||||||
|
Each time a change was made to the code its necessary to rebuild the
|
||||||
|
module then run the tests. This was getting tiring so I decided to use
|
||||||
|
[guard] to automate the process.
|
||||||
|
|
||||||
|
[node]: http://nodejs.org/
|
||||||
|
[node-genx]: https://github.com/wezm/node-genx
|
||||||
|
[guard]: https://github.com/guard/guard
|
||||||
|
|
||||||
|
guard is a ruby gem that provides a DSL for performing actions when
|
||||||
|
a set of watched files change. There a bunch of "guards" available
|
||||||
|
that provide out of the box support for things like [rspec], [jammit],
|
||||||
|
[sass] and [CoffeeScript][coffee-script]. For simple custom cases
|
||||||
|
like mine there is also [guard-shell], which will run a shell
|
||||||
|
command when one of its watched files changes.
|
||||||
|
|
||||||
|
[coffee-script]: http://jashkenas.github.com/coffee-script/
|
||||||
|
[rspec]: http://rspec.info/
|
||||||
|
[jammit]: http://documentcloud.github.com/jammit/
|
||||||
|
[sass]: http://sass-lang.com/
|
||||||
|
[guard-shell]: https://github.com/guard/guard-shell
|
||||||
|
|
||||||
|
guard uses a Guardfile akin to a Makefile in you project directory to
|
||||||
|
configure the guards. Mine looks like this:
|
||||||
|
|
||||||
|
guard 'shell' do
|
||||||
|
watch(%r".*\.(?:cc|h)") { |m| `node-waf build && jasbin` }
|
||||||
|
watch(%r"spec/.*_spec\..*") {|m| `jasbin --verbose` }
|
||||||
|
end
|
||||||
|
|
||||||
|
This runs `node-waf build && jasbin` to rebuild the module and run the
|
||||||
|
tests when any of the C++ source files or headers change. It just runs
|
||||||
|
the the tests when any of the spec files change.
|
||||||
|
|
||||||
|
Once your Guardfile is setup simply run `guard` in you project directory
|
||||||
|
and it will start watching for changes.
|
|
@ -0,0 +1,12 @@
|
||||||
|
---
|
||||||
|
title: Automatically Build and Test With Guard
|
||||||
|
extra: How to use guard to automatically build and test a node.js C++ module.
|
||||||
|
kind: article
|
||||||
|
section: technical
|
||||||
|
created_at: 2011-01-25 22:31:00
|
||||||
|
keywords:
|
||||||
|
- guard
|
||||||
|
- node
|
||||||
|
- ruby
|
||||||
|
- js
|
||||||
|
- testing
|
Loading…
Reference in a new issue