bug fixes with test runner
This commit is contained in:
parent
67dc590794
commit
5ccc3edcbe
|
@ -95,7 +95,7 @@ class Autospec::Runner
|
||||||
n = INotify::Notifier.new
|
n = INotify::Notifier.new
|
||||||
FileUtils.touch('tmp/test_polling')
|
FileUtils.touch('tmp/test_polling')
|
||||||
|
|
||||||
n.watch("./tmp/test_polling"){ works = true }
|
n.watch("./tmp/test_polling"){works = true }
|
||||||
quit = false
|
quit = false
|
||||||
Thread.new do
|
Thread.new do
|
||||||
while !works && !quit
|
while !works && !quit
|
||||||
|
@ -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,31 +170,41 @@ class Autospec::Runner
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def thread_loop
|
||||||
|
@mutex.synchronize do
|
||||||
|
last_failed = false
|
||||||
|
current = @queue.last
|
||||||
|
if current
|
||||||
|
result = run_spec(current[1])
|
||||||
|
if result == 0
|
||||||
|
@queue.pop
|
||||||
|
else
|
||||||
|
last_failed = true
|
||||||
|
if result.to_i > 0
|
||||||
|
focus_on_failed_tests
|
||||||
|
ensure_all_specs_will_run
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
wait = @queue.length == 0 || last_failed
|
||||||
|
@signal.wait(@mutex) if wait
|
||||||
|
end
|
||||||
|
rescue => e
|
||||||
|
p "DISASTA PASTA"
|
||||||
|
puts e
|
||||||
|
puts e.backtrace
|
||||||
|
end
|
||||||
|
|
||||||
def start_service_queue
|
def start_service_queue
|
||||||
@worker ||= Thread.new do
|
@worker ||= Thread.new do
|
||||||
while true
|
while true
|
||||||
@mutex.synchronize do
|
thread_loop
|
||||||
last_failed = false
|
|
||||||
current = @queue.last
|
|
||||||
if current
|
|
||||||
result = run_spec(current[1])
|
|
||||||
if result == 0
|
|
||||||
@queue.pop
|
|
||||||
else
|
|
||||||
last_failed = true
|
|
||||||
if result.to_i > 0
|
|
||||||
focus_on_failed_tests
|
|
||||||
ensure_all_specs_will_run
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@signal.wait(@mutex) if @queue.length == 0 || last_failed
|
|
||||||
end
|
|
||||||
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
|
||||||
|
|
Loading…
Reference in New Issue