Class: Megatest::MultiProcess::Executor
- Inherits:
-
Object
- Object
- Megatest::MultiProcess::Executor
- Defined in:
- lib/megatest/multi_process.rb
Instance Attribute Summary collapse
-
#wall_time ⇒ Object
readonly
Returns the value of attribute wall_time.
Instance Method Summary collapse
- #after_fork_in_child(active_job) ⇒ Object
-
#initialize(config, out) ⇒ Executor
constructor
A new instance of Executor.
- #run(queue, reporters) ⇒ Object
Constructor Details
Instance Attribute Details
#wall_time ⇒ Object (readonly)
Returns the value of attribute wall_time.
204 205 206 |
# File 'lib/megatest/multi_process.rb', line 204 def wall_time @wall_time end |
Instance Method Details
#after_fork_in_child(active_job) ⇒ Object
211 212 213 214 215 |
# File 'lib/megatest/multi_process.rb', line 211 def after_fork_in_child(active_job) @jobs.each do |job| job.close unless job == active_job end end |
#run(queue, reporters) ⇒ Object
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 |
# File 'lib/megatest/multi_process.rb', line 217 def run(queue, reporters) start_time = Megatest.now @config.run_global_setup_callbacks @jobs = @config.jobs_count.times.map { |index| Job.new(@config, index) } @config.before_fork_callbacks.each(&:call) @jobs.each { |j| j.run(self, queue.test_cases_index) } monitor = InlineMonitor.new(@config, queue) if queue.respond_to?(:heartbeat) begin while true monitor&.tick dead_jobs = @jobs.select(&:closed?).each { |j| j.on_exit(queue, reporters) } @jobs -= dead_jobs break if @jobs.empty? break if queue.empty? @jobs.select(&:idle?).each do |job| job.process(queue, reporters) end reads, = IO.select(@jobs, nil, nil, 1) reads&.each do |job| job.process(queue, reporters) end break if @config.circuit_breaker.break? end rescue Interrupt @jobs.each(&:term) # Early exit end @jobs.each(&:close) @jobs.each(&: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 queue.cleanup end |