#!/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