From 9cfe2f1b35a08bd5e7c49619b3c1643d5a6c0ae8 Mon Sep 17 00:00:00 2001 From: Rohit Garg Date: Sun, 18 Oct 2015 16:27:12 +0530 Subject: [PATCH 01/16] Adding support for new config number of devices --- .gitignore | 1 + bin/parallel_calabash | 4 + lib/parallel_calabash.rb | 1 + lib/parallel_calabash/adb_helper.rb | 15 ++++ lib/parallel_calabash/ios/patches.rb | 12 +++ lib/parallel_calabash/ios/xcrun_helper.rb | 89 +++++++++++++++++++++++ lib/parallel_calabash/runner.rb | 45 ++++++------ lib/parallel_calabash/version.rb | 2 +- parallel_calabash.gemspec | 1 + 9 files changed, 147 insertions(+), 23 deletions(-) create mode 100644 lib/parallel_calabash/ios/patches.rb create mode 100644 lib/parallel_calabash/ios/xcrun_helper.rb diff --git a/.gitignore b/.gitignore index c941b28..ca31a51 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,5 @@ *.o *.a mkmf.log +.DS_Store test_files diff --git a/bin/parallel_calabash b/bin/parallel_calabash index 0ce81b1..33aa388 100755 --- a/bin/parallel_calabash +++ b/bin/parallel_calabash @@ -33,6 +33,10 @@ def parse_arguments(arguments) options[:device_target] = device_target end + opts.on('--num_emulators number', 'number of parallel ios emulators to launch for same user (SSH running will be avoided)') do |num_emulators| + options[:num_emulators] = num_emulators + end + opts.on('--device_endpoint endpoint', 'ios endpoint if no .parallel-calabash config') do |device_endpoint| options[:device_endpoint] = device_endpoint end diff --git a/lib/parallel_calabash.rb b/lib/parallel_calabash.rb index 633b326..d7ba9ec 100644 --- a/lib/parallel_calabash.rb +++ b/lib/parallel_calabash.rb @@ -22,6 +22,7 @@ def initialize(options) { DEVICE_TARGET: options[:device_target], DEVICE_ENDPOINT: options[:device_endpoint], + num_emulators: options[:num_emulators] }, options[:ios_config] ) diff --git a/lib/parallel_calabash/adb_helper.rb b/lib/parallel_calabash/adb_helper.rb index cee573c..016699d 100644 --- a/lib/parallel_calabash/adb_helper.rb +++ b/lib/parallel_calabash/adb_helper.rb @@ -66,6 +66,7 @@ def initialize(filter = nil, default_simulator = nil, config_file = nil, instrum else @config = File.exist?(config_file) ? eval(File.read(config_file)) : {} end + @no_of_devices = @default_simulator[:num_emulators].to_i || @config[:num_emulators].to_i @instruments = instruments || %x(instruments -s devices ; echo) # Bizarre workaround for xcode 7 end @@ -78,6 +79,8 @@ def connected_devices_with_model_info if @config[:DEVICES] configs = apply_filter(compute_devices) fail '** No devices (or users) unfiltered!' if configs.empty? + elsif @no_of_devices > 0 + configs = compute_simulators_to_create else configs = apply_filter(compute_simulators) configs = configs.empty? ? [@default_simulator] : configs @@ -85,6 +88,18 @@ def connected_devices_with_model_info @devices = configs end + def compute_simulators_to_create + port = (@config[:CALABASH_SERVER_PORT] || 28000).to_i + simulator = @config[:DEVICE_TARGET] || nil + (1..@no_of_devices).map do |i| + {}.tap do |my_hash| + my_hash[:SIMULATOR] = simulator unless simulator.nil? + my_hash[:DEVICE_NAME] = "PCalSimulator_#{i}" + my_hash[:CALABASH_SERVER_PORT] = port + i - 1 + end + end + end + def compute_simulators port = (@config[:CALABASH_SERVER_PORT] || 28000).to_i users = @config[:USERS] || [] diff --git a/lib/parallel_calabash/ios/patches.rb b/lib/parallel_calabash/ios/patches.rb new file mode 100644 index 0000000..6889b0f --- /dev/null +++ b/lib/parallel_calabash/ios/patches.rb @@ -0,0 +1,12 @@ +class <> Device: #{device_info} = #{device_name} = #{device_target}\n" + $stdout.print "#{process_number}>> Device: #{device_name} = #{device_target}\n" $stdout.flush unless @skip_ios_ping_check @@ -137,12 +136,19 @@ def command_for_test(process_number, test_files, app_path, cucumber_options, sim AUTOTEST: '1', DEVICE_ENDPOINT: device_endpoint, DEVICE_TARGET: device_target, - DEVICE_INFO: device_info, TEST_USER: device[:USER] || %x( whoami ).strip, # 'DEBUG_UNIX_CALLS' => '1', TEST_PROCESS_NUMBER: (process_number+1).to_s, - SCREENSHOT_PATH: "PCal_#{process_number+1}_" + SCREENSHOT_PATH: "PCal_#{process_number+1}_", + APP_BUNDLE_PATH: user_app } + + unless device[:USER] + xcrun_helper = ParallelCalabash::Ios::XcrunHelper.new(env, device[:DEVICE], device_target) + xcrun_helper.set_env_vars_if_needed + xcrun_helper.start_simulator_and_app_if_needed + end + env['BUNDLE_ID'] = ENV['BUNDLE_ID'] if ENV['BUNDLE_ID'] exports = env.map { |k, v| WINDOWS ? "(SET \"#{k}=#{v}\")" : "#{k}='#{v}';export #{k}" }.join(separator) @@ -202,23 +208,18 @@ def stop_and_remove(device_name, ssh) end end - def copy_app_set_port(app_path, device) - user_path = File.dirname(app_path) + '/' + device[:USER] - FileUtils.rmtree(user_path) - FileUtils.mkdir_p(user_path) - user_app = user_path + '/' + File.basename(app_path) - FileUtils.copy_entry(app_path, user_app) + def copy_app_set_port(app_path, device, target_path) + process_path = File.dirname(app_path) + '/' + target_path + FileUtils.rmtree(process_path) + FileUtils.mkdir_p(process_path) + process_app = process_path + '/' + File.basename(app_path) + FileUtils.copy_entry(app_path, process_app) - # Set plist. - - system("/usr/libexec/PlistBuddy -c 'Delete CalabashServerPort integer #{device[:CALABASH_SERVER_PORT]}' #{user_app}/Info.plist") - unless system("/usr/libexec/PlistBuddy -c 'Add CalabashServerPort integer #{device[:CALABASH_SERVER_PORT]}' #{user_app}/Info.plist") - raise "Unable to set CalabashServerPort in #{user_app}/Info.plist" - end + RunLoop::PlistBuddy.new.plist_set("CalabashServerPort", "integer", device[:CALABASH_SERVER_PORT], "#{process_app}/Info.plist") - puts "User app: #{user_app}" + puts "Process app: #{process_app}" - user_app + process_app end end end diff --git a/lib/parallel_calabash/version.rb b/lib/parallel_calabash/version.rb index 57f0226..9b92e1e 100644 --- a/lib/parallel_calabash/version.rb +++ b/lib/parallel_calabash/version.rb @@ -1,3 +1,3 @@ module ParallelCalabash - VERSION = "0.2.4" + VERSION = "0.2.5" end diff --git a/parallel_calabash.gemspec b/parallel_calabash.gemspec index 6372364..5364db2 100644 --- a/parallel_calabash.gemspec +++ b/parallel_calabash.gemspec @@ -20,5 +20,6 @@ Gem::Specification.new do |spec| spec.add_development_dependency "bundler", "~> 1.6" spec.add_development_dependency "rake", "~> 10.0" + spec.add_runtime_dependency "run_loop", ">= 1.5" spec.add_runtime_dependency 'parallel' end From 929a3a6f35d705e9b22dfd99572aa414d1d89f82 Mon Sep 17 00:00:00 2001 From: Rohit Garg Date: Sun, 18 Oct 2015 16:29:31 +0530 Subject: [PATCH 02/16] fixing some things related to config setup --- Gemfile | 3 ++- lib/parallel_calabash/adb_helper.rb | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index caa0351..68bcec1 100644 --- a/Gemfile +++ b/Gemfile @@ -5,4 +5,5 @@ gemspec gem 'rake' gem 'calabash-android' gem 'pry' -gem 'rspec' \ No newline at end of file +gem 'rspec' +gem 'run_loop' \ No newline at end of file diff --git a/lib/parallel_calabash/adb_helper.rb b/lib/parallel_calabash/adb_helper.rb index 016699d..57550c1 100644 --- a/lib/parallel_calabash/adb_helper.rb +++ b/lib/parallel_calabash/adb_helper.rb @@ -66,7 +66,7 @@ def initialize(filter = nil, default_simulator = nil, config_file = nil, instrum else @config = File.exist?(config_file) ? eval(File.read(config_file)) : {} end - @no_of_devices = @default_simulator[:num_emulators].to_i || @config[:num_emulators].to_i + @no_of_devices = @default_simulator[:num_emulators].to_i || @config[:NO_OF_DEVICES].to_i @instruments = instruments || %x(instruments -s devices ; echo) # Bizarre workaround for xcode 7 end From 76f15fb0fb47c746e5cdc77aa0b1c2a669eb07ce Mon Sep 17 00:00:00 2001 From: Rohit Garg Date: Sun, 18 Oct 2015 16:50:55 +0530 Subject: [PATCH 03/16] Added connectivity and fixed one issue with number of device calculation --- lib/parallel_calabash/adb_helper.rb | 2 +- lib/parallel_calabash/ios/connectivity.rb | 31 +++++++++++++++++++++++ lib/parallel_calabash/ios/xcrun_helper.rb | 3 +-- 3 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 lib/parallel_calabash/ios/connectivity.rb diff --git a/lib/parallel_calabash/adb_helper.rb b/lib/parallel_calabash/adb_helper.rb index 57550c1..3a5effc 100644 --- a/lib/parallel_calabash/adb_helper.rb +++ b/lib/parallel_calabash/adb_helper.rb @@ -66,7 +66,7 @@ def initialize(filter = nil, default_simulator = nil, config_file = nil, instrum else @config = File.exist?(config_file) ? eval(File.read(config_file)) : {} end - @no_of_devices = @default_simulator[:num_emulators].to_i || @config[:NO_OF_DEVICES].to_i + @no_of_devices = (@default_simulator[:num_emulators] || @config[:NO_OF_DEVICES]).to_i @instruments = instruments || %x(instruments -s devices ; echo) # Bizarre workaround for xcode 7 end diff --git a/lib/parallel_calabash/ios/connectivity.rb b/lib/parallel_calabash/ios/connectivity.rb new file mode 100644 index 0000000..653ff7c --- /dev/null +++ b/lib/parallel_calabash/ios/connectivity.rb @@ -0,0 +1,31 @@ +module ParallelCalabash + class TimeoutErr < RuntimeError + end + module Ios + class Connectivity + def self.ensure launcher + raise "ping_app not present in launcher!" unless launcher.respond_to? "ping_app" + connected = false + until connected do + begin + Timeout::timeout(90, TimeoutErr) do + until connected + begin + connected = (launcher.ping_app == '200') + break if connected + rescue Exception => e + puts "Retry connection after 1 second" + ensure + sleep 1 unless connected + end + end + end + rescue TimeoutErr => e + puts 'Timed out... exiting' + stop + end + end + end + end + end +end \ No newline at end of file diff --git a/lib/parallel_calabash/ios/xcrun_helper.rb b/lib/parallel_calabash/ios/xcrun_helper.rb index 5e40c16..12f1cfa 100644 --- a/lib/parallel_calabash/ios/xcrun_helper.rb +++ b/lib/parallel_calabash/ios/xcrun_helper.rb @@ -40,8 +40,7 @@ def self.try_stop_simulator device_uuid, state, ssh def self.create_simulator(device_name, ssh, simulator) stop_and_remove(device_name, ssh) - - device_info = %x( #{ssh} "xcrun simctl create \"#{device_name}\" #{simulator}" ).strip + device_info = %x( #{ssh} "xcrun simctl create '#{device_name}' #{simulator}" ).strip fail "Failed to create #{device_name} for #{simulator}" unless device_info device_info end From 332c6247cd94f406bbbad31dadd71e4fdc54c9c8 Mon Sep 17 00:00:00 2001 From: Rohit Garg Date: Sun, 18 Oct 2015 17:19:10 +0530 Subject: [PATCH 04/16] Adding one more patch for supporting the new run_loop things --- lib/parallel_calabash/ios/patches.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/parallel_calabash/ios/patches.rb b/lib/parallel_calabash/ios/patches.rb index 6889b0f..5178a93 100644 --- a/lib/parallel_calabash/ios/patches.rb +++ b/lib/parallel_calabash/ios/patches.rb @@ -3,6 +3,13 @@ def terminate_all_sims puts "Patched!!" end end + +class < Date: Sun, 18 Oct 2015 17:26:56 +0530 Subject: [PATCH 05/16] Updated readme --- README.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 53af241..53ab2c0 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,7 @@ Example: parallel_calabash -app my.app --ios_config ~/.parallel_calabash.iphoneo -v, --version Show version --app app_path app file path --device_target target ios target if no .parallel-calabash config + --num_emulators number number of parallel ios emulators to launch for same user (SSH running will be avoided) --device_endpoint endpoint ios endpoint if no .parallel-calabash config --simulator type for simctl create, e.g. 'com.apple.CoreSimulator.SimDeviceType.iPhone-6 com.apple.CoreSimulator.SimRuntime.iOS-8-4' --ios_config file for ios, configuration for devices and users @@ -67,7 +68,16 @@ Example: parallel_calabash -app my.app --ios_config ~/.parallel_calabash.iphoneo ### iOS set-up * iOS testing is only supported on MacOS hosts. -* Create as many (Administrator-privileged!) test accounts as you have devices or want simulators (Settings > Users & Groups) +* For basic setup, use the below config and launch the parallel tests + +As follows: + + { + NO_OF_DEVICES: 3, + DEVICE_TARGET: "'iPhone 5s' '8.4'" + } + +* For different user based control, create as many (Administrator-privileged!) test accounts as you have devices or want simulators (Settings > Users & Groups) * As the main user, the one that runs parallel_calabash, create ~/.parallel_calabash.iphonesimulator and/or ~/.parallel_calabash.iphoneos As follows: From c6e0bf1f8c398ee9ffa90b8369a44c157556c249 Mon Sep 17 00:00:00 2001 From: Rohit Garg Date: Fri, 23 Oct 2015 15:46:38 +0530 Subject: [PATCH 06/16] Removed unnecessary section from readme, use flags directly, no need to use config --- README.md | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 53ab2c0..7b68f6f 100644 --- a/README.md +++ b/README.md @@ -68,14 +68,8 @@ Example: parallel_calabash -app my.app --ios_config ~/.parallel_calabash.iphoneo ### iOS set-up * iOS testing is only supported on MacOS hosts. -* For basic setup, use the below config and launch the parallel tests - -As follows: - - { - NO_OF_DEVICES: 3, - DEVICE_TARGET: "'iPhone 5s' '8.4'" - } +* For basic run, use the below command and launch the parallel tests +parallel_calabash -app my.app --num_emulators 3 --simulator 'com.apple.CoreSimulator.SimDeviceType.iPhone-6 com.apple.CoreSimulator.SimRuntime.iOS-8-4' -o '-cucumber -opts' -r '-cucumber -reports>' features/ * For different user based control, create as many (Administrator-privileged!) test accounts as you have devices or want simulators (Settings > Users & Groups) * As the main user, the one that runs parallel_calabash, create ~/.parallel_calabash.iphonesimulator and/or ~/.parallel_calabash.iphoneos From 603c3df92a70a542d28563d8a8315365e041c3ec Mon Sep 17 00:00:00 2001 From: Rohit Garg Date: Mon, 26 Oct 2015 13:14:01 +0530 Subject: [PATCH 07/16] Method stop isn't there, doing a break instead for flow recovery --- lib/parallel_calabash/ios/connectivity.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/parallel_calabash/ios/connectivity.rb b/lib/parallel_calabash/ios/connectivity.rb index 653ff7c..02f186b 100644 --- a/lib/parallel_calabash/ios/connectivity.rb +++ b/lib/parallel_calabash/ios/connectivity.rb @@ -22,7 +22,7 @@ def self.ensure launcher end rescue TimeoutErr => e puts 'Timed out... exiting' - stop + break end end end From 82f0375a46726d99070fd224f45df9d0db80a759 Mon Sep 17 00:00:00 2001 From: Rohit Garg Date: Tue, 27 Oct 2015 15:34:03 +0530 Subject: [PATCH 08/16] Added code for new xcode launch mechanism and added patches for launch --- lib/parallel_calabash/ios/patches.rb | 16 +++++++++++++--- lib/parallel_calabash/ios/xcrun_helper.rb | 6 ++++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/lib/parallel_calabash/ios/patches.rb b/lib/parallel_calabash/ios/patches.rb index 5178a93..5c88101 100644 --- a/lib/parallel_calabash/ios/patches.rb +++ b/lib/parallel_calabash/ios/patches.rb @@ -1,19 +1,29 @@ class < Date: Tue, 27 Oct 2015 16:41:49 +0530 Subject: [PATCH 09/16] Added process number to the log file extension --- lib/parallel_calabash/runner.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/parallel_calabash/runner.rb b/lib/parallel_calabash/runner.rb index dfde11b..21b0245 100644 --- a/lib/parallel_calabash/runner.rb +++ b/lib/parallel_calabash/runner.rb @@ -99,7 +99,7 @@ def run_tests(test_files, process_number, options) o = execute_command_for_process(process_number, test) device = @device_helper.device_for_process process_number - log = "/tmp/PCal-#{device[:USER]}.process_number" + log = "/tmp/PCal-#{device[:USER]}.#{process_number}" puts "Writing log #{log}" open(log, 'w') { |file| file.print o[:stdout] } o From 3c63427c4530cc5db83c437e85143decbeb7636c Mon Sep 17 00:00:00 2001 From: Rohit Garg Date: Tue, 27 Oct 2015 23:19:59 +0530 Subject: [PATCH 10/16] Added popup closing logic on launch testing, initial debugging using run-loop basic --- lib/parallel_calabash/ios/patches.rb | 2 +- lib/parallel_calabash/ios/xcrun_helper.rb | 18 +++++++++--------- lib/parallel_calabash/runner.rb | 3 +++ misc/startup_popup_close.js | 7 +++++++ 4 files changed, 20 insertions(+), 10 deletions(-) create mode 100644 misc/startup_popup_close.js diff --git a/lib/parallel_calabash/ios/patches.rb b/lib/parallel_calabash/ios/patches.rb index 5c88101..0615366 100644 --- a/lib/parallel_calabash/ios/patches.rb +++ b/lib/parallel_calabash/ios/patches.rb @@ -23,7 +23,7 @@ def ensure_software_keyboard device puts "patched ensure_software_keyboard" end - def quit_sim + def quit_sim opts={} puts "Patched quit_sim" end end diff --git a/lib/parallel_calabash/ios/xcrun_helper.rb b/lib/parallel_calabash/ios/xcrun_helper.rb index 112d6fb..120b74f 100644 --- a/lib/parallel_calabash/ios/xcrun_helper.rb +++ b/lib/parallel_calabash/ios/xcrun_helper.rb @@ -56,20 +56,19 @@ def start_simulator_and_app_if_needed %x( xcrun simctl boot '#{@simulator_uuid}' ) %x( xcrun simctl install '#{@simulator_uuid}' '#{@env[:APP_BUNDLE_PATH]}' ) %x( xcrun simctl shutdown '#{@simulator_uuid}' ) - %x( open -na "#{XcrunHelper.sim_name}" --args -CurrentDeviceUDID #{@simulator_uuid} ) - %x( instruments -w '#{@simulator_uuid}' ) + %x( xcrun open -n -g -a "#{XcrunHelper.sim_name}" --args -CurrentDeviceUDID #{@simulator_uuid} ) + %x( mkdir -p ./.run-loop/#{@simulator_uuid} ) launch_app end end def launch_app - app_bundle_id = ::RunLoop::PlistBuddy.new.plist_read('CFBundleIdentifier', @env[:APP_BUNDLE_PATH] + '/Info.plist') - pid = %x( xcrun simctl launch #{@simulator_uuid} #{app_bundle_id} ) - if pid != "" && @env != nil - @env[:APP_PID_INFO] = pid.strip - @env[:NO_LAUNCH] = '1' - end - pid + %x( instruments -w '#{@simulator_uuid}' \ + -D './.run-loop/#{@simulator_uuid}/instrument.trace' \ + -t Automation '#{@env[:APP_BUNDLE_PATH]}' \ + -e UIASCRIPT '#{File.join(File.dirname(__FILE__),"../../../misc/startup_popup_close.js")}' \ + -e UIARESULTSPATH ./.run-loop/#{@simulator_uuid} \ + >& ./.run-loop/#{@simulator_uuid}/run-loop.out ) end def set_env_vars_if_needed @@ -77,6 +76,7 @@ def set_env_vars_if_needed @env[:DEVICE_TARGET] = device_instruments_target(@simulator_uuid) @env[:SIMULATOR_UUID] = @simulator_uuid end + @env[:NO_LAUNCH] = '1' end private diff --git a/lib/parallel_calabash/runner.rb b/lib/parallel_calabash/runner.rb index 21b0245..304ef9d 100644 --- a/lib/parallel_calabash/runner.rb +++ b/lib/parallel_calabash/runner.rb @@ -185,6 +185,9 @@ def prepare_for_parallel_execution FileUtils.chmod_R('g+w', 'build/reports') if File.exists? 'build/reports' FileUtils.chmod('g+w', Dir['*']) FileUtils.chmod('g+w', '.') + + #remove run loop files if any + FileUtils.rm_rf(".run-loop") end def create_simulator(device_name, ssh, simulator) diff --git a/misc/startup_popup_close.js b/misc/startup_popup_close.js new file mode 100644 index 0000000..2c57de5 --- /dev/null +++ b/misc/startup_popup_close.js @@ -0,0 +1,7 @@ +UIATarget.onAlert = function onAlert(alert) { + var title = alert.name(); + UIALogger.logWarning("Alert with title '" + title + "' encountered."); + return true; +} +UIATarget.localTarget().delay(4); +UIATarget.localTarget().frontMostApp().alert().buttons()[0].tap(); From c4331f387b6d18302b3974aededbba34a670b045 Mon Sep 17 00:00:00 2001 From: Rohit Garg Date: Tue, 27 Oct 2015 23:23:13 +0530 Subject: [PATCH 11/16] Updated README with requirements --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 7b68f6f..f449be1 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,12 @@ Example: parallel_calabash -app my.app --ios_config ~/.parallel_calabash.iphoneo * iOS testing is only supported on MacOS hosts. * For basic run, use the below command and launch the parallel tests parallel_calabash -app my.app --num_emulators 3 --simulator 'com.apple.CoreSimulator.SimDeviceType.iPhone-6 com.apple.CoreSimulator.SimRuntime.iOS-8-4' -o '-cucumber -opts' -r '-cucumber -reports>' features/ +* You would require to add following code to your env.rb file + +if ENV["TEST_PROCESS_NUMBER"] + require 'parallel_calabash/ios/patches' + launcher.relaunch(timeout: 90, relaunch_simulator: false, quit_sim_on_init: false) +end * For different user based control, create as many (Administrator-privileged!) test accounts as you have devices or want simulators (Settings > Users & Groups) * As the main user, the one that runs parallel_calabash, create ~/.parallel_calabash.iphonesimulator and/or ~/.parallel_calabash.iphoneos From 36483e92b76e40cac33e74d4547b74feaee827fd Mon Sep 17 00:00:00 2001 From: Rohit Garg Date: Wed, 28 Oct 2015 13:12:07 +0530 Subject: [PATCH 12/16] Added folders to users home directory for inspection --- lib/parallel_calabash/ios/xcrun_helper.rb | 8 ++++---- lib/parallel_calabash/runner.rb | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/parallel_calabash/ios/xcrun_helper.rb b/lib/parallel_calabash/ios/xcrun_helper.rb index 120b74f..76f1fae 100644 --- a/lib/parallel_calabash/ios/xcrun_helper.rb +++ b/lib/parallel_calabash/ios/xcrun_helper.rb @@ -57,18 +57,18 @@ def start_simulator_and_app_if_needed %x( xcrun simctl install '#{@simulator_uuid}' '#{@env[:APP_BUNDLE_PATH]}' ) %x( xcrun simctl shutdown '#{@simulator_uuid}' ) %x( xcrun open -n -g -a "#{XcrunHelper.sim_name}" --args -CurrentDeviceUDID #{@simulator_uuid} ) - %x( mkdir -p ./.run-loop/#{@simulator_uuid} ) + %x( mkdir -p ~/.parallel-loop/#{@simulator_uuid} ) launch_app end end def launch_app %x( instruments -w '#{@simulator_uuid}' \ - -D './.run-loop/#{@simulator_uuid}/instrument.trace' \ + -D '~/.parallel-loop/#{@simulator_uuid}/instrument.trace' \ -t Automation '#{@env[:APP_BUNDLE_PATH]}' \ -e UIASCRIPT '#{File.join(File.dirname(__FILE__),"../../../misc/startup_popup_close.js")}' \ - -e UIARESULTSPATH ./.run-loop/#{@simulator_uuid} \ - >& ./.run-loop/#{@simulator_uuid}/run-loop.out ) + -e UIARESULTSPATH ~/.parallel-loop/#{@simulator_uuid} \ + >& ~/.parallel-loop/#{@simulator_uuid}/run-loop.out ) end def set_env_vars_if_needed diff --git a/lib/parallel_calabash/runner.rb b/lib/parallel_calabash/runner.rb index 304ef9d..e965437 100644 --- a/lib/parallel_calabash/runner.rb +++ b/lib/parallel_calabash/runner.rb @@ -187,7 +187,7 @@ def prepare_for_parallel_execution FileUtils.chmod('g+w', '.') #remove run loop files if any - FileUtils.rm_rf(".run-loop") + FileUtils.rm_rf("~/.parallel-loop") end def create_simulator(device_name, ssh, simulator) From f0dece6242e168e9903b3087a1fff8acf689cfe4 Mon Sep 17 00:00:00 2001 From: Rohit Garg Date: Fri, 30 Oct 2015 21:41:18 +0530 Subject: [PATCH 13/16] Readme formatting --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f449be1..adfe207 100644 --- a/README.md +++ b/README.md @@ -69,13 +69,15 @@ Example: parallel_calabash -app my.app --ios_config ~/.parallel_calabash.iphoneo * iOS testing is only supported on MacOS hosts. * For basic run, use the below command and launch the parallel tests -parallel_calabash -app my.app --num_emulators 3 --simulator 'com.apple.CoreSimulator.SimDeviceType.iPhone-6 com.apple.CoreSimulator.SimRuntime.iOS-8-4' -o '-cucumber -opts' -r '-cucumber -reports>' features/ + $ parallel_calabash -app my.app --num_emulators 3 --simulator 'com.apple.CoreSimulator.SimDeviceType.iPhone-6 com.apple.CoreSimulator.SimRuntime.iOS-8-4' -o '-cucumber -opts' -r '-cucumber -reports>' features/ * You would require to add following code to your env.rb file +```ruby if ENV["TEST_PROCESS_NUMBER"] require 'parallel_calabash/ios/patches' launcher.relaunch(timeout: 90, relaunch_simulator: false, quit_sim_on_init: false) end +``` * For different user based control, create as many (Administrator-privileged!) test accounts as you have devices or want simulators (Settings > Users & Groups) * As the main user, the one that runs parallel_calabash, create ~/.parallel_calabash.iphonesimulator and/or ~/.parallel_calabash.iphoneos From 9f509a8eaed4e6be726470d4f200acfd3330222f Mon Sep 17 00:00:00 2001 From: Rohit Garg Date: Fri, 30 Oct 2015 21:42:27 +0530 Subject: [PATCH 14/16] Readme formatting --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index adfe207..7bb13a7 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,7 @@ Example: parallel_calabash -app my.app --ios_config ~/.parallel_calabash.iphoneo * iOS testing is only supported on MacOS hosts. * For basic run, use the below command and launch the parallel tests + $ parallel_calabash -app my.app --num_emulators 3 --simulator 'com.apple.CoreSimulator.SimDeviceType.iPhone-6 com.apple.CoreSimulator.SimRuntime.iOS-8-4' -o '-cucumber -opts' -r '-cucumber -reports>' features/ * You would require to add following code to your env.rb file From b12e7dfe2fd716d7b2706985c4a71946c3b75cb8 Mon Sep 17 00:00:00 2001 From: Rohit Garg Date: Fri, 30 Oct 2015 21:44:01 +0530 Subject: [PATCH 15/16] Readme formatting --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 7bb13a7..e50a442 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,7 @@ Example: parallel_calabash -app my.app --ios_config ~/.parallel_calabash.iphoneo * For basic run, use the below command and launch the parallel tests $ parallel_calabash -app my.app --num_emulators 3 --simulator 'com.apple.CoreSimulator.SimDeviceType.iPhone-6 com.apple.CoreSimulator.SimRuntime.iOS-8-4' -o '-cucumber -opts' -r '-cucumber -reports>' features/ + * You would require to add following code to your env.rb file ```ruby From 62a26e2bb68ddbfa6911b2da532ad1a4a9b3344e Mon Sep 17 00:00:00 2001 From: Rohit Garg Date: Fri, 30 Oct 2015 21:47:08 +0530 Subject: [PATCH 16/16] Readme formatting --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e50a442..83b0a8a 100644 --- a/README.md +++ b/README.md @@ -69,9 +69,9 @@ Example: parallel_calabash -app my.app --ios_config ~/.parallel_calabash.iphoneo * iOS testing is only supported on MacOS hosts. * For basic run, use the below command and launch the parallel tests - - $ parallel_calabash -app my.app --num_emulators 3 --simulator 'com.apple.CoreSimulator.SimDeviceType.iPhone-6 com.apple.CoreSimulator.SimRuntime.iOS-8-4' -o '-cucumber -opts' -r '-cucumber -reports>' features/ - +``` +$ parallel_calabash -app my.app --num_emulators 3 --simulator 'com.apple.CoreSimulator.SimDeviceType.iPhone-6 com.apple.CoreSimulator.SimRuntime.iOS-8-4' -o '-cucumber -opts' -r '-cucumber -reports>' features/ +``` * You would require to add following code to your env.rb file ```ruby