Created
October 3, 2012 18:42
-
-
Save acidlabs-snippets/3828928 to your computer and use it in GitHub Desktop.
#GIT #Hook #tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# | |
tests = [ | |
{:name => "RSPEC", :command => "rake spec"}, | |
{:name => "JASMINE", :command => "jasmine-headless-webkit --color"} | |
] | |
tests.each do |test| | |
puts "\e[33mEXECUTING #{test[:name]} TESTS\e[0m" | |
test[:result] = system test[:command] | |
end | |
all_ok = tests.none? {|test| not test[:result]} | |
if all_ok | |
puts "\e[32mAll systems green! proceeding with the commit...\e[0m" | |
else | |
puts "\e[31mSome tests are failing! Fix 'em before you commit again.\e[0m" | |
end | |
exit all_ok ? 0 : 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment