Class: RSpecTurbo::Executor

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec_turbo/executor.rb

Overview

Runs the planned batches across a fixed pool of slots: one Worker per free slot at a time, slots recycled as workers finish until the queue drains.

Renders a live multi-line dashboard on a TTY (per-worker spinner lines plus a global progress bar) and periodic single-line [progress] updates on CI.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(planner, display, rspec_options) ⇒ Executor

Returns a new instance of Executor.



12
13
14
15
16
17
18
19
# File 'lib/rspec_turbo/executor.rb', line 12

def initialize(planner, display, rspec_options)
  @planner = planner
  @display = display
  @rspec_options = rspec_options
  @labels = planner.batches.each_index.map { |i| format("worker/%02d", i + 1) }
  @slots = (1..planner.batches.size).to_a
  @total_examples = planner.counts.values.sum
end

Instance Attribute Details

#wall_startedObject (readonly)

Returns the value of attribute wall_started.



10
11
12
# File 'lib/rspec_turbo/executor.rb', line 10

def wall_started
  @wall_started
end

Instance Method Details

#runObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/rspec_turbo/executor.rb', line 21

def run
  pending = Queue.new
  @planner.batches.each_with_index { |units, i| pending << [@labels[i], units] }

  results = []
  @wall_started = Process.clock_gettime(Process::CLOCK_MONOTONIC)

  if Config::TTY
    run_tty(pending, results)
  else
    run_plain(pending, results)
  end

  results
end