2
ENV['AUTOTEST'] = 'true'
7
old_sync = $stdout.sync
11
open("| #{cmd}", "r") do |f|
17
results << if RUBY_VERSION >= "1.9" then
27
$stdout.sync = old_sync
36
def growl(message, status)
37
# Strip the color codes
38
message.gsub!(/\[\d+m/, '')
40
growlnotify = `which growlnotify`.chomp
41
return if growlnotify.empty?
42
title = "Watchr Test Results"
43
image = status == :pass ? "autotest/images/pass.png" : "autotest/images/fail.png"
44
options = "-w -n Watchr --image '#{File.expand_path(image)}' -m '#{message}' '#{title}'"
45
system %(#{growlnotify} #{options} &)
49
%w{spec/unit spec/integration}.collect { |d|
50
file.sub('lib/puppet', d)
57
result = file.sub('lib/puppet', 'test')
58
return nil unless File.exist?(result)
64
result = run_comp(command).split("\n").last
65
status = result.include?('0 failures') ? :pass : :fail
71
result = run_comp(command).split("\n").last
72
status = result.include?('0 failures, 0 errors') ? :pass : :fail
73
growl result.split("\n").last rescue nil
76
def run_test_file(file)
80
def run_spec_files(files)
82
return if files.empty?
83
opts = File.readlines('spec/spec.opts').collect { |l| l.chomp }.join(" ")
84
run_spec("spec #{files.join(' ')}")
100
watch('spec/spec_helper.rb') { run_all_specs }
101
watch(%r{^spec/(unit|integration)/.*\.rb$}) { |md| run_spec_files(md[0]) }
102
watch(%r{^lib/puppet/(.*)\.rb$}) { |md|
103
run_spec_files(file2specs(md[0]))
104
if t = file2test(md[0])
108
watch(%r{^spec/lib/spec.*}) { |md| run_all_specs }
109
watch(%r{^spec/lib/monkey_patches/.*}) { |md| run_all_specs }
110
watch(%r{test/.+\.rb}) { |md|
111
if md[0] =~ /\/lib\//
119
Signal.trap 'QUIT' do
120
puts " --- Running all tests ---\n\n"
129
@wants_to_quit = true
132
puts "Interrupt a second time to quit; wait for rerun of tests"
135
# raise Interrupt, nil # let the run loop catch it