diff --git a/lib/autospec/formatter.rb b/lib/autospec/formatter.rb index bbc151b194c..32bdd810595 100644 --- a/lib/autospec/formatter.rb +++ b/lib/autospec/formatter.rb @@ -4,17 +4,36 @@ module Autospec; end class Autospec::Formatter < RSpec::Core::Formatters::BaseFormatter def dump_summary(duration, total, failures, pending) - failed_specs = examples.delete_if{|e| e.execution_result[:status] != "failed"}.map{|s| s.metadata[:location]} + # failed_specs = examples.delete_if{|e| e.execution_result[:status] != "failed"}.map{|s| s.metadata[:location]} - # if this fails don't kill everything - begin - FileUtils.mkdir_p('tmp') - File.open("./tmp/rspec_result","w") do |f| - f.puts failed_specs.join("\n") - end - rescue - # nothing really we can do, at least don't kill the test runner - end + # # if this fails don't kill everything + # begin + # FileUtils.mkdir_p('tmp') + # File.open("./tmp/rspec_result","w") do |f| + # f.puts failed_specs.join("\n") + # end + # rescue + # # nothing really we can do, at least don't kill the test runner + # end + super end + def start(count) + FileUtils.mkdir_p('tmp') + @fail_file = File.open("./tmp/rspec_result","w") + super(count) + end + + def close + @fail_file.close + super + end + + def example_failed(example) + @fail_file.puts example.metadata[:location] + @fail_file.flush + super(example) + end + + end diff --git a/lib/autospec/runner.rb b/lib/autospec/runner.rb index d03afd09e22..f73e23db510 100644 --- a/lib/autospec/runner.rb +++ b/lib/autospec/runner.rb @@ -68,7 +68,36 @@ class Autospec::Runner @signal.signal end - Process.wait(@spork_pid) + spork_running = true + Thread.new do + Process.wait(@spork_pid) + spork_running = false + end + + while spork_running + + STDIN.gets + + if @queue.length == 0 + @queue << ['spec', 'spec'] + @signal.signal + else + specs = failed_specs(:delete => false) + puts + puts + if specs.length == 0 + puts "No specs have failed yet!" + puts + else + puts "The following specs have failed: " + specs.each do |s| + puts s + end + puts + end + end + end + puts "Spork has been terminated, exiting" rescue => e @@ -221,12 +250,12 @@ class Autospec::Runner end end - def failed_specs + def failed_specs(opts={:delete => true}) specs = [] path = './tmp/rspec_result' if File.exist?(path) specs = File.open(path) { |file| file.read.split("\n") } - File.delete(path) + File.delete(path) if opts[:delete] end specs