Skip to content
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: device selection revisited #1694

Merged
merged 1 commit into from
Oct 10, 2019
Merged

Conversation

noomorph
Copy link
Collaborator

@noomorph noomorph commented Oct 8, 2019

This pull request prepares the ground to finally deal with #853 and also should potentially resolve #1565.

The consequent PR will add device property to a configuration, which can be configured in a more powerful way.

Changes:

  1. AppleSimUtils: make it thinner and more explicit, therefore the search method is called now list (similar to the CLI). The query handler logic (iPhone X, iOS 12.0) is moved 1 layer upwards, to SimulatorDriver.

  2. SimulatorDriver: logic of search remains intact - device type (+ device os, if specified via comma).

  3. AppleSimUtils: remove the dependency on a heavy and non-maintainable direct call xcrun simctl list -j, by allowing new AppleSimUtils().create(device) to accept a "prototype" for a device you want to create. I pick it from the result the list() method returns as-is, and pass it to create().

  4. SimulatorDriver: remove redundant calls to applesimutils, querying the same things twice when creating a device. Important: now, when creating a device, it takes an OS version of the first matching but a busy device.

  5. AndroidDriver: remove redundant Telnet queries to busy devices. That can happen, because getting a name now done explicitly, via queryName() method, so we can postpone it till the very last moment.

  6. ADB: recompose an async-iterator-like ADB output parser to lazy DeviceHandle classes, to allow bullet (5) to happen.

  7. DeviceRegistry: refactor to accommodate changes to SimulatorDriver and AndroidDriver. API was simplified to just allocateDevice and disposeDevice. This way, we remove 2-way connecting between *Driver -> DeviceRegistry -> injected methods of *Driver, therefore we have better maintainability.

TODO(@noomorph): conduct some more manual QA.

@noomorph noomorph force-pushed the fix/ios/device-selection branch 3 times, most recently from eedadb7 to 1a99650 Compare October 8, 2019 16:03
@LeoNatan
Copy link
Contributor

LeoNatan commented Oct 8, 2019

If it is a complex query like iPhone X, iOS 12.0 (contains comma-separated values), it immediately searches by device type and OS.

I don't think this is correct. There can be simulators of the same name for different OS versions. We need to be able to specify a more complex query, rather than just a string with commas.

@LeoNatan
Copy link
Contributor

LeoNatan commented Oct 8, 2019

We discussed in the past the ability to provide an object as device selector.

{
  name: "iPhone X",
  os: "iOS 13.0"
}

vs

{
  type: "iPhone X",
  os: "iOS 13.0"
}

@LeoNatan LeoNatan changed the title [DRAFT]: Device selection revisited Device selection revisited Oct 8, 2019
return udid;
}

async _groupDevicesByStatus(query) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Query should be an object rather than string. If we are making such important changes, let's do it fully. Otherwise, there is ambiguity that cannot be resolved with this query. Devices with the same name are allowed to exist, If I have two devices named "MySim", one for iOS 13 and one for iOS 12, the current proposed solution will fail for a "MySim, iOS 13.0" query.

Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps we can have a fallback like this for legacy strings, but we should add the full solution. I don't think it's a hard solution, as the object can travel, just like the string, from the package.json to here.

Copy link
Collaborator Author

@noomorph noomorph Oct 9, 2019

Choose a reason for hiding this comment

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

I decided to split the refactor and the change to the feature, on Friday it will appear in a consequent pull request. Have to switch to the "performance project". Currently, with this PR the device selection logic will remain the same for iOS simulators, except for removed xcrun simctl list -j.

@noomorph noomorph changed the title Device selection revisited refactor: device selection revisited Oct 9, 2019
@noomorph noomorph marked this pull request as ready for review October 9, 2019 17:30
fix(ios): create a new device using a busy one as a prototype
perf(devices): optimize search and create operations for simulators and emulators
refactor(devices): a simpler concept of DeviceRegistry
@noomorph noomorph merged commit aa25025 into master Oct 10, 2019
@noomorph noomorph deleted the fix/ios/device-selection branch October 10, 2019 07:56
@lock lock bot locked as resolved and limited conversation to collaborators Oct 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TypeError: Cannot read property 'identifier' of undefined
2 participants