Skip to content

Conversation

@rogerluan
Copy link
Collaborator

Resolves #421

This PR simply trims whitespaces around the file read.

I was misled by these docs https://github.com/fastlane/ci/blob/master/docs/xcode-version.md#file-content that xcode-install would strip whitespaces, but it actually doesn't (yet), and caused that very misleading behavior (which also happens to be extremely hard to debug or notice because visually - on Terminal - it never prints the trailing whitespaces 😬 ).

I tried adding a unit test to cover this case, but honestly I couldn't make it work. This is what I ended up with, in spec/install_spec.rb:

it 'reads .xcode-version and trim whitespaces if needed' do
  Installer.any_instance.expects(:download).with('6.3', true, nil, nil, 3).returns('/some/path')
  Installer.any_instance.expects(:install_dmg).with('/some/path', '-6.3', true, true)
  File.expects(:exist?).with('.xcode-version').returns(true)
  File.expects(:read).with('.xcode-version').returns('6.3\n')
  Command::Install.run([])
end

@rogerluan
Copy link
Collaborator Author

The CI failure seems to be unrelated (and present in master as well) 🤔

Copy link
Member

@KrauseFx KrauseFx left a comment

Choose a reason for hiding this comment

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

Thank you!

@KrauseFx KrauseFx merged commit a956fc1 into xcpretty:master Mar 25, 2021
@rogerluan rogerluan deleted the strip-xcode-version branch April 21, 2021 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

xcversion install without explicit version (using .xcode-version) fails

2 participants