Class: ParallelCalabash::ParallelCalabashApp
- Inherits:
-
Object
- Object
- ParallelCalabash::ParallelCalabashApp
- Defined in:
- lib/parallel_calabash.rb
Instance Method Summary collapse
- #any_test_failed?(test_results) ⇒ Boolean
-
#initialize(options) ⇒ ParallelCalabashApp
constructor
A new instance of ParallelCalabashApp.
- #number_of_processes_to_start ⇒ Object
- #report_time_taken ⇒ Object
- #run_tests_in_parallel ⇒ Object
Constructor Details
#initialize(options) ⇒ ParallelCalabashApp
Returns a new instance of ParallelCalabashApp.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/parallel_calabash.rb', line 15 def initialize() = @helper = if .has_key?(:apk_path) ParallelCalabash::AdbHelper.new([:filter]) else ParallelCalabash::IosHelper.new( [:filter], { DEVICE_TARGET: [:device_target], DEVICE_ENDPOINT: [:device_endpoint], }, [:ios_config] ) end @runner = if .has_key?(:apk_path) ParallelCalabash::AndroidRunner.new(@helper, [:mute_output]) else ParallelCalabash::IosRunner.new(@helper, [:mute_output], [:skip_ios_ping_check]) end end |
Instance Method Details
#any_test_failed?(test_results) ⇒ Boolean
70 71 72 |
# File 'lib/parallel_calabash.rb', line 70 def any_test_failed?(test_results) test_results.any? { |result| result[:exit_status] != 0 } end |
#number_of_processes_to_start ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/parallel_calabash.rb', line 37 def number_of_processes_to_start number_of_processes = @helper.number_of_connected_devices raise "\n**** NO DEVICE FOUND ****\n" if number_of_processes==0 puts '*******************************' puts " #{number_of_processes} DEVICES FOUND:" puts @helper.connected_devices_with_model_info puts '*******************************' number_of_processes end |
#report_time_taken ⇒ Object
74 75 76 77 78 79 80 |
# File 'lib/parallel_calabash.rb', line 74 def report_time_taken start = Time.now yield time_in_sec = Time.now - start mm, ss = time_in_sec.divmod(60) puts "\nTook #{mm} Minutes, #{ss.round(2)} Seconds" end |
#run_tests_in_parallel ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/parallel_calabash.rb', line 47 def run_tests_in_parallel @runner.prepare_for_parallel_execution number_of_processes = number_of_processes_to_start test_results = nil report_time_taken do groups = FeatureGrouper.feature_groups(, number_of_processes) threads = groups.size puts "Running with #{threads} threads: #{groups}" complete = [] test_results = Parallel.map_with_index( groups, :in_threads => threads, :finish => lambda { |_, i, _| complete.push(i); print complete, "\n" }) do |group, index| @runner.run_tests(group, index, ) end puts 'All threads complete' ResultFormatter.report_results(test_results) end @runner.prepare_for_parallel_execution puts 'Parallel run complete' Kernel.exit(1) if any_test_failed?(test_results) end |