lib/screengrab/runner.rb in screengrab-0.3.1 vs lib/screengrab/runner.rb in screengrab-0.3.2

- old
+ new

@@ -124,11 +124,11 @@ end end end def screenshot_file_names_in(output_directory, device_type) - Dir.glob(File.join('.', output_directory, '**', device_type, '*.png'), File::FNM_CASEFOLD) + Dir.glob(File.join(output_directory, '**', device_type, '*.png'), File::FNM_CASEFOLD) end def determine_external_screenshots_path(device_serial) device_ext_storage = @executor.execute(command: "adb -s #{device_serial} shell echo \\$EXTERNAL_STORAGE", print_all: true, @@ -226,10 +226,12 @@ def pull_screenshots_from_device(device_serial, device_screenshots_paths, device_type_dir_name) UI.message "Pulling captured screenshots from the device" starting_screenshot_count = screenshot_file_names_in(@config[:output_directory], device_type_dir_name).length + UI.verbose("Starting screenshot count is: #{starting_screenshot_count}") + device_screenshots_paths.each do |device_path| if_device_path_exists(device_serial, device_path) do |path| @executor.execute(command: "adb -s #{device_serial} pull #{path} #{@config[:output_directory]}", print_all: false, print_command: true) @@ -243,10 +245,12 @@ # user provided device_type option value to match the directory structure that supply expects move_pulled_screenshots(device_type_dir_name) ending_screenshot_count = screenshot_file_names_in(@config[:output_directory], device_type_dir_name).length + UI.verbose("Ending screenshot count is: #{ending_screenshot_count}") + # Because we can't guarantee the screenshot output directory will be empty when we pull, we determine # success based on whether there are more screenshots there than when we started. if starting_screenshot_count == ending_screenshot_count UI.error "Make sure you've used Screengrab.screenshot() in your tests and that your expected tests are being run." UI.user_error! "No screenshots were detected 📷❌" @@ -256,10 +260,10 @@ end def move_pulled_screenshots(device_type_dir_name) # Glob pattern that finds the pulled screenshots directory for each locale # (Matches: fastlane/metadata/android/en-US/images/screenshots) - screenshots_dir_pattern = File.join('.', @config[:output_directory], '**', "screenshots") + screenshots_dir_pattern = File.join(@config[:output_directory], '**', "screenshots") Dir.glob(screenshots_dir_pattern, File::FNM_CASEFOLD).each do |screenshots_dir| src_screenshots = Dir.glob(File.join(screenshots_dir, '*.png'), File::FNM_CASEFOLD) # We move the screenshots by replacing the last segment of the screenshots directory path with