lib/test_queue/iterator.rb in test-queue-0.3.0 vs lib/test_queue/iterator.rb in test-queue-0.3.1

- old
+ new

@@ -4,11 +4,10 @@ def initialize(test_framework, sock, filter=nil, early_failure_limit: nil) @test_framework = test_framework @done = false @suite_stats = [] - @procline = $0 @sock = sock @filter = filter if @sock =~ /^(.+):(\d+)$/ @tcp_address = $1 @tcp_port = $2.to_i @@ -18,10 +17,12 @@ end def each fail "already used this iterator. previous caller: #@done" if @done + procline = $0 + while true # If we've hit too many failures in one worker, assume the entire # test suite is broken, and notify master so the run # can be immediately halted. if @early_failure_limit && @failures >= @early_failure_limit @@ -37,21 +38,21 @@ if data = client.read(65536) client.close item = Marshal.load(data) break if item.nil? || item.empty? if item == "WAIT" - $0 = "#{@procline} - Waiting for work" + $0 = "#{procline} - Waiting for work" sleep 0.1 next end suite_name, path = item suite = load_suite(suite_name, path) # Maybe we were told to load a suite that doesn't exist anymore. next unless suite - $0 = "#{@procline} - #{suite.respond_to?(:description) ? suite.description : suite}" + $0 = "#{procline} - #{suite.respond_to?(:description) ? suite.description : suite}" start = Time.now if @filter @filter.call(suite){ yield suite } else yield suite @@ -62,9 +63,10 @@ break end end rescue Errno::ENOENT, Errno::ECONNRESET, Errno::ECONNREFUSED ensure + $0 = procline @done = caller.first File.open("/tmp/test_queue_worker_#{$$}_suites", "wb") do |f| Marshal.dump(@suite_stats, f) end end