-
-
Notifications
You must be signed in to change notification settings - Fork 30
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
refactor: simplify createDevice logic #89
Conversation
if (isNewerIdFormatRequired) { | ||
runtimeId = `${SIM_RUNTIME_NAME}${platform}-${runtimeId.replace(/\./g, '-')}`; | ||
let potentialRuntimeIds = [`${runtimeIdSemver.major}.${runtimeIdSemver.minor}`]; | ||
if (runtimeId.split('.').length === 3) { |
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.
if (runtimeIdSemver.patch) ...
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'm not sure that there is no situation where a 0
patch version is not valid, and it would be excluded here.
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'm fine with the current implementation as well
lib/simctl.js
Outdated
break; | ||
} catch (err) { | ||
const reason = err.stderr ? err.stderr.trim() : err.message; | ||
log.warn(`Unable to create simulator: ${reason}`); |
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.
Do we need to print these warnings? we anyway know some of these ids won't work
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.
Perhaps it only makes sense to print them if the whole sim creation op fails
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 think it would be confusing if it were not there, as there would be multiple lines saying it was creating a simulator, with no indication of why.
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.
Played around a bit and the error gets logged elsewhere, so the confusion I envisioned is not there.
lib/simctl.js
Outdated
if (runtimeId.split('.').length === 3) { | ||
potentialRuntimeIds.push(runtimeId); | ||
} | ||
for (const id of potentialRuntimeIds) { |
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.
runtimeIds.push(
...(potentialRuntimeIds.map((id) => `${SIM_RUNTIME_NAME}${platform}-${id.replace(/\./g, '-')}`)),
...potentialRuntimeIds
)
lib/simctl.js
Outdated
} | ||
} | ||
} | ||
const done = _.values(await getDevices()) |
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.
👍
lib/simctl.js
Outdated
.filter((device) => device.udid === udid) | ||
.every((device) => device.state !== 'Creating'); | ||
if (!done) { | ||
throw new Error('Device still being created'); |
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.
should we also print the device name?
It looks like tests need some love |
What is this referring to? |
https://github.com/appium/node-simctl/pull/89/files#diff-a020ec8175f353e84bb9b28d0a2b31c0R428 |
Make sure that we can create simulators when the platform version and runtimes are different (which is mostly to say, when there is a patch version of a sim)
So, if
xcrun simctl list runtimes
returns:And someone wants iOS 13.2 it will currently fail because the runtime will be
com.apple.CoreSimulator.SimRuntime.iOS-13-2-2
rather than the correctcom.apple.CoreSimulator.SimRuntime.iOS-13-2
. In this PR it just tries out the various combinations, in order to find the correct one.In the case of Xcode
11.2.1
, requesting iOS 13.2, will produce array of possible runtime ids: