lib/snapshot/runner.rb in snapshot-1.8.0 vs lib/snapshot/runner.rb in snapshot-1.9.0
- old
+ new
@@ -33,13 +33,18 @@
results = {} # collect all the results for a nice table
launch_arguments_set = config_launch_arguments
Snapshot.config[:devices].each do |device|
launch_arguments_set.each do |launch_arguments|
Snapshot.config[:languages].each do |language|
+ locale = nil
+ if language.kind_of?(Array)
+ locale = language[1]
+ language = language[0]
+ end
results[device] ||= {}
- results[device][language] = run_for_device_and_language(language, device, launch_arguments)
+ results[device][language] = run_for_device_and_language(language, locale, device, launch_arguments)
end
end
end
print_results(results)
@@ -53,18 +58,18 @@
FileUtils.rm_rf(TestCommandGenerator.derived_data_path)
end
# 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, device, launch_arguments, retries = 0)
- return launch(language, device, launch_arguments)
+ def run_for_device_and_language(language, locale, device, launch_arguments, retries = 0)
+ return launch(language, locale, device, launch_arguments)
rescue => ex
UI.error ex.to_s # show the reason for failure to the user, but still maybe retry
if retries < Snapshot.config[:number_of_retries]
UI.important "Tests failed, re-trying #{retries + 1} out of #{Snapshot.config[:number_of_retries] + 1} times"
- run_for_device_and_language(language, device, launch_arguments, retries + 1)
+ run_for_device_and_language(language, locale, device, launch_arguments, retries + 1)
else
UI.error "Backtrace:\n\t#{ex.backtrace.join("\n\t")}" if $verbose
self.collected_errors << ex
raise ex if Snapshot.config[:stop_after_first_error]
return false # for the results
@@ -102,20 +107,22 @@
puts Terminal::Table.new(params)
puts ""
end
# Returns true if it succeded
- def launch(language, device_type, launch_arguments)
+ def launch(language, locale, device_type, launch_arguments)
screenshots_path = TestCommandGenerator.derived_data_path
FileUtils.rm_rf(File.join(screenshots_path, "Logs"))
FileUtils.rm_rf(screenshots_path) if Snapshot.config[:clean]
FileUtils.mkdir_p(screenshots_path)
File.write("/tmp/language.txt", language)
+ File.write("/tmp/locale.txt", locale || "")
File.write("/tmp/snapshot-launch_arguments.txt", launch_arguments.last)
Fixes::SimulatorZoomFix.patch
+ Fixes::HardwareKeyboardFix.patch
Snapshot.kill_simulator # because of https://github.com/fastlane/snapshot/issues/337
`xcrun simctl shutdown booted &> /dev/null`
if Snapshot.config[:erase_simulator]
@@ -128,11 +135,15 @@
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}")
+ if locale
+ UI.header("#{device_type} - #{language} (#{locale})")
+ else
+ UI.header("#{device_type} - #{language}")
+ end
prefix_hash = [
{
prefix: "Running Tests: ",
block: proc do |value|
@@ -152,11 +163,11 @@
# no exception raised... that means we need to retry
UI.error "Caught error... #{return_code}"
self.number_of_retries_due_to_failing_simulator += 1
if self.number_of_retries_due_to_failing_simulator < 20
- launch(language, device_type, launch_arguments)
+ launch(language, locale, device_type, launch_arguments)
else
# It's important to raise an error, as we don't want to collect the screenshots
UI.crash!("Too many errors... no more retries...")
end
end)
@@ -213,10 +224,10 @@
def verify_helper_is_current
helper_files = Update.find_helper
helper_files.each do |path|
content = File.read(path)
- if content.include?("start.pressForDuration(0, thenDragToCoordinate: finish)")
+ unless content.include?("SnapshotHelperVersion [1.1]")
UI.error "Your '#{path}' is outdated, please run `snapshot update`"
UI.error "to update your Helper file"
UI.user_error!("Please update your Snapshot Helper file")
end
end