lib/snapshot/runner.rb in snapshot-1.13.0 vs lib/snapshot/runner.rb in snapshot-1.13.1

- old
+ new

@@ -7,10 +7,11 @@ attr_accessor :number_of_retries_due_to_failing_simulator # All the errors we experience while running snapshot attr_accessor :collected_errors + # rubocop:disable Metrics/AbcSize def work if File.exist?("./fastlane/snapshot.js") or File.exist?("./snapshot.js") UI.error "Found old snapshot configuration file 'snapshot.js'" UI.error "You updated to snapshot 1.0 which now uses UI Automation" UI.error "Please follow the migration guide: https://github.com/fastlane/snapshot/blob/master/MigrationGuide.md" @@ -30,20 +31,24 @@ self.number_of_retries_due_to_failing_simulator = 0 self.collected_errors = [] results = {} # collect all the results for a nice table launch_arguments_set = config_launch_arguments - Snapshot.config[:devices].each do |device| + Snapshot.config[:devices].each_with_index do |device, device_index| launch_arguments_set.each do |launch_arguments| - Snapshot.config[:languages].each do |language| + Snapshot.config[:languages].each_with_index do |language, language_index| locale = nil if language.kind_of?(Array) locale = language[1] language = language[0] end results[device] ||= {} + current_run = device_index * Snapshot.config[:languages].count + language_index + 1 + number_of_runs = Snapshot.config[:languages].count * Snapshot.config[:devices].count + UI.message("snapshot run #{current_run} of #{number_of_runs}") + results[device][language] = run_for_device_and_language(language, locale, device, launch_arguments) end end end @@ -57,10 +62,11 @@ # Clear the Derived Data unless Snapshot.config[:derived_data_path] FileUtils.rm_rf(TestCommandGenerator.derived_data_path) end end + # rubocop:enable Metrics/AbcSize # This is its own method so that it can re-try if the tests fail randomly # @return true/false depending on if the tests succeded def run_for_device_and_language(language, locale, device, launch_arguments, retries = 0) return launch(language, locale, device, launch_arguments) @@ -190,22 +196,14 @@ return Collector.fetch_screenshots(raw_output, dir_name, device_type, launch_arguments.first) end # rubocop:enable Metrics/AbcSize - def open_simulator_for_device(device) + def open_simulator_for_device(device_name) return unless ENV['FASTLANE_EXPLICIT_OPEN_SIMULATOR'] - # As a second level of feature switching, see if we want to try the xcode-select variant - if ENV['FASTLANE_EXPLICIT_OPEN_SIMULATOR'] == '2' - simulator_path = File.join(FastlaneCore::Helper.xcode_path, 'Applications', 'Simulator.app') - UI.message("Explicitly opening simulator at #{simulator_path} for device: #{device}") - else - simulator_path = 'Simulator' - UI.message("Explicitly opening simulator for device: #{device}") - end - - `open -a #{simulator_path} --args -CurrentDeviceUDID #{TestCommandGenerator.device_udid(device)}` + device = TestCommandGenerator.find_device(device_name) + FastlaneCore::Simulator.launch(device) if device end def uninstall_app(device_type) UI.verbose "Uninstalling app '#{Snapshot.config[:app_identifier]}' from #{device_type}..." Snapshot.config[:app_identifier] ||= ask("App Identifier: ")