class Loupe::Executor

Executor

This abstract parent class is responsible for providing the basics for executors. Concrete classes are the process and ractor executors.

Public Class Methods

new(options) click to toggle source

@param options [Hash<Symbol, BasicObject>] @return [Loupe::Executor]

# File lib/loupe/executor.rb, line 13
def initialize(options)
  @options = options
  @queue = populate_queue
  @reporter = options[:interactive] ? PagedReporter.new(options) : PlainReporter.new(options)
end

Public Instance Methods

run() click to toggle source

@return [Integer]

# File lib/loupe/executor.rb, line 20
def run
  raise NotImplementedError, "Concrete implementations of executors should implement the run method"
end

Private Instance Methods

populate_queue() click to toggle source

Populate the test queue with entries including the class and the test method to be executed. E.g.:

[[MyTest, :test_something], [AnotherTest, :test_another_thing]]

@return [Array<Array<Class, Symbol>>]

# File lib/loupe/executor.rb, line 32
def populate_queue
  Test.classes.flat_map do |klass, line_numbers|
    list = klass.test_list

    unless line_numbers.empty?
      list.select! do |method_name|
        line_numbers.include?(klass.instance_method(method_name).source_location.last.to_s)
      end
    end

    list.map! { |method| [klass, method] }.shuffle!
  end
end