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

Commit 1da6bb8

Browse files
author
nturgut
authored
change how we parse simulator output to incorporate try bots (#18)
* change how we parse simulator output to incorporate try bots * addressing reviewer comments * make the test version same with wbe_drivers package
1 parent 1cea0d7 commit 1da6bb8

File tree

3 files changed

+53
-4
lines changed

3 files changed

+53
-4
lines changed

packages/simulators/lib/simulator_manager.dart

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class IosSimulatorManager {
102102
await _listExistingSimulators(osMajorVersion, osMinorVersion);
103103

104104
// The simulator list, have the version string followed by a list of phone
105-
// names along with their ids and their statuses. Example output:
105+
// names along with their ids and their statuses. Example output 1:
106106
// -- iOS 13.5 --
107107
// iPhone 8 (2A437C91-3B85-4D7B-BB91-32561DA07B85) (Shutdown)
108108
// iPhone 8 Plus (170207A8-7631-4CBE-940E-86A7815AEB2B) (Shutdown)
@@ -114,11 +114,34 @@ class IosSimulatorManager {
114114
// iPhone 8 Plus (170207A8-7631-4CBE-940E-86A7815AEB2B) (Shutdown)
115115
// iPhone 11 (7AEC5FB9-E08A-4F7F-8CA2-1518CE3A3E0D) (Booted)
116116
// iPhone 11 Pro (D8074C8B-35A5-4DA5-9AB2-4CE738A5E5FC) (Shutdown)
117+
// -- Device Pairs --
118+
// Example output 2 (from Mac Web Engine try bots):
119+
// == Devices ==
120+
// -- iOS 13.0 --
121+
// iPhone 8 (C142C9F5-C26E-4EB5-A2B8-915D5BD62FA5) (Shutdown)
122+
// iPhone 8 Plus (C1FE8FAA-5797-478E-8BEE-D7AD4811F08C) (Shutdown)
123+
// iPhone 11 (28A3E6C0-76E7-4EE3-9B34-B059C4BBE5CA) (Shutdown)
124+
// iPhone 11 Pro (0AD4BBA5-7BE7-415D-B9FD-D962FA8E1782) (Shutdown)
125+
// iPhone 11 Pro Max (1280DE05-B334-4E60-956F-4A62220DEFA3) (Shutdown)
126+
// iPad Pro (9.7-inch) (EDE46501-CB2B-4EA4-8B5C-13FAC6F2EC91) (Shutdown)
127+
// iPad Pro (11-inch) (E0B89C9C-6200-495C-B18B-0078CCAAC688) (Shutdown)
128+
// iPad Pro (12.9-inch) (3rd generation) (DB3EB7A8-C4D2-4F86-AFC1-D652FB0579E8) (Shutdown)
129+
// iPad Air (3rd generation) (9237DCD8-8F0E-40A6-96DF-B33C915AFE1B) (Shutdown)
130+
// == Device Pairs ==
117131
final int indexOfVersionListStart =
118132
simulatorsList.indexOf(simulatorVersion);
119133
final String restOfTheOutput = simulatorsList
120134
.substring(indexOfVersionListStart + simulatorVersion.length);
121-
final int indexOfNextVersion = restOfTheOutput.indexOf('--');
135+
int indexOfNextVersion = restOfTheOutput.indexOf('--');
136+
if (indexOfNextVersion == -1) {
137+
// Search for `== Device Pairs ==`.
138+
indexOfNextVersion = restOfTheOutput.indexOf('==');
139+
}
140+
if (indexOfNextVersion == -1) {
141+
// Set to end of file.
142+
indexOfNextVersion = restOfTheOutput.length;
143+
}
144+
122145
final String listOfPhones =
123146
restOfTheOutput.substring(0, indexOfNextVersion);
124147

@@ -198,8 +221,7 @@ class IosSimulator {
198221
await io.Process.run('xcrun', ['simctl', 'shutdown', '$id']);
199222

200223
if (versionResult.exitCode != 0) {
201-
throw Exception(
202-
'Failed to shutdown iOS simulators with id: $id.');
224+
throw Exception('Failed to shutdown iOS simulators with id: $id.');
203225
}
204226

205227
this._booted = false;

packages/simulators/pubspec.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ description: For creating and managing iOS simulators.
33

44
environment:
55
sdk: ">=2.2.2 <3.0.0"
6+
7+
dev_dependencies:
8+
test: ^1.6.5
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
// @dart = 2.6
6+
import 'package:test/test.dart';
7+
8+
import '../lib/simulator_manager.dart';
9+
10+
void main() async {
11+
test('boot simulator', () async {
12+
IosSimulatorManager simulatorManager = IosSimulatorManager();
13+
IosSimulator simulator =
14+
await simulatorManager.getSimulator(13, 0, 'iPhone 11');
15+
await simulator.boot();
16+
});
17+
18+
test('shutdown simulator', () async {
19+
IosSimulatorManager simulatorManager = IosSimulatorManager();
20+
IosSimulator simulator =
21+
await simulatorManager.getSimulator(13, 0, 'iPhone 11');
22+
await simulator.shutdown();
23+
});
24+
}

0 commit comments

Comments
 (0)