snapshot/lib/snapshot/runner.rb in fastlane-2.13.0 vs snapshot/lib/snapshot/runner.rb in fastlane-2.14.0

- old
+ new

@@ -49,10 +49,12 @@ 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) + + copy_simulator_logs(device, language, locale, launch_arguments) end end end print_results(results) @@ -60,14 +62,10 @@ UI.user_error!(self.collected_errors.join('; ')) if self.collected_errors.count > 0 # Generate HTML report ReportsGenerator.new.generate - if Snapshot.config[:output_simulator_logs] - output_simulator_logs - end - # Clear the Derived Data unless Snapshot.config[:derived_data_path] FileUtils.rm_rf(TestCommandGenerator.derived_data_path) end end @@ -98,18 +96,20 @@ else launch_arguments.map.with_index { |e, i| [i, e] } end end - def output_simulator_logs - Snapshot.config[:devices].each do |device_name| - device = TestCommandGenerator.find_device(device_name) - sim_device_logfilepath_source = File.expand_path("~/Library/Logs/CoreSimulator/#{device.udid}/system.log") - next unless File.exist?(sim_device_logfilepath_source) + def copy_simulator_logs(device_name, language, locale, launch_arguments) + return unless Snapshot.config[:output_simulator_logs] - sim_device_logfilepath_dest = File.join(Snapshot.config[:output_directory], "#{device.name}_#{device.os_type}_#{device.os_version}_system.log") - FileUtils.cp(sim_device_logfilepath_source, sim_device_logfilepath_dest) - end + detected_language = locale || language + language_folder = File.join(Snapshot.config[:output_directory], detected_language) + device = TestCommandGenerator.find_device(device_name) + components = [launch_arguments].delete_if { |a| a.to_s.length == 0 } + + UI.header("Collecting system logs #{device_name} - #{language}") + logarchive_dest = File.join(language_folder, "system_logs-" + Digest::MD5.hexdigest(components.join("-")) + ".logarchive") + FastlaneCore::Simulator.copy_logarchive(device, logarchive_dest) end def print_results(results) return if results.count == 0