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

fix: prevent booting already booted simulators #2033

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/cli-platform-ios/src/commands/runIOS/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ async function runOnSimulator(
args: FlagsT,
simulator?: Device,
) {
// let selectedSimulator;
/**
* If provided simulator does not exist, try simulators in following order
* - iPhone 14
Expand Down Expand Up @@ -278,7 +277,7 @@ async function runOnSimulator(
selectedSimulator.udid,
]);

if (!selectedSimulator.booted) {
if (selectedSimulator.state !== 'Booted') {
bootSimulator(selectedSimulator);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe('findMatchingSimulator', () => {
).toEqual({
udid: 'BA0D93BD-07E6-4182-9B0A-F60A2474139C',
name: 'iPhone 6',
booted: false,
state: 'Shutdown',
version: 'iOS 9.2',
});
});
Expand Down Expand Up @@ -108,7 +108,7 @@ describe('findMatchingSimulator', () => {
).toEqual({
udid: 'BA0D93BD-07E6-4182-9B0A-F60A2474139C',
name: 'iPhone 6',
booted: false,
state: 'Shutdown',
version: 'iOS 12.1',
});
});
Expand Down Expand Up @@ -201,7 +201,7 @@ describe('findMatchingSimulator', () => {
).toEqual({
udid: '1CCBBF8B-5773-4EA6-BD6F-C308C87A1ADB',
name: 'iPhone 5',
booted: false,
state: 'Shutdown',
version: 'iOS 9.2',
});
});
Expand Down Expand Up @@ -276,7 +276,7 @@ describe('findMatchingSimulator', () => {
).toEqual({
udid: '1CCBBF8B-5773-4EA6-BD6F-C308C87A1ADB',
name: 'iPhone 5',
booted: false,
state: 'Shutdown',
version: 'iOS 9.2',
});
});
Expand Down Expand Up @@ -325,7 +325,7 @@ describe('findMatchingSimulator', () => {
).toEqual({
udid: 'D0F29BE7-CC3C-4976-888D-C739B4F50508',
name: 'iPhone 6s',
booted: true,
state: 'Booted',
version: 'iOS 9.2',
});
});
Expand Down Expand Up @@ -374,7 +374,7 @@ describe('findMatchingSimulator', () => {
).toEqual({
udid: 'BA0D93BD-07E6-4182-9B0A-F60A2474139C',
name: 'iPhone 6',
booted: false,
state: 'Shutdown',
version: 'iOS 9.2',
});
});
Expand Down Expand Up @@ -449,7 +449,7 @@ describe('findMatchingSimulator', () => {
).toEqual({
udid: '3A409DC5-5188-42A6-8598-3AA6F34607A5',
name: 'iPhone 7',
booted: true,
state: 'Booted',
version: 'iOS 10.0',
});
});
Expand Down Expand Up @@ -524,7 +524,7 @@ describe('findMatchingSimulator', () => {
).toEqual({
udid: 'D0F29BE7-CC3C-4976-888D-C739B4F50508',
name: 'iPhone 6s',
booted: false,
state: 'Shutdown',
version: 'iOS 9.2',
});
});
Expand Down Expand Up @@ -599,7 +599,7 @@ describe('findMatchingSimulator', () => {
).toEqual({
udid: 'CBBB8FB8-77AB-49A9-8297-4CCFE3189C22',
name: 'iPhone 6s',
booted: false,
state: 'Shutdown',
version: 'iOS 10.0',
});
});
Expand Down Expand Up @@ -738,7 +738,7 @@ describe('findMatchingSimulator', () => {
).toEqual({
udid: 'B2141C1E-86B7-4A10-82A7-4956799526DF',
name: 'iPad Pro (9.7-inch)',
booted: false,
state: 'Shutdown',
version: 'iOS 12.0',
});
});
Expand Down Expand Up @@ -813,7 +813,7 @@ describe('findMatchingSimulator', () => {
).toEqual({
udid: 'B2141C1E-86B7-4A10-82A7-4956799526DF',
name: 'iPad Pro (9.7-inch)',
booted: false,
state: 'Shutdown',
version: 'iOS 12.2',
});
});
Expand Down Expand Up @@ -935,7 +935,7 @@ describe('findMatchingSimulator', () => {
).toEqual({
udid: 'BA0D93BD-07E6-4182-9B0A-F60A2474139C',
name: 'iPhone 6',
booted: false,
state: 'Shutdown',
version: 'iOS 12.1',
});
});
Expand Down Expand Up @@ -979,7 +979,7 @@ describe('findMatchingSimulator', () => {
).toEqual({
udid: '3AA90A75-D9C3-41A6-8DE1-43BE74A0C32B',
name: 'iPhone 14',
booted: false,
state: 'Shutdown',
version: 'iOS 16.0',
});
});
Expand Down Expand Up @@ -1023,7 +1023,7 @@ describe('findMatchingSimulator', () => {
).toEqual({
udid: '6F2FA108-AC7D-4D3C-BD13-56C5E7FCEDFE',
name: 'iPhone 14 Plus',
booted: false,
state: 'Shutdown',
version: 'iOS 16.0',
});
});
Expand Down Expand Up @@ -1060,7 +1060,7 @@ describe('findMatchingSimulator', () => {
).toEqual({
udid: '816C30EA-38EA-41AC-BFDA-96FB632D522E',
name: 'Apple TV',
booted: true,
state: 'Booted',
version: 'tvOS 11.2',
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,19 @@ function findMatchingSimulator(
) {
continue;
}
const booted = simulator.state === 'Booted';
const lastBootedAt = simulator.lastBootedAt;
const simulatorDescriptor = {
const simulatorDescriptor: Device = {
udid: simulator.udid,
name: simulator.name,
booted,
state: simulator.state,
version,
};
if (findOptions && findOptions.udid) {
if (simulator.udid === findOptions.udid) {
return simulatorDescriptor;
}
} else {
if (booted && simulatorName === null) {
if (simulator.state === 'Booted' && simulatorName === null) {
return simulatorDescriptor;
}
if (simulator.name === simulatorName && !match) {
Expand Down
7 changes: 3 additions & 4 deletions packages/cli-platform-ios/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
export interface Device {
availability?: string;
state?: string;
isAvailable?: boolean;
name: string;
udid: string;
state?: string;
availability?: string;
isAvailable?: boolean;
version?: string;
availabilityError?: string;
type?: 'simulator' | 'device' | 'catalyst';
booted?: boolean;
lastBootedAt?: string;
}

Expand Down
Loading