1 ENV['FOG_MOCK'] ||= 'true'
2 ENV['AUTOTEST'] = 'true'
8 growlnotify = `which growlnotify`.chomp
9 title = "Watchr Test Results"
11 when /(\d+)\s+?(failure|error)/i
12 ($1.to_i == 0) ? "~/.watchr_images/passed.png" : "~/.watchr_images/failed.png"
14 '~/.watchr_images/unknown.png'
16 options = "-w -n Watchr --image '#{File.expand_path(image)}' -m '#{message}' '#{title}'"
17 system %(#{growlnotify} #{options} &)
25 def run_spec_test(file)
27 result = run "rspec --format p --color #{file}"
28 growl result.split("\n").last
31 puts "FIXME: No test #{file} [#{Time.now}]"
35 def filter_rspec(data)
36 data.split("\n").find_all do |l|
37 l =~ /^(\d+)\s+exampl\w+.*?(\d+).*?failur\w+.*?(\d+).*?pending/
43 files = Dir.glob("spec/**/*_spec.rb").join(" ")
44 result = run "rspec #{files}"
45 growl_results = filter_rspec result
48 puts "GROWL: #{growl_results}"
53 puts " --- Running all tests ---\n\n"
65 puts "Interrupt a second time to quit"
68 # raise Interrupt, nil # let the run loop catch it
74 result = file.sub('lib/puppet/', 'spec/unit/puppet/').gsub(/\.rb$/, '_spec.rb')
75 result = file.sub('lib/facter/', 'spec/unit/facter/').gsub(/\.rb$/, '_spec.rb')
79 watch( 'spec/.*_spec\.rb' ) do |md|
83 watch( 'lib/.*\.rb' ) do |md|
84 # run_spec_test(file2spec(md[0]))