Class: Flakie::Engine

Inherits:
Object
  • Object
show all
Defined in:
lib/flakie/engine.rb

Instance Method Summary collapse

Constructor Details

#initialize(command, count:, reporter:) ⇒ Engine

Returns a new instance of Engine.



5
6
7
8
9
10
# File 'lib/flakie/engine.rb', line 5

def initialize(command, count:, reporter:)
  @command = command
  @count = count
  @reporter = reporter
  @report = Report.new([])
end

Instance Method Details

#runObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/flakie/engine.rb', line 12

def run
  reporter.open

  count.times do |index|
    start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
    system(command, out: File::NULL, err: File::NULL)
    end_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
    duration = (end_time - start_time).round
    report.runs.append Run.new(status: $?.success?, duration: duration, number: index + 1)
    reporter.report(report)
  end

  reporter.close
end