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



452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
# File 'lib/rspec/queue.rb', line 452

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



433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
# File 'lib/rspec/queue.rb', line 433

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.configure do |config|
    config.backtrace_exclusion_patterns = [
      # Filter bundler paths
      %r{/tmp/bundle/},
      # RSpec internals
      %r{/gems/rspec-},
      # ci-queue and rspec-queue internals
      %r{exe/rspec-queue},
      %r{lib/ci/queue/},
      %r{rspec/queue}
    ]
  end
end