Class: Megatest::Executor

Inherits:
AbstractExecutor show all
Defined in:
lib/megatest/executor.rb

Defined Under Namespace

Classes: ExternalMonitor

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractExecutor

#initialize

Constructor Details

This class inherits a constructor from Megatest::AbstractExecutor

Instance Attribute Details

#wall_timeObject (readonly)

Returns the value of attribute wall_time.



68
69
70
# File 'lib/megatest/executor.rb', line 68

def wall_time
  @wall_time
end

Instance Method Details

#concurrent?Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/megatest/executor.rb', line 70

def concurrent?
  false
end

#run(queue, reporters) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/megatest/executor.rb', line 74

def run(queue, reporters)
  start_time = Megatest.now

  @config.run_global_setup_callbacks
  @config.run_job_setup_callbacks(nil)

  monitor = ExternalMonitor.new(@config) if queue.respond_to?(:heartbeat)

  reporters.each { |r| r.start(self, queue) }

  runner = Runner.new(@config)

  begin
    while true
      if test_case = queue.pop_test
        reporters.each { |r| r.before_test_case(queue, test_case) }

        result = runner.execute(test_case)

        result = queue.record_result(result)
        reporters.each { |r| r.after_test_case(queue, test_case, result) }

        @config.circuit_breaker.record_result(result)
        break if @config.circuit_breaker.break?
      elsif queue.empty?
        break
      else
        # There was no tests to pop, but not all tests are completed.
        # So we stick around to pop tests that could be lost.
        sleep(1)
      end
    end
  rescue Interrupt
    # Early exit
  end

  monitor&.reap

  @wall_time = Megatest.now - start_time
  reporters.each { |r| r.summary(self, queue, queue.summary) }

  if @config.circuit_breaker.break?
    @out.error("Exited early because too many failures were encountered")
  end

  @config.run_job_teardown_callbacks(nil)

  queue.cleanup
end