madx (owner)

Revisions

gist: 99782 Download_button fork
public
Public Clone URL: git://gist.github.com/99782.git
Text
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/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