Skip to content

Commit

Permalink
[scan] fix misleading error message when no devices are found (#21650)
Browse files Browse the repository at this point in the history
  • Loading branch information
MagnificentMiles committed Nov 27, 2023
1 parent 2860bac commit d334e2f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions scan/lib/scan/detect_values.rb
Expand Up @@ -146,6 +146,8 @@ def self.detect_simulator(devices, requested_os_type, deployment_target_key, def

selector = ->(sim) { pieces.count > 0 && sim.name == pieces.first }

display_device = "'#{device_string}'"

set + (
if pieces.count == 0
[] # empty array
Expand All @@ -157,6 +159,8 @@ def self.detect_simulator(devices, requested_os_type, deployment_target_key, def
.pop(1)
else # pieces.count == 2 -- mathematically, because of the 'end of line' part of our regular expression
version = pieces[1].tr('()', '')
display_device = "'#{pieces[0]}' with version #{version}"

potential_emptiness_error = lambda do |sims|
if sims.empty?
UI.error("No simulators found that are equal to the version " \
Expand All @@ -168,8 +172,8 @@ def self.detect_simulator(devices, requested_os_type, deployment_target_key, def
end
).tap do |array|
if array.empty?
UI.test_failure!("No device found with name '#{device_string}'") if Scan.config[:ensure_devices_found]
UI.error("Ignoring '#{device_string}', couldnt find matching simulator")
UI.test_failure!("No device found with name #{display_device}") if Scan.config[:ensure_devices_found]
UI.error("Ignoring '#{device_string}', couldn't find matching simulator")
end
end
end
Expand Down

0 comments on commit d334e2f

Please sign in to comment.