Skip to content

Conversation

@jazaval
Copy link
Contributor

@jazaval jazaval commented Dec 9, 2017

This PR fixes an issue with iOS simulator installation in 10.11 and 10.13, where the xcode-install gem does not populate the simulator list immediately after wrapping up an Xcode install.

The method called by the install_simulators action will refresh the gem's simulator list output until at least one simulator is scraped from Apple.

@jazaval jazaval added the bug label Dec 9, 2017
@jazaval jazaval self-assigned this Dec 9, 2017
Copy link
Contributor

@ehanlon ehanlon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works! Thanks for the fix!

if highest.nil?
Chef::Application.fatal!("iOS #{major_version} Simulator no longer available from Apple!")
if available_list.empty?
Chef::Log.error('iOS simulator list not populated yet, refreshing...')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels more like a #warning as opposed to an #error, but I'm not totally familiar with implementing the Chef::Log class. What's the difference/reasoning behind error over warning?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or even just an info message. Interesting case though: What happens if the list never populates?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried using info and warn levels - but Kitchen wouldn't print them even when I set the log level envionment var. There was a kitchen PR to address this: test-kitchen/test-kitchen#950, but it still doesn't work for me on latest.

Copy link
Contributor

@ehanlon ehanlon Dec 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO I don't really need to see it in the output. I could always set the log level in the Kitchen output with -l.

Copy link

@brownmike brownmike left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is a hotfix so I won't block the merge on my comments. But I'd like to pair on this a bit this week when we get a chance.

if highest.nil?
Chef::Application.fatal!("iOS #{major_version} Simulator no longer available from Apple!")
if available_list.empty?
Chef::Log.error('iOS simulator list not populated yet, refreshing...')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or even just an info message. Interesting case though: What happens if the list never populates?

Chef::Application.fatal!("iOS #{major_version} Simulator no longer available from Apple!")
if available_list.empty?
Chef::Log.error('iOS simulator list not populated yet, refreshing...')
shell_out('sleep 20')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

highest = available_list.select { |name, vers| requirement.match?(name, vers) }.max
if highest.nil?
Chef::Application.fatal!("iOS #{major_version} Simulator no longer available from Apple!")
if available_list.empty?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method has accumulated quite a few responsibilities:

  • Creating a dependency object
  • Checking the state of some (global?) list to see if it's populated yet and sleeping (retrying somehow?) if it isn't
  • Creating a highest object by selecting the highest available simulator from the aformentioned list
  • nil checking on the previous result so we can fail in a loud and obvious way
  • and finally joining the highest object with spaces

I think we have a tortured object in here trying to get out.

Copy link
Collaborator

@americanhanko americanhanko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's quite a bit more work to be done here and thinking about how to implement the native xcode-install gem, but this is a great working refactor for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants