module KnapsackPro::Extensions::RSpecExtension::Runner

Public Instance Methods

knapsack__deprecated_run_all_when_everything_filtered_enabled?() click to toggle source

must be called after ‘Runner#knapsack__setup` that loads the `spec_helper.rb` configuration

# File lib/knapsack_pro/extensions/rspec_extension.rb, line 56
def knapsack__deprecated_run_all_when_everything_filtered_enabled?
  configuration.respond_to?(:run_all_when_everything_filtered) && !!configuration.run_all_when_everything_filtered
end
knapsack__error_exit_code() click to toggle source

Based on: github.com/rspec/rspec-core/blob/f8c8880dabd8f0544a6f91d8d4c857c1bd8df903/lib/rspec/core/configuration.rb#L546

# File lib/knapsack_pro/extensions/rspec_extension.rb, line 51
def knapsack__error_exit_code
  configuration.error_exit_code # nil unless `--error-exit-code` is specified
end
knapsack__exit_early() click to toggle source
# File lib/knapsack_pro/extensions/rspec_extension.rb, line 45
def knapsack__exit_early
  _exit_status = configuration.reporter.exit_early(exit_code)
end
knapsack__load_spec_files_batch(test_file_paths) click to toggle source

@param test_file_paths Array

Example: ['a_spec.rb', 'b_spec.rb[1:1]']
# File lib/knapsack_pro/extensions/rspec_extension.rb, line 66
def knapsack__load_spec_files_batch(test_file_paths)
  world.reset

  # Reset filters, but do not reset `configuration.static_config_filter_manager` to preserve the --tag option
  filter_manager = RSpec::Core::FilterManager.new
  options.configure_filter_manager(filter_manager)
  configuration.filter_manager = filter_manager

  configuration.knapsack__load_spec_files(test_file_paths)
end
knapsack__persist_example_statuses() click to toggle source

Based on: github.com/rspec/rspec-core/blob/f8c8880dabd8f0544a6f91d8d4c857c1bd8df903/lib/rspec/core/runner.rb#L90

# File lib/knapsack_pro/extensions/rspec_extension.rb, line 123
def knapsack__persist_example_statuses
  persist_example_statuses
end
knapsack__rspec_is_quitting?() click to toggle source
# File lib/knapsack_pro/extensions/rspec_extension.rb, line 41
def knapsack__rspec_is_quitting?
  world.respond_to?(:rspec_is_quitting) && world.rspec_is_quitting
end
knapsack__run_specs(queue_runner) click to toggle source

Based on: github.com/rspec/rspec-core/blob/f8c8880dabd8f0544a6f91d8d4c857c1bd8df903/lib/rspec/core/runner.rb#L113

Ignore ‘configuration.fail_if_no_examples` in Queue Mode:

* a late CI node, started after all tests were executed by other nodes, is expected to receive an empty batch
* a batch could contain tests with no examples (e.g. commented out)

@return [Fixnum] exit status code.

# File lib/knapsack_pro/extensions/rspec_extension.rb, line 85
def knapsack__run_specs(queue_runner)
  # Based on:
  # https://github.com/rspec/rspec-core/blob/f8c8880dabd8f0544a6f91d8d4c857c1bd8df903/lib/rspec/core/world.rb#L53
  ordering_strategy = configuration.ordering_registry.fetch(:global)
  node_examples_passed = true

  configuration.reporter.report(_expected_example_count = 0) do |reporter|
    configuration.with_suite_hooks do
      queue_runner.with_batch do |test_file_paths, queue|
        knapsack__load_spec_files_batch(test_file_paths)

        examples_passed = ordering_strategy.order(world.example_groups).map do |example_group|
          queue_runner.handle_signal!
          example_group.run(reporter)
        end.all?

        if examples_passed
          queue.mark_batch_passed
        else
          queue.mark_batch_failed
          node_examples_passed = false
        end

        knapsack__persist_example_statuses

        if reporter.fail_fast_limit_met?
          queue_runner.log_fail_fast_limit_met
          break
        end
      end
    end

    exit_code(node_examples_passed)
  end
end
knapsack__seed() click to toggle source
# File lib/knapsack_pro/extensions/rspec_extension.rb, line 60
def knapsack__seed
  Seed.new(configuration.seed.to_s, configuration.seed_used?)
end
knapsack__setup(stream_error = $stderr, stream_out = $stdout) click to toggle source

Based on: github.com/rspec/rspec-core/blob/f8c8880dabd8f0544a6f91d8d4c857c1bd8df903/lib/rspec/core/runner.rb#L98

‘@configuration.load_spec_files` is not called because we load tests in batches with `knapsack__load_spec_files_batch` later on.

# File lib/knapsack_pro/extensions/rspec_extension.rb, line 31
def knapsack__setup(stream_error = $stderr, stream_out = $stdout)
  configure(stream_error, stream_out)
ensure
  world.knapsack__announce_filters
end
knapsack__wants_to_quit?() click to toggle source
# File lib/knapsack_pro/extensions/rspec_extension.rb, line 37
def knapsack__wants_to_quit?
  world.wants_to_quit
end