Class: RSpec::Queue::ReportRunner

Inherits:
Object
  • Object
show all
Includes:
CI::Queue::OutputHelpers, RunnerHelpers
Defined in:
lib/rspec/queue.rb

Instance Method Summary collapse

Instance Method Details

#call(options, stdout, stderr) ⇒ Object



267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
# File 'lib/rspec/queue.rb', line 267

def call(options, stdout, stderr)
  setup(options, stdout, stderr)

  queue = CI::Queue.from_uri(queue_url, RSpec::Queue.config)

  supervisor = begin
    queue.supervisor
  rescue NotImplementedError => error
    abort! error.message
  end

  step("Waiting for workers to complete")

  unless supervisor.wait_for_workers
    unless supervisor.queue_initialized?
      abort! "No master was elected. Did all workers crash?"
    end

    unless supervisor.exhausted?
      abort! "#{supervisor.size} tests weren't run."
    end
  end

  # TODO: better reporting
  errors = supervisor.build.error_reports.sort_by(&:first).map(&:last)
  if errors.empty?
    step(green('No errors found'))
    0
  else
    message = errors.size == 1 ? "1 error found" : "#{errors.size} errors found"
    step(red(message), collapsed: false)
    puts errors
    1
  end
end