Class: RSpec::Queue::Runner

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

Instance Method Summary collapse

Instance Method Details

#run_specs(example_groups) ⇒ Object



373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
# File 'lib/rspec/queue.rb', line 373

def run_specs(example_groups)
  examples = example_groups.flat_map(&:descendants).flat_map do |example_group|
    example_group.filtered_examples.map do |example|
      SingleExample.new(example_group, example)
    end
  end

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

  if queue.retrying?
    retry_queue = queue.retry_queue
    if retry_queue.exhausted?
      puts "Found 0 tests to retry, processing the main queue."
    else
      puts "Retrying #{retry_queue.size} failed tests."
      queue = retry_queue
    end
  end

  BuildStatusRecorder.build = queue.build
  queue.populate(examples, random: ordering_seed, &:id)
  examples_count = examples.size # TODO: figure out which stub value would be best
  success = true
  @configuration.reporter.report(examples_count) do |reporter|
    @configuration.add_formatter(BuildStatusRecorder)
    FileUtils.mkdir_p('log')
    @configuration.add_formatter(OrderRecorder, open('log/test_order.log', 'w+'))

    @configuration.with_suite_hooks do
      break if @world.wants_to_quit
      queue.poll do |example|
        success &= example.run(QueueReporter.new(reporter, queue, example))
        break if @world.wants_to_quit
      end
    end
  end

  return 0 if @world.non_example_failure
  success ? 0 : @configuration.failure_exit_code
end

#setup(err, out) ⇒ Object



365
366
367
368
369
370
371
# File 'lib/rspec/queue.rb', line 365

def setup(err, out)
  super
  invalid_usage!('Missing --queue parameter') unless queue_url
  invalid_usage!('Missing --build parameter') unless RSpec::Queue.config.build_id
  invalid_usage!('Missing --worker parameter') unless RSpec::Queue.config.worker_id
  RSpec.configuration.backtrace_formatter.filter_gem('ci-queue')
end