Skip to content

Commit f8db7b2

Browse files
fix: prevent booting already booted simulators (#2033)
* fix: prevent booting already booted simulators * chore: remove useless commented code
1 parent 4b281bd commit f8db7b2

File tree

4 files changed

+22
-25
lines changed

4 files changed

+22
-25
lines changed

packages/cli-platform-ios/src/commands/runIOS/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,6 @@ async function runOnSimulator(
217217
args: FlagsT,
218218
simulator?: Device,
219219
) {
220-
// let selectedSimulator;
221220
/**
222221
* If provided simulator does not exist, try simulators in following order
223222
* - iPhone 14
@@ -269,7 +268,7 @@ async function runOnSimulator(
269268
selectedSimulator.udid,
270269
]);
271270

272-
if (!selectedSimulator.booted) {
271+
if (selectedSimulator.state !== 'Booted') {
273272
bootSimulator(selectedSimulator);
274273
}
275274

packages/cli-platform-ios/src/tools/__tests__/findMatchingSimulator.test.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ describe('findMatchingSimulator', () => {
5656
).toEqual({
5757
udid: 'BA0D93BD-07E6-4182-9B0A-F60A2474139C',
5858
name: 'iPhone 6',
59-
booted: false,
59+
state: 'Shutdown',
6060
version: 'iOS 9.2',
6161
});
6262
});
@@ -108,7 +108,7 @@ describe('findMatchingSimulator', () => {
108108
).toEqual({
109109
udid: 'BA0D93BD-07E6-4182-9B0A-F60A2474139C',
110110
name: 'iPhone 6',
111-
booted: false,
111+
state: 'Shutdown',
112112
version: 'iOS 12.1',
113113
});
114114
});
@@ -201,7 +201,7 @@ describe('findMatchingSimulator', () => {
201201
).toEqual({
202202
udid: '1CCBBF8B-5773-4EA6-BD6F-C308C87A1ADB',
203203
name: 'iPhone 5',
204-
booted: false,
204+
state: 'Shutdown',
205205
version: 'iOS 9.2',
206206
});
207207
});
@@ -276,7 +276,7 @@ describe('findMatchingSimulator', () => {
276276
).toEqual({
277277
udid: '1CCBBF8B-5773-4EA6-BD6F-C308C87A1ADB',
278278
name: 'iPhone 5',
279-
booted: false,
279+
state: 'Shutdown',
280280
version: 'iOS 9.2',
281281
});
282282
});
@@ -325,7 +325,7 @@ describe('findMatchingSimulator', () => {
325325
).toEqual({
326326
udid: 'D0F29BE7-CC3C-4976-888D-C739B4F50508',
327327
name: 'iPhone 6s',
328-
booted: true,
328+
state: 'Booted',
329329
version: 'iOS 9.2',
330330
});
331331
});
@@ -374,7 +374,7 @@ describe('findMatchingSimulator', () => {
374374
).toEqual({
375375
udid: 'BA0D93BD-07E6-4182-9B0A-F60A2474139C',
376376
name: 'iPhone 6',
377-
booted: false,
377+
state: 'Shutdown',
378378
version: 'iOS 9.2',
379379
});
380380
});
@@ -449,7 +449,7 @@ describe('findMatchingSimulator', () => {
449449
).toEqual({
450450
udid: '3A409DC5-5188-42A6-8598-3AA6F34607A5',
451451
name: 'iPhone 7',
452-
booted: true,
452+
state: 'Booted',
453453
version: 'iOS 10.0',
454454
});
455455
});
@@ -524,7 +524,7 @@ describe('findMatchingSimulator', () => {
524524
).toEqual({
525525
udid: 'D0F29BE7-CC3C-4976-888D-C739B4F50508',
526526
name: 'iPhone 6s',
527-
booted: false,
527+
state: 'Shutdown',
528528
version: 'iOS 9.2',
529529
});
530530
});
@@ -599,7 +599,7 @@ describe('findMatchingSimulator', () => {
599599
).toEqual({
600600
udid: 'CBBB8FB8-77AB-49A9-8297-4CCFE3189C22',
601601
name: 'iPhone 6s',
602-
booted: false,
602+
state: 'Shutdown',
603603
version: 'iOS 10.0',
604604
});
605605
});
@@ -738,7 +738,7 @@ describe('findMatchingSimulator', () => {
738738
).toEqual({
739739
udid: 'B2141C1E-86B7-4A10-82A7-4956799526DF',
740740
name: 'iPad Pro (9.7-inch)',
741-
booted: false,
741+
state: 'Shutdown',
742742
version: 'iOS 12.0',
743743
});
744744
});
@@ -813,7 +813,7 @@ describe('findMatchingSimulator', () => {
813813
).toEqual({
814814
udid: 'B2141C1E-86B7-4A10-82A7-4956799526DF',
815815
name: 'iPad Pro (9.7-inch)',
816-
booted: false,
816+
state: 'Shutdown',
817817
version: 'iOS 12.2',
818818
});
819819
});
@@ -935,7 +935,7 @@ describe('findMatchingSimulator', () => {
935935
).toEqual({
936936
udid: 'BA0D93BD-07E6-4182-9B0A-F60A2474139C',
937937
name: 'iPhone 6',
938-
booted: false,
938+
state: 'Shutdown',
939939
version: 'iOS 12.1',
940940
});
941941
});
@@ -979,7 +979,7 @@ describe('findMatchingSimulator', () => {
979979
).toEqual({
980980
udid: '3AA90A75-D9C3-41A6-8DE1-43BE74A0C32B',
981981
name: 'iPhone 14',
982-
booted: false,
982+
state: 'Shutdown',
983983
version: 'iOS 16.0',
984984
});
985985
});
@@ -1023,7 +1023,7 @@ describe('findMatchingSimulator', () => {
10231023
).toEqual({
10241024
udid: '6F2FA108-AC7D-4D3C-BD13-56C5E7FCEDFE',
10251025
name: 'iPhone 14 Plus',
1026-
booted: false,
1026+
state: 'Shutdown',
10271027
version: 'iOS 16.0',
10281028
});
10291029
});
@@ -1060,7 +1060,7 @@ describe('findMatchingSimulator', () => {
10601060
).toEqual({
10611061
udid: '816C30EA-38EA-41AC-BFDA-96FB632D522E',
10621062
name: 'Apple TV',
1063-
booted: true,
1063+
state: 'Booted',
10641064
version: 'tvOS 11.2',
10651065
});
10661066
});

packages/cli-platform-ios/src/tools/findMatchingSimulator.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,20 +83,19 @@ function findMatchingSimulator(
8383
) {
8484
continue;
8585
}
86-
const booted = simulator.state === 'Booted';
8786
const lastBootedAt = simulator.lastBootedAt;
88-
const simulatorDescriptor = {
87+
const simulatorDescriptor: Device = {
8988
udid: simulator.udid,
9089
name: simulator.name,
91-
booted,
90+
state: simulator.state,
9291
version,
9392
};
9493
if (findOptions && findOptions.udid) {
9594
if (simulator.udid === findOptions.udid) {
9695
return simulatorDescriptor;
9796
}
9897
} else {
99-
if (booted && simulatorName === null) {
98+
if (simulator.state === 'Booted' && simulatorName === null) {
10099
return simulatorDescriptor;
101100
}
102101
if (simulator.name === simulatorName && !match) {

packages/cli-platform-ios/src/types.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
export interface Device {
2-
availability?: string;
3-
state?: string;
4-
isAvailable?: boolean;
52
name: string;
63
udid: string;
4+
state?: string;
5+
availability?: string;
6+
isAvailable?: boolean;
77
version?: string;
88
availabilityError?: string;
99
type?: 'simulator' | 'device' | 'catalyst';
10-
booted?: boolean;
1110
lastBootedAt?: string;
1211
}
1312

0 commit comments

Comments
 (0)