lib/snapshot/runner.rb in snapshot-0.7.0 vs lib/snapshot/runner.rb in snapshot-0.7.1

- old
+ new

@@ -3,20 +3,20 @@ module Snapshot class Runner TRACE_DIR = '/tmp/snapshot_traces' - def work(clean: true, build: true) + def work(clean: true, build: true, take_snapshots: true) SnapshotConfig.shared_instance.js_file # to verify the file can be found earlier Builder.new.build_app(clean: clean) if build @app_path = determine_app_path counter = 0 errors = [] - FileUtils.rm_rf SnapshotConfig.shared_instance.screenshots_path if SnapshotConfig.shared_instance.clear_previous_screenshots + FileUtils.rm_rf SnapshotConfig.shared_instance.screenshots_path if (SnapshotConfig.shared_instance.clear_previous_screenshots and take_snapshots) SnapshotConfig.shared_instance.devices.each do |device| SnapshotConfig.shared_instance.languages.each do |language_item| if language_item.instance_of?String @@ -30,21 +30,23 @@ prepare_simulator(device, language) begin errors.concat(run_tests(device, language, locale)) - counter += copy_screenshots(language) + counter += copy_screenshots(language) if take_snapshots rescue => ex Helper.log.error(ex) end teardown_simulator(device, language) end end `killall "iOS Simulator"` # close the simulator after the script is finished + return unless take_snapshots + ReportsGenerator.new.generate if errors.count > 0 Helper.log.error "-----------------------------------------------------------" Helper.log.error errors.join(' - ').red @@ -130,10 +132,14 @@ case result when :retry retry_run = true when :screenshot Helper.log.info "Successfully took screenshot 📱" + when :pass + Helper.log.info line.strip.gsub("Pass:", "✓").green + when :fail + Helper.log.info line.strip.gsub("Fail:", "✗").red when :need_permission raise "Looks like you may need to grant permission for Instruments to analyze other processes.\nPlease Ctrc + C and run this command: \"#{command}\"" end rescue Exception => ex Helper.log.error lines.join('') @@ -180,9 +186,13 @@ return :retry elsif line.include?"Screenshot captured" return :screenshot elsif line.include? "Instruments wants permission to analyze other processes" return :need_permission + elsif line.include? "Pass: " + return :pass + elsif line.include? "Fail: " + return :fail elsif line =~ /.*Error: (.*)/ raise "UIAutomation Error: #{$1}" elsif line =~ /Instruments Usage Error :(.*)/ raise "Instruments Usage Error: #{$1}" elsif line.include?"__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object"