[flutter_tools] add --uninstall-first flag and pipe it through to ios-deploy (#102948)
This commit is contained in:
parent
4bed76757d
commit
09686a04c9
@ -33,7 +33,15 @@ TaskFunction createHotModeTest({String? deviceIdOverride, Map<String, String>? e
|
|||||||
final File benchmarkFile = file(path.join(_editedFlutterGalleryDir.path, 'hot_benchmark.json'));
|
final File benchmarkFile = file(path.join(_editedFlutterGalleryDir.path, 'hot_benchmark.json'));
|
||||||
rm(benchmarkFile);
|
rm(benchmarkFile);
|
||||||
final List<String> options = <String>[
|
final List<String> options = <String>[
|
||||||
'--hot', '-d', deviceIdOverride!, '--benchmark', '--resident', '--no-android-gradle-daemon', '--no-publish-port', '--verbose',
|
'--hot',
|
||||||
|
'-d',
|
||||||
|
deviceIdOverride!,
|
||||||
|
'--benchmark',
|
||||||
|
'--resident',
|
||||||
|
'--no-android-gradle-daemon',
|
||||||
|
'--no-publish-port',
|
||||||
|
'--verbose',
|
||||||
|
'--uninstall-first',
|
||||||
];
|
];
|
||||||
int hotReloadCount = 0;
|
int hotReloadCount = 0;
|
||||||
late Map<String, dynamic> smallReloadData;
|
late Map<String, dynamic> smallReloadData;
|
||||||
|
@ -140,6 +140,11 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment
|
|||||||
'this option multiple times each with one argument to pass '
|
'this option multiple times each with one argument to pass '
|
||||||
'multiple arguments to the Dart entrypoint. Currently this is '
|
'multiple arguments to the Dart entrypoint. Currently this is '
|
||||||
'only supported on desktop platforms.',
|
'only supported on desktop platforms.',
|
||||||
|
)
|
||||||
|
..addFlag('uninstall-first',
|
||||||
|
hide: !verboseHelp,
|
||||||
|
help: 'Uninstall previous versions of the app on the device '
|
||||||
|
'before reinstalling. Currently only supported on iOS.',
|
||||||
);
|
);
|
||||||
usesWebOptions(verboseHelp: verboseHelp);
|
usesWebOptions(verboseHelp: verboseHelp);
|
||||||
usesTargetOption();
|
usesTargetOption();
|
||||||
@ -166,6 +171,7 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment
|
|||||||
bool get runningWithPrebuiltApplication => argResults[FlutterOptions.kUseApplicationBinary] != null;
|
bool get runningWithPrebuiltApplication => argResults[FlutterOptions.kUseApplicationBinary] != null;
|
||||||
bool get trackWidgetCreation => boolArg('track-widget-creation');
|
bool get trackWidgetCreation => boolArg('track-widget-creation');
|
||||||
bool get enableImpeller => boolArg('enable-impeller');
|
bool get enableImpeller => boolArg('enable-impeller');
|
||||||
|
bool get uninstallFirst => boolArg('uninstall-first');
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool get reportNullSafety => true;
|
bool get reportNullSafety => true;
|
||||||
@ -196,6 +202,7 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment
|
|||||||
webRunHeadless: featureFlags.isWebEnabled && boolArg('web-run-headless'),
|
webRunHeadless: featureFlags.isWebEnabled && boolArg('web-run-headless'),
|
||||||
webBrowserDebugPort: browserDebugPort,
|
webBrowserDebugPort: browserDebugPort,
|
||||||
enableImpeller: enableImpeller,
|
enableImpeller: enableImpeller,
|
||||||
|
uninstallFirst: uninstallFirst,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return DebuggingOptions.enabled(
|
return DebuggingOptions.enabled(
|
||||||
@ -240,6 +247,7 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment
|
|||||||
nullAssertions: boolArg('null-assertions'),
|
nullAssertions: boolArg('null-assertions'),
|
||||||
nativeNullAssertions: boolArg('native-null-assertions'),
|
nativeNullAssertions: boolArg('native-null-assertions'),
|
||||||
enableImpeller: enableImpeller,
|
enableImpeller: enableImpeller,
|
||||||
|
uninstallFirst: uninstallFirst,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -792,6 +792,7 @@ class DebuggingOptions {
|
|||||||
this.nullAssertions = false,
|
this.nullAssertions = false,
|
||||||
this.nativeNullAssertions = false,
|
this.nativeNullAssertions = false,
|
||||||
this.enableImpeller = false,
|
this.enableImpeller = false,
|
||||||
|
this.uninstallFirst = false,
|
||||||
}) : debuggingEnabled = true;
|
}) : debuggingEnabled = true;
|
||||||
|
|
||||||
DebuggingOptions.disabled(this.buildInfo, {
|
DebuggingOptions.disabled(this.buildInfo, {
|
||||||
@ -808,6 +809,7 @@ class DebuggingOptions {
|
|||||||
this.cacheSkSL = false,
|
this.cacheSkSL = false,
|
||||||
this.traceAllowlist,
|
this.traceAllowlist,
|
||||||
this.enableImpeller = false,
|
this.enableImpeller = false,
|
||||||
|
this.uninstallFirst = false,
|
||||||
}) : debuggingEnabled = false,
|
}) : debuggingEnabled = false,
|
||||||
useTestFonts = false,
|
useTestFonts = false,
|
||||||
startPaused = false,
|
startPaused = false,
|
||||||
@ -876,6 +878,7 @@ class DebuggingOptions {
|
|||||||
required this.nullAssertions,
|
required this.nullAssertions,
|
||||||
required this.nativeNullAssertions,
|
required this.nativeNullAssertions,
|
||||||
required this.enableImpeller,
|
required this.enableImpeller,
|
||||||
|
required this.uninstallFirst,
|
||||||
});
|
});
|
||||||
|
|
||||||
final bool debuggingEnabled;
|
final bool debuggingEnabled;
|
||||||
@ -912,6 +915,11 @@ class DebuggingOptions {
|
|||||||
final bool webUseSseForInjectedClient;
|
final bool webUseSseForInjectedClient;
|
||||||
final bool enableImpeller;
|
final bool enableImpeller;
|
||||||
|
|
||||||
|
/// Whether the tool should try to uninstall a previously installed version of the app.
|
||||||
|
///
|
||||||
|
/// This is not implemented for every platform.
|
||||||
|
final bool uninstallFirst;
|
||||||
|
|
||||||
/// Whether to run the browser in headless mode.
|
/// Whether to run the browser in headless mode.
|
||||||
///
|
///
|
||||||
/// Some CI environments do not provide a display and fail to launch the
|
/// Some CI environments do not provide a display and fail to launch the
|
||||||
@ -1026,6 +1034,7 @@ class DebuggingOptions {
|
|||||||
nullAssertions: (json['nullAssertions'] as bool?)!,
|
nullAssertions: (json['nullAssertions'] as bool?)!,
|
||||||
nativeNullAssertions: (json['nativeNullAssertions'] as bool?)!,
|
nativeNullAssertions: (json['nativeNullAssertions'] as bool?)!,
|
||||||
enableImpeller: (json['enableImpeller'] as bool?) ?? false,
|
enableImpeller: (json['enableImpeller'] as bool?) ?? false,
|
||||||
|
uninstallFirst: (json['uninstallFirst'] as bool?) ?? false,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -394,6 +394,7 @@ class IOSDevice extends Device {
|
|||||||
appDeltaDirectory: package.appDeltaDirectory,
|
appDeltaDirectory: package.appDeltaDirectory,
|
||||||
launchArguments: launchArguments,
|
launchArguments: launchArguments,
|
||||||
interfaceType: interfaceType,
|
interfaceType: interfaceType,
|
||||||
|
uninstallFirst: debuggingOptions.uninstallFirst,
|
||||||
);
|
);
|
||||||
if (deviceLogReader is IOSDeviceLogReader) {
|
if (deviceLogReader is IOSDeviceLogReader) {
|
||||||
deviceLogReader.debuggerStream = iosDeployDebugger;
|
deviceLogReader.debuggerStream = iosDeployDebugger;
|
||||||
@ -415,6 +416,7 @@ class IOSDevice extends Device {
|
|||||||
appDeltaDirectory: package.appDeltaDirectory,
|
appDeltaDirectory: package.appDeltaDirectory,
|
||||||
launchArguments: launchArguments,
|
launchArguments: launchArguments,
|
||||||
interfaceType: interfaceType,
|
interfaceType: interfaceType,
|
||||||
|
uninstallFirst: debuggingOptions.uninstallFirst,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
installationResult = await iosDeployDebugger!.launchAndAttach() ? 0 : 1;
|
installationResult = await iosDeployDebugger!.launchAndAttach() ? 0 : 1;
|
||||||
|
@ -127,6 +127,7 @@ class IOSDeploy {
|
|||||||
required List<String> launchArguments,
|
required List<String> launchArguments,
|
||||||
required IOSDeviceConnectionInterface interfaceType,
|
required IOSDeviceConnectionInterface interfaceType,
|
||||||
Directory? appDeltaDirectory,
|
Directory? appDeltaDirectory,
|
||||||
|
required bool uninstallFirst,
|
||||||
}) {
|
}) {
|
||||||
appDeltaDirectory?.createSync(recursive: true);
|
appDeltaDirectory?.createSync(recursive: true);
|
||||||
// Interactive debug session to support sending the lldb detach command.
|
// Interactive debug session to support sending the lldb detach command.
|
||||||
@ -144,6 +145,8 @@ class IOSDeploy {
|
|||||||
'--app_deltas',
|
'--app_deltas',
|
||||||
appDeltaDirectory.path,
|
appDeltaDirectory.path,
|
||||||
],
|
],
|
||||||
|
if (uninstallFirst)
|
||||||
|
'--uninstall',
|
||||||
'--debug',
|
'--debug',
|
||||||
if (interfaceType != IOSDeviceConnectionInterface.network)
|
if (interfaceType != IOSDeviceConnectionInterface.network)
|
||||||
'--no-wifi',
|
'--no-wifi',
|
||||||
@ -168,6 +171,7 @@ class IOSDeploy {
|
|||||||
required String bundlePath,
|
required String bundlePath,
|
||||||
required List<String> launchArguments,
|
required List<String> launchArguments,
|
||||||
required IOSDeviceConnectionInterface interfaceType,
|
required IOSDeviceConnectionInterface interfaceType,
|
||||||
|
required bool uninstallFirst,
|
||||||
Directory? appDeltaDirectory,
|
Directory? appDeltaDirectory,
|
||||||
}) async {
|
}) async {
|
||||||
appDeltaDirectory?.createSync(recursive: true);
|
appDeltaDirectory?.createSync(recursive: true);
|
||||||
@ -183,6 +187,8 @@ class IOSDeploy {
|
|||||||
],
|
],
|
||||||
if (interfaceType != IOSDeviceConnectionInterface.network)
|
if (interfaceType != IOSDeviceConnectionInterface.network)
|
||||||
'--no-wifi',
|
'--no-wifi',
|
||||||
|
if (uninstallFirst)
|
||||||
|
'--uninstall',
|
||||||
'--justlaunch',
|
'--justlaunch',
|
||||||
if (launchArguments.isNotEmpty) ...<String>[
|
if (launchArguments.isNotEmpty) ...<String>[
|
||||||
'--args',
|
'--args',
|
||||||
|
@ -369,6 +369,42 @@ void main() {
|
|||||||
Cache: () => Cache.test(processManager: FakeProcessManager.any()),
|
Cache: () => Cache.test(processManager: FakeProcessManager.any()),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testUsingContext('forwards --uninstall-only to DebuggingOptions', () async {
|
||||||
|
final RunCommand command = RunCommand();
|
||||||
|
final FakeDevice mockDevice = FakeDevice(
|
||||||
|
sdkNameAndVersion: 'iOS 13',
|
||||||
|
)..startAppSuccess = false;
|
||||||
|
|
||||||
|
mockDeviceManager
|
||||||
|
..devices = <Device>[
|
||||||
|
mockDevice,
|
||||||
|
]
|
||||||
|
..targetDevices = <Device>[
|
||||||
|
mockDevice,
|
||||||
|
];
|
||||||
|
|
||||||
|
// Causes swift to be detected in the analytics.
|
||||||
|
fs.currentDirectory.childDirectory('ios').childFile('AppDelegate.swift').createSync(recursive: true);
|
||||||
|
|
||||||
|
await expectToolExitLater(createTestCommandRunner(command).run(<String>[
|
||||||
|
'run',
|
||||||
|
'--no-pub',
|
||||||
|
'--no-hot',
|
||||||
|
'--uninstall-first',
|
||||||
|
]), isNull);
|
||||||
|
|
||||||
|
final DebuggingOptions options = await command.createDebuggingOptions(false);
|
||||||
|
expect(options.uninstallFirst, isTrue);
|
||||||
|
}, overrides: <Type, Generator>{
|
||||||
|
Artifacts: () => artifacts,
|
||||||
|
Cache: () => Cache.test(processManager: FakeProcessManager.any()),
|
||||||
|
DeviceManager: () => mockDeviceManager,
|
||||||
|
FileSystem: () => fs,
|
||||||
|
ProcessManager: () => FakeProcessManager.any(),
|
||||||
|
Usage: () => usage,
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
testUsingContext('passes device target platform to usage', () async {
|
testUsingContext('passes device target platform to usage', () async {
|
||||||
final RunCommand command = RunCommand();
|
final RunCommand command = RunCommand();
|
||||||
final FakeDevice mockDevice = FakeDevice(sdkNameAndVersion: 'iOS 13')
|
final FakeDevice mockDevice = FakeDevice(sdkNameAndVersion: 'iOS 13')
|
||||||
|
@ -53,6 +53,7 @@ void main () {
|
|||||||
'/',
|
'/',
|
||||||
'--app_deltas',
|
'--app_deltas',
|
||||||
'app-delta',
|
'app-delta',
|
||||||
|
'--uninstall',
|
||||||
'--debug',
|
'--debug',
|
||||||
'--args',
|
'--args',
|
||||||
<String>[
|
<String>[
|
||||||
@ -73,6 +74,7 @@ void main () {
|
|||||||
appDeltaDirectory: appDeltaDirectory,
|
appDeltaDirectory: appDeltaDirectory,
|
||||||
launchArguments: <String>['--enable-dart-profiling'],
|
launchArguments: <String>['--enable-dart-profiling'],
|
||||||
interfaceType: IOSDeviceConnectionInterface.network,
|
interfaceType: IOSDeviceConnectionInterface.network,
|
||||||
|
uninstallFirst: true,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(iosDeployDebugger.logLines, emits('Did finish launching.'));
|
expect(iosDeployDebugger.logLines, emits('Did finish launching.'));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user