Unverified Commit 6054eda8 authored by Christopher Fujino's avatar Christopher Fujino Committed by GitHub

fix lateinitialization error in devicelab-runner (#94957)

parent 2d2cd1f5
...@@ -18,7 +18,9 @@ import 'package:path/path.dart' as path; ...@@ -18,7 +18,9 @@ import 'package:path/path.dart' as path;
/// adding Flutter to an existing iOS app. /// adding Flutter to an existing iOS app.
Future<void> main() async { Future<void> main() async {
await task(() async { await task(() async {
late String simulatorDeviceId; // this variable cannot be `late`, as we reference it in the `finally` block
// which may execute before this field has been initialized
String? simulatorDeviceId;
section('Create Flutter module project'); section('Create Flutter module project');
final Directory tempDir = Directory.systemTemp.createTempSync('flutter_module_test.'); final Directory tempDir = Directory.systemTemp.createTempSync('flutter_module_test.');
......
...@@ -116,14 +116,14 @@ Future<void> testWithNewIOSSimulator( ...@@ -116,14 +116,14 @@ Future<void> testWithNewIOSSimulator(
} }
/// Shuts down and deletes simulator with deviceId. /// Shuts down and deletes simulator with deviceId.
Future<void> removeIOSimulator(String deviceId) async { Future<void> removeIOSimulator(String? deviceId) async {
if (deviceId != null && deviceId != '') { if (deviceId != null && deviceId != '') {
await eval( await eval(
'xcrun', 'xcrun',
<String>[ <String>[
'simctl', 'simctl',
'shutdown', 'shutdown',
deviceId deviceId,
], ],
canFail: true, canFail: true,
workingDirectory: flutterDirectory.path, workingDirectory: flutterDirectory.path,
...@@ -133,7 +133,8 @@ Future<void> removeIOSimulator(String deviceId) async { ...@@ -133,7 +133,8 @@ Future<void> removeIOSimulator(String deviceId) async {
<String>[ <String>[
'simctl', 'simctl',
'delete', 'delete',
deviceId], deviceId,
],
canFail: true, canFail: true,
workingDirectory: flutterDirectory.path, workingDirectory: flutterDirectory.path,
); );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment