Skip to content

Commit

Permalink
feat: allow selection of iOS sim with --udid (#1068)
Browse files Browse the repository at this point in the history
* feat: Allow selection of iOS sim with `--udid`

* fix: Keep Mac as Catalyst destination

* support lowercase UUIDs

Co-authored-by: Michał Pierzchała <thymikee@gmail.com>
  • Loading branch information
alloy and thymikee authored Mar 30, 2020
1 parent 4c8af54 commit 2d575b0
Show file tree
Hide file tree
Showing 6 changed files with 236 additions and 147 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('findMatchingSimulator', () => {
findMatchingSimulator(
{
devices: {
'iOS 9.2': [
'com.apple.CoreSimulator.SimRuntime.iOS-9-2': [
{
state: 'Shutdown',
availability: '(available)',
Expand Down Expand Up @@ -51,7 +51,7 @@ describe('findMatchingSimulator', () => {
],
},
},
'iPhone 6',
{simulator: 'iPhone 6'},
),
).toEqual({
udid: 'BA0D93BD-07E6-4182-9B0A-F60A2474139C',
Expand All @@ -66,7 +66,7 @@ describe('findMatchingSimulator', () => {
findMatchingSimulator(
{
devices: {
'iOS 12.1': [
'com.apple.CoreSimulator.SimRuntime.iOS-12-1': [
{
state: 'Shutdown',
isAvailable: true,
Expand Down Expand Up @@ -103,7 +103,7 @@ describe('findMatchingSimulator', () => {
],
},
},
'iPhone 6',
{simulator: 'iPhone 6'},
),
).toEqual({
udid: 'BA0D93BD-07E6-4182-9B0A-F60A2474139C',
Expand All @@ -118,7 +118,7 @@ describe('findMatchingSimulator', () => {
findMatchingSimulator(
{
devices: {
'iOS 9.2': [
'com.apple.CoreSimulator.SimRuntime.iOS-9-2': [
{
state: 'Shutdown',
availability: '(unavailable, runtime profile not found)',
Expand Down Expand Up @@ -152,7 +152,7 @@ describe('findMatchingSimulator', () => {
],
},
},
'iPhone 6',
{simulator: 'iPhone 6'},
),
).toEqual(null);
});
Expand All @@ -162,7 +162,7 @@ describe('findMatchingSimulator', () => {
findMatchingSimulator(
{
devices: {
'iOS 9.2': [
'com.apple.CoreSimulator.SimRuntime.iOS-9-2': [
{
state: 'Shutdown',
availability: '(unavailable, runtime profile not found)',
Expand Down Expand Up @@ -211,7 +211,7 @@ describe('findMatchingSimulator', () => {
findMatchingSimulator(
{
devices: {
'iOS 9.2': [
'com.apple.CoreSimulator.SimRuntime.iOS-9-2': [
{
state: 'Shutdown',
availability: '(unavailable, runtime profile not found)',
Expand Down Expand Up @@ -243,7 +243,7 @@ describe('findMatchingSimulator', () => {
udid: 'D0F29BE7-CC3C-4976-888D-C739B4F50508',
},
],
'iOS 10.0': [
'com.apple.CoreSimulator.SimRuntime.iOS-10-0': [
{
state: 'Shutdown',
availability: '(available)',
Expand Down Expand Up @@ -286,7 +286,7 @@ describe('findMatchingSimulator', () => {
findMatchingSimulator(
{
devices: {
'iOS 9.2': [
'com.apple.CoreSimulator.SimRuntime.iOS-9-2': [
{
state: 'Shutdown',
availability: '(unavailable, runtime profile not found)',
Expand Down Expand Up @@ -335,7 +335,7 @@ describe('findMatchingSimulator', () => {
findMatchingSimulator(
{
devices: {
'iOS 9.2': [
'com.apple.CoreSimulator.SimRuntime.iOS-9-2': [
{
state: 'Shutdown',
availability: '(unavailable, runtime profile not found)',
Expand Down Expand Up @@ -369,7 +369,7 @@ describe('findMatchingSimulator', () => {
],
},
},
'iPhone 6',
{simulator: 'iPhone 6'},
),
).toEqual({
udid: 'BA0D93BD-07E6-4182-9B0A-F60A2474139C',
Expand All @@ -384,7 +384,7 @@ describe('findMatchingSimulator', () => {
findMatchingSimulator(
{
devices: {
'iOS 9.2': [
'com.apple.CoreSimulator.SimRuntime.iOS-9-2': [
{
state: 'Shutdown',
availability: '(unavailable, runtime profile not found)',
Expand Down Expand Up @@ -416,7 +416,7 @@ describe('findMatchingSimulator', () => {
udid: 'D0F29BE7-CC3C-4976-888D-C739B4F50508',
},
],
'iOS 10.0': [
'com.apple.CoreSimulator.SimRuntime.iOS-10-0': [
{
state: 'Shutdown',
availability: '(available)',
Expand Down Expand Up @@ -459,7 +459,7 @@ describe('findMatchingSimulator', () => {
findMatchingSimulator(
{
devices: {
'iOS 9.2': [
'com.apple.CoreSimulator.SimRuntime.iOS-9-2': [
{
state: 'Shutdown',
availability: '(unavailable, runtime profile not found)',
Expand Down Expand Up @@ -491,7 +491,7 @@ describe('findMatchingSimulator', () => {
udid: 'D0F29BE7-CC3C-4976-888D-C739B4F50508',
},
],
'iOS 10.0': [
'com.apple.CoreSimulator.SimRuntime.iOS-10-0': [
{
state: 'Shutdown',
availability: '(available)',
Expand Down Expand Up @@ -519,7 +519,7 @@ describe('findMatchingSimulator', () => {
],
},
},
'iPhone 6s',
{simulator: 'iPhone 6s'},
),
).toEqual({
udid: 'D0F29BE7-CC3C-4976-888D-C739B4F50508',
Expand All @@ -534,7 +534,7 @@ describe('findMatchingSimulator', () => {
findMatchingSimulator(
{
devices: {
'iOS 9.2': [
'com.apple.CoreSimulator.SimRuntime.iOS-9-2': [
{
state: 'Shutdown',
availability: '(unavailable, runtime profile not found)',
Expand Down Expand Up @@ -566,7 +566,7 @@ describe('findMatchingSimulator', () => {
udid: 'D0F29BE7-CC3C-4976-888D-C739B4F50508',
},
],
'iOS 10.0': [
'com.apple.CoreSimulator.SimRuntime.iOS-10-0': [
{
state: 'Shutdown',
availability: '(available)',
Expand Down Expand Up @@ -594,7 +594,7 @@ describe('findMatchingSimulator', () => {
],
},
},
'iPhone 6s (10.0)',
{simulator: 'iPhone 6s (10.0)'},
),
).toEqual({
udid: 'CBBB8FB8-77AB-49A9-8297-4CCFE3189C22',
Expand All @@ -609,7 +609,7 @@ describe('findMatchingSimulator', () => {
findMatchingSimulator(
{
devices: {
'iOS 9.2': [
'com.apple.CoreSimulator.SimRuntime.iOS-9-2': [
{
state: 'Shutdown',
availability: '(unavailable, runtime profile not found)',
Expand Down Expand Up @@ -641,7 +641,7 @@ describe('findMatchingSimulator', () => {
udid: 'D0F29BE7-CC3C-4976-888D-C739B4F50508',
},
],
'iOS 10.0': [
'com.apple.CoreSimulator.SimRuntime.iOS-10-0': [
{
state: 'Shutdown',
availability: '(available)',
Expand All @@ -663,7 +663,7 @@ describe('findMatchingSimulator', () => {
],
},
},
'iPhone 6s (10.0)',
{simulator: 'iPhone 6s (10.0)'},
),
).toEqual(null);
});
Expand All @@ -673,7 +673,7 @@ describe('findMatchingSimulator', () => {
findMatchingSimulator(
{
devices: {
'iOS 12.0': [
'com.apple.CoreSimulator.SimRuntime.iOS-12-0': [
{
state: 'Shutdown',
availability: '(unavailable, runtime profile not found)',
Expand Down Expand Up @@ -711,7 +711,7 @@ describe('findMatchingSimulator', () => {
udid: 'B2141C1E-86B7-4A10-82A7-4956799526DF',
},
],
'iOS 12.2': [
'com.apple.CoreSimulator.SimRuntime.iOS-12-2': [
{
state: 'Shutdown',
availability: '(available)',
Expand All @@ -733,7 +733,7 @@ describe('findMatchingSimulator', () => {
],
},
},
'iPad Pro (9.7-inch)',
{simulator: 'iPad Pro (9.7-inch)'},
),
).toEqual({
udid: 'B2141C1E-86B7-4A10-82A7-4956799526DF',
Expand All @@ -748,7 +748,7 @@ describe('findMatchingSimulator', () => {
findMatchingSimulator(
{
devices: {
'iOS 12.0': [
'com.apple.CoreSimulator.SimRuntime.iOS-12-0': [
{
state: 'Shutdown',
availability: '(unavailable, runtime profile not found)',
Expand Down Expand Up @@ -780,7 +780,7 @@ describe('findMatchingSimulator', () => {
udid: 'D0F29BE7-CC3C-4976-888D-C739B4F50508',
},
],
'iOS 12.2': [
'com.apple.CoreSimulator.SimRuntime.iOS-12-2': [
{
state: 'Shutdown',
availability: '(available)',
Expand Down Expand Up @@ -808,7 +808,7 @@ describe('findMatchingSimulator', () => {
],
},
},
'iPad Pro (9.7-inch) (12.2)',
{simulator: 'iPad Pro (9.7-inch) (12.2)'},
),
).toEqual({
udid: 'B2141C1E-86B7-4A10-82A7-4956799526DF',
Expand All @@ -823,7 +823,7 @@ describe('findMatchingSimulator', () => {
findMatchingSimulator(
{
devices: {
'iOS 12.0': [
'com.apple.CoreSimulator.SimRuntime.iOS-12-0': [
{
state: 'Shutdown',
availability: '(unavailable, runtime profile not found)',
Expand Down Expand Up @@ -855,7 +855,7 @@ describe('findMatchingSimulator', () => {
udid: 'D0F29BE7-CC3C-4976-888D-C739B4F50508',
},
],
'iOS 12.2': [
'com.apple.CoreSimulator.SimRuntime.iOS-12-2': [
{
state: 'Shutdown',
availability: '(available)',
Expand Down Expand Up @@ -883,7 +883,7 @@ describe('findMatchingSimulator', () => {
],
},
},
'iPad Pro (9.7-inch) (12.0)',
{simulator: 'iPad Pro (9.7-inch) (12.0)'},
),
).toEqual(null);
});
Expand All @@ -893,7 +893,7 @@ describe('findMatchingSimulator', () => {
findMatchingSimulator(
{
devices: {
'tvOS 11.2': [
'com.apple.CoreSimulator.SimRuntime.tvOS-11-2': [
{
state: 'Booted',
availability: '(available)',
Expand All @@ -915,7 +915,7 @@ describe('findMatchingSimulator', () => {
],
},
},
'Apple TV',
{simulator: 'Apple TV'},
),
).toEqual({
udid: '816C30EA-38EA-41AC-BFDA-96FB632D522E',
Expand All @@ -924,4 +924,56 @@ describe('findMatchingSimulator', () => {
version: 'tvOS 11.2',
});
});

it('should return a simulator by UDID', () => {
expect(
findMatchingSimulator(
{
devices: {
'com.apple.CoreSimulator.SimRuntime.iOS-12-1': [
{
state: 'Shutdown',
isAvailable: true,
name: 'iPhone 6s',
udid: 'D0F29BE7-CC3C-4976-888D-C739B4F50508',
},
{
state: 'Shutdown',
isAvailable: true,
name: 'iPhone 6',
udid: 'BA0D93BD-07E6-4182-9B0A-F60A2474139C',
},
{
state: 'Shutdown',
isAvailable: true,
name: 'iPhone XS Max',
udid: 'B9B5E161-416B-43C4-A78F-729CB96CC8C6',
availabilityError: '',
},
{
state: 'Shutdown',
isAvailable: true,
name: 'iPad Air',
udid: '1CCBBF8B-5773-4EA6-BD6F-C308C87A1ADB',
availabilityError: '',
},
{
state: 'Shutdown',
isAvailable: true,
name: 'iPad (5th generation)',
udid: '9564ABEE-9EC2-4B4A-B443-D3710929A45A',
availabilityError: '',
},
],
},
},
{udid: 'BA0D93BD-07E6-4182-9B0A-F60A2474139C'},
),
).toEqual({
udid: 'BA0D93BD-07E6-4182-9B0A-F60A2474139C',
name: 'iPhone 6',
booted: false,
version: 'iOS 12.1',
});
});
});
Loading

0 comments on commit 2d575b0

Please sign in to comment.