Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit be1596a

Browse files
Filter out unavailable via simctl
1 parent b4be22c commit be1596a

File tree

3 files changed

+15
-84
lines changed

3 files changed

+15
-84
lines changed

script/tool/lib/src/common/xcode.dart

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,10 @@ class Xcode {
9191
final List<String> findSimulatorsArguments = <String>[
9292
'simctl',
9393
'list',
94-
'--json'
94+
'devices',
95+
'runtimes',
96+
'available',
97+
'--json',
9598
];
9699
final String findSimulatorCompleteCommand =
97100
'$_xcRunCommand ${findSimulatorsArguments.join(' ')}';
@@ -141,10 +144,6 @@ class Xcode {
141144
// Looking for runtimes, trying to find latest version of device.
142145
for (final Map<String, dynamic> rawDevice in devicesForRuntime.reversed) {
143146
final Map<String, Object> device = rawDevice.cast<String, Object>();
144-
if (device['availabilityError'] != null ||
145-
(device['isAvailable'] as bool?) == false) {
146-
continue;
147-
}
148147
id = device['udid'] as String?;
149148
if (id == null) {
150149
continue;

script/tool/test/common/xcode_test.dart

Lines changed: 1 addition & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -100,83 +100,6 @@ void main() {
100100
expect(await xcode.findBestAvailableIphoneSimulator(), expectedDeviceId);
101101
});
102102

103-
test('skips unavailable devices', () async {
104-
const String expectedDeviceId = '2706BBEB-1E01-403E-A8E9-70E8E5A24774';
105-
// Note: This uses `dynamic` deliberately, and should not be updated to
106-
// Object, in order to ensure that the code correctly handles this return
107-
// type from JSON decoding.
108-
final Map<String, dynamic> devices = <String, dynamic>{
109-
'runtimes': <Map<String, dynamic>>[
110-
<String, dynamic>{
111-
'bundlePath':
112-
'/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 13.0.simruntime',
113-
'buildversion': '17A577',
114-
'runtimeRoot':
115-
'/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 13.0.simruntime/Contents/Resources/RuntimeRoot',
116-
'identifier': 'com.apple.CoreSimulator.SimRuntime.iOS-13-0',
117-
'version': '13.0',
118-
'isAvailable': true,
119-
'name': 'iOS 13.0'
120-
},
121-
<String, dynamic>{
122-
'bundlePath':
123-
'/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 13.4.simruntime',
124-
'buildversion': '17L255',
125-
'runtimeRoot':
126-
'/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 13.4.simruntime/Contents/Resources/RuntimeRoot',
127-
'identifier': 'com.apple.CoreSimulator.SimRuntime.iOS-13-4',
128-
'version': '13.4',
129-
'isAvailable': true,
130-
'name': 'iOS 13.4'
131-
},
132-
<String, dynamic>{
133-
'bundlePath':
134-
'/Applications/Xcode_11_7.app/Contents/Developer/Platforms/WatchOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/watchOS.simruntime',
135-
'buildversion': '17T531',
136-
'runtimeRoot':
137-
'/Applications/Xcode_11_7.app/Contents/Developer/Platforms/WatchOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/watchOS.simruntime/Contents/Resources/RuntimeRoot',
138-
'identifier': 'com.apple.CoreSimulator.SimRuntime.watchOS-6-2',
139-
'version': '6.2.1',
140-
'isAvailable': true,
141-
'name': 'watchOS 6.2'
142-
}
143-
],
144-
'devices': <String, dynamic>{
145-
'com.apple.CoreSimulator.SimRuntime.iOS-13-4': <Map<String, dynamic>>[
146-
<String, dynamic>{
147-
'dataPath':
148-
'/Users/xxx/Library/Developer/CoreSimulator/Devices/2706BBEB-1E01-403E-A8E9-70E8E5A24774/data',
149-
'logPath':
150-
'/Users/xxx/Library/Logs/CoreSimulator/2706BBEB-1E01-403E-A8E9-70E8E5A24774',
151-
'udid': expectedDeviceId,
152-
'isAvailable': true,
153-
'deviceTypeIdentifier':
154-
'com.apple.CoreSimulator.SimDeviceType.iPhone-8',
155-
'state': 'Shutdown',
156-
'name': 'iPhone 8'
157-
},
158-
<String, dynamic>{
159-
'dataPath':
160-
'/Users/xxx/Library/Developer/CoreSimulator/Devices/1E76A0FD-38AC-4537-A989-EA639D7D012A/data',
161-
'logPath':
162-
'/Users/xxx/Library/Logs/CoreSimulator/1E76A0FD-38AC-4537-A989-EA639D7D012A',
163-
'udid': '1E76A0FD-38AC-4537-A989-EA639D7D012A',
164-
'isAvailable': false,
165-
'deviceTypeIdentifier':
166-
'com.apple.CoreSimulator.SimDeviceType.iPhone-8-Plus',
167-
'state': 'Shutdown',
168-
'name': 'iPhone 8 Plus'
169-
}
170-
]
171-
}
172-
};
173-
174-
processRunner.processToReturn = MockProcess.succeeding();
175-
processRunner.resultStdout = jsonEncode(devices);
176-
177-
expect(await xcode.findBestAvailableIphoneSimulator(), expectedDeviceId);
178-
});
179-
180103
test('ignores non-iOS runtimes', () async {
181104
// Note: This uses `dynamic` deliberately, and should not be updated to
182105
// Object, in order to ensure that the code correctly handles this return
@@ -204,7 +127,7 @@ void main() {
204127
'logPath':
205128
'/Users/xxx/Library/Logs/CoreSimulator/1E76A0FD-38AC-4537-A989-EA639D7D012A',
206129
'udid': '1E76A0FD-38AC-4537-A989-EA639D7D012A',
207-
'isAvailable': false,
130+
'isAvailable': true,
208131
'deviceTypeIdentifier':
209132
'com.apple.CoreSimulator.SimDeviceType.Apple-Watch-38mm',
210133
'state': 'Shutdown',

script/tool/test/xctest_command_test.dart

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,16 @@ void main() {
368368
processRunner.recordedCalls,
369369
orderedEquals(<ProcessCall>[
370370
const ProcessCall(
371-
'xcrun', <String>['simctl', 'list', '--json'], null),
371+
'xcrun',
372+
<String>[
373+
'simctl',
374+
'list',
375+
'devices',
376+
'runtimes',
377+
'available',
378+
'--json',
379+
],
380+
null),
372381
ProcessCall(
373382
'xcrun',
374383
const <String>[

0 commit comments

Comments
 (0)