bug fixes with test runner

This commit is contained in:
Sam 2013-04-26 13:58:11 +10:00
parent 67dc590794
commit 5ccc3edcbe

View file

@ -104,7 +104,7 @@ class Autospec::Runner
end end
end end
end end
sleep 0.01
File.unlink('tmp/test_polling') File.unlink('tmp/test_polling')
wait_for(100) { works } wait_for(100) { works }
@ -115,16 +115,18 @@ class Autospec::Runner
works = true works = true
end end
works !works
end end
def process_change(files) def process_change(files)
return unless files.length > 0 return unless files.length > 0
specs = [] specs = []
hit = false
files.each do |file| files.each do |file|
MATCHERS.each do |k,v| MATCHERS.each do |k,v|
if m = k.match(file) if m = k.match(file)
hit = true
spec = v ? ( v.arity == 1 ? v.call(m) : v.call ) : file spec = v ? ( v.arity == 1 ? v.call(m) : v.call ) : file
if File.exists?(spec) || Dir.exists?(spec) if File.exists?(spec) || Dir.exists?(spec)
specs << [file, spec] specs << [file, spec]
@ -132,7 +134,7 @@ class Autospec::Runner
end end
end end
end end
queue_specs(specs) queue_specs(specs) if hit
rescue => e rescue => e
p "failed in watcher" p "failed in watcher"
p e p e
@ -157,7 +159,7 @@ class Autospec::Runner
if @queue.last && @queue.last[0] == "focus" if @queue.last && @queue.last[0] == "focus"
focus = @queue.pop focus = @queue.pop
@queue << [c,spec] @queue << [c,spec]
if focus[1].include? spec || c != spec if focus[1].include?(spec) || c != spec
@queue << focus @queue << focus
end end
else else
@ -168,9 +170,7 @@ class Autospec::Runner
end end
end end
def start_service_queue def thread_loop
@worker ||= Thread.new do
while true
@mutex.synchronize do @mutex.synchronize do
last_failed = false last_failed = false
current = @queue.last current = @queue.last
@ -186,13 +186,25 @@ class Autospec::Runner
end end
end end
end end
@signal.wait(@mutex) if @queue.length == 0 || last_failed wait = @queue.length == 0 || last_failed
@signal.wait(@mutex) if wait
end end
rescue => e
p "DISASTA PASTA"
puts e
puts e.backtrace
end
def start_service_queue
@worker ||= Thread.new do
while true
thread_loop
end end
end end
end end
def focus_on_failed_tests def focus_on_failed_tests
current = @queue.last
specs = failed_specs[0..10] specs = failed_specs[0..10]
if current[0] == "focus" if current[0] == "focus"
@queue.pop @queue.pop