-
Notifications
You must be signed in to change notification settings - Fork 0
Reuse an already-booted iOS simulator instead of hanging #45
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -347,36 +347,27 @@ var IOSEmulatorManager = (function () { | |
| /** | ||
| * Returns the target emulator, which is specified through the command line. | ||
| */ | ||
| IOSEmulatorManager.prototype.getTargetEmulator = function () { | ||
| let _this = this; | ||
| if (this.targetEmulator) | ||
| return Q(this.targetEmulator); | ||
| else { | ||
| let deferred = Q.defer(); | ||
| let targetIOSEmulator = process.env.IOS_EMU; | ||
| if (!targetIOSEmulator) { | ||
| // If no iOS simulator is specified, get the most recent iOS simulator to run tests on. | ||
| testUtil_1.TestUtil.getProcessOutput("xcrun simctl list", { noLogCommand: true, noLogStdOut: true, noLogStdErr: true }) | ||
| .then((listOfDevicesWithDevicePairs) => { | ||
| let listOfDevices = listOfDevicesWithDevicePairs.slice(listOfDevicesWithDevicePairs.indexOf("-- iOS"), listOfDevicesWithDevicePairs.indexOf("-- tvOS")); | ||
| let phoneDevice = /iPhone\ \S*\ ?.*?\(([0-9A-Z-]*)\)/g; | ||
| let match = phoneDevice.exec(listOfDevices); | ||
| deferred.resolve(match[1]); | ||
| }, (error) => { | ||
| deferred.reject(error); | ||
| }); | ||
| } | ||
| else { | ||
| // Use the simulator specified on the command line. | ||
| deferred.resolve(targetIOSEmulator); | ||
| IOSEmulatorManager.prototype.getTargetEmulator = async function () { | ||
| if (this.targetEmulator) { | ||
| return this.targetEmulator; | ||
| } | ||
| let targetEmulator = process.env.IOS_EMU; | ||
| if (!targetEmulator) { | ||
| try { | ||
| const bootedUdid = await testUtil_1.TestUtil.getProcessOutput("xcrun simctl getenv booted SIMULATOR_UDID", { noLogCommand: true, noLogStdOut: true, noLogStdErr: true }); | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I would say this is an expected (although implicit) behavior, not a big deal.
Technically correct, but not a big deal IMHO in this project's context. |
||
| targetEmulator = bootedUdid.trim(); | ||
| } catch { | ||
| // No simulator is currently booted - fall back to the most recent iOS simulator. | ||
| const listOfDevicesWithDevicePairs = await testUtil_1.TestUtil.getProcessOutput("xcrun simctl list", { noLogCommand: true, noLogStdOut: true, noLogStdErr: true }); | ||
| const listOfDevices = listOfDevicesWithDevicePairs.slice(listOfDevicesWithDevicePairs.indexOf("-- iOS"), listOfDevicesWithDevicePairs.indexOf("-- tvOS")); | ||
| const phoneDevice = /iPhone\ \S*\ ?.*?\(([0-9A-Z-]*)\)/g; | ||
| const match = phoneDevice.exec(listOfDevices); | ||
| targetEmulator = match[1]; | ||
| } | ||
| return deferred.promise | ||
| .then((targetEmulator) => { | ||
| _this.targetEmulator = targetEmulator; | ||
| console.log("Using iOS simulator named " + _this.targetEmulator); | ||
| return _this.targetEmulator; | ||
| }); | ||
| } | ||
| this.targetEmulator = targetEmulator; | ||
| console.log("Using iOS simulator named " + this.targetEmulator); | ||
| return this.targetEmulator; | ||
| }; | ||
| /** | ||
| * Boots the target emulator. | ||
|
|
||
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.
Note how we are converting this old code to modern
async/awaitsyntax. That's why the diff is more than a few lines.