Skip to content

Instantly share code, notes, and snippets.

@madx
Created April 22, 2009 13:05
Show Gist options
  • Save madx/99782 to your computer and use it in GitHub Desktop.
Save madx/99782 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# Command line autotest tool
target = ARGV[0]
raise ArgumentError if target.nil? || !File.exist?(target)
running = true
trap "INT" do
puts "Interrupted by user"
exit
end
trap "TSTP" do
running = !running
end
loop do
puts "spec -cfp #{target}"
result = `spec -cfp #{target}`
if $?.to_i > 0
message = `spec -cfe #{target}`
system "notify-send -i dialog-error -u critical 'Spec failed' '#{message}'"
puts result
puts "Stopping til you fix that bug! Hit ^Z to restart"
running = false
end
if running
sleep 3
else
sleep until running
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment