lib/snapshot/runner.rb in snapshot-0.9.3 vs lib/snapshot/runner.rb in snapshot-0.10.0

- old
+ new

@@ -49,11 +49,11 @@ end break if errors.any? && ENV["SNAPSHOT_BREAK_ON_FIRST_ERROR"] end - `killall "iOS Simulator"` # close the simulator after the script is finished + kill_simulator # close the simulator after the script is finished return unless take_snapshots ReportsGenerator.new.generate @@ -98,24 +98,28 @@ app_identifier = ENV["SNAPSHOT_APP_IDENTIFIER"] app_identifier ||= @app_identifier def com(cmd) puts cmd.magenta if $verbose - Open3.popen3("#{cmd} 2>&1") do |stdin, stdout, stderr, wait_thr| - result = stdout.read - puts result if (result.to_s.length > 0 and $verbose) + + IO.popen("#{cmd} 2>&1", err: [:child, :out]) do |io| + io.each do |line| + puts line if (line.to_s.length > 0 and $verbose) + end + io.close end end udid = udid_for_simulator(device) - com("killall 'iOS Simulator'") + kill_simulator sleep 3 com("xcrun simctl boot '#{udid}'") - com("xcrun simctl uninstall booted '#{app_identifier}'") + + com("xcrun simctl uninstall '#{udid}' '#{app_identifier}'") unless Snapshot.min_xcode7? sleep 3 - com("xcrun simctl install booted '#{@app_path.shellescape}'") + com("xcrun simctl install '#{udid}' #{@app_path.shellescape}") unless Snapshot.min_xcode7? com("xcrun simctl shutdown booted") end def run_tests(device, language, locale) Helper.log.info "Running tests on #{device} in language #{language} (locale #{locale})".green @@ -217,9 +221,14 @@ elsif line =~ /Instruments Usage Error :(.*)/ raise "Instruments Usage Error: #{$1}" elsif line.include?"__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object" raise "Looks like something is wrong with the used app. Make sure the build was successful." end + end + + def kill_simulator + `killall "iOS Simulator"` + `killall "Simulator"` end def copy_screenshots(language) resulting_path = File.join(SnapshotConfig.shared_instance.screenshots_path, language)