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



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
302
303
304
305
# File 'lib/rspec/queue.rb', line 271

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 leader was elected. This typically means no worker was able to start. Were there any errors during application boot?"
    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