lib/snapshot/runner.rb in snapshot-1.7.0 vs lib/snapshot/runner.rb in snapshot-1.8.0

- old
+ new

@@ -16,10 +16,12 @@ UI.error "Please follow the migration guide: https://github.com/fastlane/snapshot/blob/master/MigrationGuide.md" UI.error "And read the updated documentation: https://github.com/fastlane/snapshot" sleep 3 # to be sure the user sees this, as compiling clears the screen end + Snapshot.config[:output_directory] = File.expand_path(Snapshot.config[:output_directory]) + verify_helper_is_current FastlaneCore::PrintTable.print_values(config: Snapshot.config, hide_keys: [], title: "Summary for snapshot #{Snapshot::VERSION}") clear_previous_screenshots if Snapshot.config[:clear_previous_screenshots] @@ -114,12 +116,20 @@ Fixes::SimulatorZoomFix.patch Snapshot.kill_simulator # because of https://github.com/fastlane/snapshot/issues/337 `xcrun simctl shutdown booted &> /dev/null` - uninstall_app(device_type) if Snapshot.config[:reinstall_app] + if Snapshot.config[:erase_simulator] + erase_simulator(device_type) + elsif Snapshot.config[:reinstall_app] + # no need to reinstall if device has been erased + uninstall_app(device_type) + end + add_media(device_type, :photo, Snapshot.config[:add_photos]) if Snapshot.config[:add_photos] + add_media(device_type, :video, Snapshot.config[:add_videos]) if Snapshot.config[:add_videos] + command = TestCommandGenerator.generate(device_type: device_type) UI.header("#{device_type} - #{language}") prefix_hash = [ @@ -163,9 +173,33 @@ UI.message "Launch Simulator #{device_type}" Helper.backticks("xcrun instruments -w #{device_udid} &> /dev/null") UI.message "Uninstall application #{Snapshot.config[:app_identifier]}" Helper.backticks("xcrun simctl uninstall #{device_udid} #{Snapshot.config[:app_identifier]} &> /dev/null") + end + + def erase_simulator(device_type) + Helper.log.debug "Erasing #{device_type}..." + device_udid = TestCommandGenerator.device_udid(device_type) + + Helper.log.info "Erasing #{device_type}...".yellow + + `xcrun simctl erase #{device_udid} &> /dev/null` + end + + def add_media(device_type, media_type, paths) + media_type = media_type.to_s + + UI.verbose "Adding #{media_type}s to #{device_type}..." + device_udid = TestCommandGenerator.device_udid(device_type) + + UI.message "Launch Simulator #{device_type}" + Helper.backticks("xcrun instruments -w #{device_udid} &> /dev/null") + + paths.each do |path| + UI.message "Adding '#{path}'" + Helper.backticks("xcrun simctl add#{media_type} #{device_udid} #{path.shellescape} &> /dev/null") + end end def clear_previous_screenshots UI.important "Clearing previously generated screenshots" path = File.join(".", Snapshot.config[:output_directory], "*", "*.png")