class TestCenter::Helper::MultiScanManager::ParallelTestBatchWorker
Attributes
pid[R]
Public Class Methods
new(options)
click to toggle source
Calls superclass method
# File lib/fastlane/plugin/test_center/helper/multi_scan_manager/parallel_test_batch_worker.rb, line 11 def initialize(options) super(options) @pipe_endpoint = nil @@colors ||= String.colors - %i[white black light_green default] @color = @@colors.sample @@colors = @@colors - [@color] end
Public Instance Methods
close_parent_process_writer()
click to toggle source
# File lib/fastlane/plugin/test_center/helper/multi_scan_manager/parallel_test_batch_worker.rb, line 95 def close_parent_process_writer @writer.close end
handle_child_process_results(tests_passed)
click to toggle source
# File lib/fastlane/plugin/test_center/helper/multi_scan_manager/parallel_test_batch_worker.rb, line 88 def handle_child_process_results(tests_passed) # as suggested by the method name, this is done in the Child process @logfile.close @writer.puts tests_passed.to_s @writer.close end
open_interprocess_communication()
click to toggle source
# File lib/fastlane/plugin/test_center/helper/multi_scan_manager/parallel_test_batch_worker.rb, line 66 def open_interprocess_communication # This is performed in the Parent process in preparation to setup # the STDOUT and STDOUT for printing messages from the Child process # to a file. This is done so that when multiple processes write # messages, they will not be written to the console in a broken # interlaced manner. @reader, @writer = IO.pipe @log_filepath = File.join( Dir.mktmpdir, "parallel-test-batch-#{@options[:batch_index] + 1}.txt" ) end
print_final_results(tests_passed)
click to toggle source
# File lib/fastlane/plugin/test_center/helper/multi_scan_manager/parallel_test_batch_worker.rb, line 62 def print_final_results(tests_passed) FastlaneCore::UI.verbose("All tests passed for batch #{@options[:batch_index] + 1}? #{tests_passed}") end
process_results()
click to toggle source
# File lib/fastlane/plugin/test_center/helper/multi_scan_manager/parallel_test_batch_worker.rb, line 24 def process_results # This is performed in the Parent process @pid = nil worker_prefix = "[worker #{@options[:batch_index] + 1}] " File.foreach(@log_filepath) do |line| unless FastlaneCore::Helper.colors_disabled? worker_prefix = worker_prefix.colorize(@color) end print worker_prefix print line end state = :ready_to_work @options[:test_batch_results] << (@reader.gets.chomp.to_s == 'true') end
reroute_stdout_to_logfile()
click to toggle source
# File lib/fastlane/plugin/test_center/helper/multi_scan_manager/parallel_test_batch_worker.rb, line 79 def reroute_stdout_to_logfile @reader.close # we are now in the subprocess. Write all stdout to the # log file to prevent interlaced messages @logfile = File.open(@log_filepath, 'w') @logfile.sync = true $stdout.reopen(@logfile) $stderr.reopen(@logfile) end
run(run_options)
click to toggle source
Calls superclass method
# File lib/fastlane/plugin/test_center/helper/multi_scan_manager/parallel_test_batch_worker.rb, line 41 def run(run_options) self.state = :working open_interprocess_communication @pid = Process.fork do tests_passed = false begin reroute_stdout_to_logfile tests_passed = super(run_options) rescue StandardError => e puts e.message puts e.backtrace.inspect ensure print_final_results(tests_passed) handle_child_process_results(tests_passed) exit! end end close_parent_process_writer end
state=(new_state)
click to toggle source
Calls superclass method
# File lib/fastlane/plugin/test_center/helper/multi_scan_manager/parallel_test_batch_worker.rb, line 20 def state=(new_state) super(new_state) end