Skip to content

Instantly share code, notes, and snippets.

@martinrehfeld
Created July 21, 2011 08:42
Show Gist options
  • Save martinrehfeld/1096802 to your computer and use it in GitHub Desktop.
Save martinrehfeld/1096802 to your computer and use it in GitHub Desktop.
Erlang "autotest" -- run your eunit suites automatically when changing files (uses rebar + Ruby guard)
source 'http://rubygems.org'
group :development, :test do
gem 'guard-shell'
gem 'rb-fsevent'
gem 'growl'
end
# automatically run the eunit tests
def run_eunit(src, suite)
if File.exist?(File.join(File.dirname(__FILE__), 'test', "#{suite}_tests.erl"))
cmd = "./rebar eunit skip_deps=true suite=#{suite}"
puts "Executing #{cmd}"
puts `#{cmd}`
if $? == 0
Growl.notify_ok "#{suite}: eunit passed."
else
Growl.notify_error "#{suite}: eunit failed."
end
else
puts "No tests for #{suite.inspect}"
Growl.notify_warning "No tests for #{suite}!"
end
end
guard 'shell' do
watch(%r{(src|test)/([^.].*?)(_tests)?.erl}) {|m| run_eunit(m[1], m[2]) }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment