-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve how App and Ipa instances detect the Calabash server version #379
Improve how App and Ipa instances detect the Calabash server version #379
Conversation
Add the fat dylib for testing
The #valid? method calls this new class method. I want to move the valid check into the initializer to: * fail fast * remove the need to call #valid? in instance methods
App is valid because the check in initializer
1.9 seconds => 0.09 seconds
Don't bother with all the validation in individual methods; just create an .app instance from the Payload/App.app bundle
@@ -14,6 +14,20 @@ class App | |||
# @return [RunLoop::App] A instance of App with a path. | |||
def initialize(app_bundle_path) | |||
@path = File.expand_path(app_bundle_path) | |||
|
|||
if !App.valid?(app_bundle_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Immediately raise an error if the app bundle is invalid. This avoids having to check in each instance method.
No hurry on this @sapieneptus. It does not have to be part of the next release. |
def payload_dir | ||
@payload_dir ||= lambda { | ||
@payload_dir ||= lambda do | ||
FileUtils.cp(path, tmpdir) | ||
zip_path = File.join(tmpdir, File.basename(path)) | ||
Dir.chdir(tmpdir) do | ||
system('unzip', *['-q', zip_path]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we were supposed to use ditto
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this operation we are copying a zip file (.ipa) to a temp location.
It is safe, I think, to copy with cp. Who knows, maybe FileUtils.cp is implemented with ditto on MacOS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To clarify, we should use ditto when copying .app (app bundles) directories. I don't think we need to use ditto when copying archive files because the resource forks are included in the archive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was talking about the unzip
, not the cp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E.g., for resigning we do:
// NOTE: To correctly preserve MACOS metadata we must use ditto instead of zip.
// Failing to do so can make codesign bail out with some very exotic
// error messages in some rare cases.
ShellOrDie("ditto", "-x", "-k", "--sequesterRsrc", filepath, tmpDir)
Perhaps it's not relevant here, but I thought it was just generally safer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(>_O) Of course you were.
I will fix this.
plist?(file) || | ||
lproj_asset?(file) || | ||
code_signing_asset?(file) || | ||
core_data_asset?(file) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jmoody Why not use a whitelist approach instead? Files that need to be checked for calabash linkage should be just the main app binary and any dylibs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whitelist
I thought about pretty seriously. I am tempted to use a whitelist.
I was thinking about extensions and a future where we would automate those as well - but the same whitelist rules would apply.
I think I will change the approach now to use whitelist.
@jmoody The comments I have made are non-blocking. I don't think I don't have enough context to say whether or not this will aversely impact the rest of RunLoop, but I don't see anything obviously wrong with the PR and the tests are passing. So with that in mind, I would say it's good to go. |
I thought more about using a whitelist and had a brief conversation with Simon. I don't think we actually can make a whitelist that would cover all cases. |
Grr. Travis is failing because it can't install ruby 2.1.7. Merging. Will deal with this failure if it occurs on develop. |
…version-take-2 Improve how App and Ipa instances detect the Calabash server version
@jmoody Sorry to keep going back and forth on this, but I thought we agreed that whitelisting by |
No worries. Makes the code better. +1
I thought you were arguing for a whitelist with these rules:
I looked at
This is the behavior. A list of executables is created and strings is call on the elements of that list to detect the Calabash iOS server version. |
Motivation
The previous implementation (thanks @ark-konopacki) had a couple of problems:
This PR is a bit long and I am sorry for that. I will annotate the changes with notes to help the reviewer.
Related to (private links):