Test installation status when ideviceid is not installed (#10254)
Ensure that flutter doctor returns a partial installation status when ideviceid is not installed.
This commit is contained in:
@@ -6,7 +6,6 @@ import 'dart:async';
|
||||
|
||||
import '../base/common.dart';
|
||||
import '../base/file_system.dart';
|
||||
import '../base/io.dart';
|
||||
import '../base/os.dart';
|
||||
import '../base/platform.dart';
|
||||
import '../base/process.dart';
|
||||
@@ -33,6 +32,19 @@ class IOSWorkflow extends DoctorValidator implements Workflow {
|
||||
|
||||
bool get hasIDeviceId => exitsHappy(<String>['idevice_id', '-h']);
|
||||
|
||||
bool get hasWorkingLibimobiledevice {
|
||||
// Verify that libimobiledevice tools are installed.
|
||||
if (!hasIDeviceId)
|
||||
return false;
|
||||
|
||||
// If a device is attached, verify that we can get its name.
|
||||
final String result = runSync(<String>['idevice_id', '-l']);
|
||||
if (result.isNotEmpty && !exitsHappy(<String>['idevicename']))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool get hasIDeviceInstaller => exitsHappy(<String>['ideviceinstaller', '-h']);
|
||||
|
||||
bool get hasIosDeploy => exitsHappy(<String>['ios-deploy', '--version']);
|
||||
@@ -140,6 +152,16 @@ class IOSWorkflow extends DoctorValidator implements Workflow {
|
||||
if (hasHomebrew) {
|
||||
brewStatus = ValidationType.installed;
|
||||
|
||||
if (!hasWorkingLibimobiledevice) {
|
||||
brewStatus = ValidationType.partial;
|
||||
messages.add(new ValidationMessage.error(
|
||||
'libimobiledevice is incompatible with the installed Xcode version. To update, run:\n'
|
||||
' brew update\n'
|
||||
' brew uninstall --ignore-dependencies libimobiledevice\n'
|
||||
' brew install --HEAD libimobiledevice'
|
||||
));
|
||||
}
|
||||
|
||||
if (!hasIDeviceInstaller) {
|
||||
brewStatus = ValidationType.partial;
|
||||
messages.add(new ValidationMessage.error(
|
||||
@@ -155,7 +177,7 @@ class IOSWorkflow extends DoctorValidator implements Workflow {
|
||||
if (hasIosDeploy) {
|
||||
messages.add(new ValidationMessage('ios-deploy $iosDeployVersionText'));
|
||||
}
|
||||
if (!hasIDeviceId || !_iosDeployIsInstalledAndMeetsVersionCheck) {
|
||||
if (!_iosDeployIsInstalledAndMeetsVersionCheck) {
|
||||
brewStatus = ValidationType.partial;
|
||||
if (hasIosDeploy) {
|
||||
messages.add(new ValidationMessage.error(
|
||||
@@ -170,20 +192,8 @@ class IOSWorkflow extends DoctorValidator implements Workflow {
|
||||
' brew install ios-deploy'
|
||||
));
|
||||
}
|
||||
} else {
|
||||
// Check for compatibility between libimobiledevice and Xcode.
|
||||
// TODO(cbracken) remove this check once libimobiledevice > 1.2.0 is released.
|
||||
final ProcessResult result = (await runAsync(<String>['idevice_id', '-l'])).processResult;
|
||||
if (result.exitCode == 0 && result.stdout.isNotEmpty && !await exitsHappyAsync(<String>['ideviceName'])) {
|
||||
brewStatus = ValidationType.partial;
|
||||
messages.add(new ValidationMessage.error(
|
||||
'libimobiledevice is incompatible with the installed Xcode version. To update, run:\n'
|
||||
' brew update\n'
|
||||
' brew uninstall --ignore-dependencies libimobiledevice\n'
|
||||
' brew install --HEAD libimobiledevice'
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
if (isCocoaPodsInstalledAndMeetsVersionCheck) {
|
||||
if (isCocoaPodsInitialized) {
|
||||
messages.add(new ValidationMessage('CocoaPods version $cocoaPodsVersionText'));
|
||||
|
||||
@@ -100,6 +100,18 @@ void main() {
|
||||
expect(result.type, ValidationType.partial);
|
||||
}, overrides: <Type, Generator>{ Xcode: () => xcode });
|
||||
|
||||
testUsingContext('Emits partial status when libimobiledevice is not installed', () async {
|
||||
when(xcode.isInstalled).thenReturn(true);
|
||||
when(xcode.xcodeVersionText)
|
||||
.thenReturn('Xcode 8.2.1\nBuild version 8C1002\n');
|
||||
when(xcode.isInstalledAndMeetsVersionCheck).thenReturn(true);
|
||||
when(xcode.eulaSigned).thenReturn(true);
|
||||
final IOSWorkflowTestTarget workflow = new IOSWorkflowTestTarget()
|
||||
..hasWorkingLibimobiledevice = false;
|
||||
final ValidationResult result = await workflow.validate();
|
||||
expect(result.type, ValidationType.partial);
|
||||
}, overrides: <Type, Generator>{ Xcode: () => xcode });
|
||||
|
||||
testUsingContext('Emits partial status when ios-deploy is not installed', () async {
|
||||
when(xcode.isInstalled).thenReturn(true);
|
||||
when(xcode.xcodeVersionText)
|
||||
@@ -209,6 +221,9 @@ class IOSWorkflowTestTarget extends IOSWorkflow {
|
||||
@override
|
||||
bool hasHomebrew = true;
|
||||
|
||||
@override
|
||||
bool hasWorkingLibimobiledevice = true;
|
||||
|
||||
@override
|
||||
bool hasIosDeploy = true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user