Unverified Commit 5dac7a23 authored by jslavitz's avatar jslavitz Committed by GitHub

Removes check for Homebrew if all necessary packages are present. (#23844)

* Removes need for homebrew installation if all other packages are installed. Modifies test to work with this new functionality.
parent 00c07266
...@@ -68,11 +68,14 @@ class IOSValidator extends DoctorValidator { ...@@ -68,11 +68,14 @@ class IOSValidator extends DoctorValidator {
} }
} }
// Change this value if the number of checks for packages needed for installation changes
static const int totalChecks = 4;
@override @override
Future<ValidationResult> validate() async { Future<ValidationResult> validate() async {
final List<ValidationMessage> messages = <ValidationMessage>[]; final List<ValidationMessage> messages = <ValidationMessage>[];
ValidationType xcodeStatus = ValidationType.missing; ValidationType xcodeStatus = ValidationType.missing;
ValidationType brewStatus = ValidationType.missing; ValidationType packageManagerStatus = ValidationType.installed;
String xcodeVersionInfo; String xcodeVersionInfo;
if (xcode.isInstalled) { if (xcode.isInstalled) {
...@@ -125,76 +128,84 @@ class IOSValidator extends DoctorValidator { ...@@ -125,76 +128,84 @@ class IOSValidator extends DoctorValidator {
} }
} }
// brew installed int checksFailed = 0;
if (hasHomebrew) {
brewStatus = ValidationType.installed;
if (!iMobileDevice.isInstalled) { if (!iMobileDevice.isInstalled) {
brewStatus = ValidationType.partial; checksFailed += 3;
messages.add(ValidationMessage.error( packageManagerStatus = ValidationType.partial;
'libimobiledevice and ideviceinstaller are not installed. To install, run:\n' messages.add(ValidationMessage.error(
' brew update\n' 'libimobiledevice and ideviceinstaller are not installed. To install with Brew, run:\n'
' brew install --HEAD usbmuxd\n' ' brew update\n'
' brew link usbmuxd\n' ' brew install --HEAD usbmuxd\n'
' brew install --HEAD libimobiledevice\n' ' brew link usbmuxd\n'
' brew install ideviceinstaller' ' brew install --HEAD libimobiledevice\n'
)); ' brew install ideviceinstaller'
} else if (!await iMobileDevice.isWorking) { ));
brewStatus = ValidationType.partial; } else if (!await iMobileDevice.isWorking) {
checksFailed += 2;
packageManagerStatus = ValidationType.partial;
messages.add(ValidationMessage.error(
'Verify that all connected devices have been paired with this computer in Xcode.\n'
'If all devices have been paired, libimobiledevice and ideviceinstaller may require updating.\n'
'To update with Brew, run:\n'
' brew update\n'
' brew uninstall --ignore-dependencies libimobiledevice\n'
' brew uninstall --ignore-dependencies usbmuxd\n'
' brew install --HEAD usbmuxd\n'
' brew unlink usbmuxd\n'
' brew link usbmuxd\n'
' brew install --HEAD libimobiledevice\n'
' brew install ideviceinstaller'
));
} else if (!await hasIDeviceInstaller) {
checksFailed += 1;
packageManagerStatus = ValidationType.partial;
messages.add(ValidationMessage.error(
'ideviceinstaller is not installed; this is used to discover connected iOS devices.\n'
'To install with Brew, run:\n'
' brew install --HEAD usbmuxd\n'
' brew link usbmuxd\n'
' brew install --HEAD libimobiledevice\n'
' brew install ideviceinstaller'
));
}
final bool iHasIosDeploy = await hasIosDeploy;
// Check ios-deploy is installed at meets version requirements.
if (iHasIosDeploy) {
messages.add(
ValidationMessage('ios-deploy ${await iosDeployVersionText}'));
}
if (!await _iosDeployIsInstalledAndMeetsVersionCheck) {
packageManagerStatus = ValidationType.partial;
if (iHasIosDeploy) {
messages.add(ValidationMessage.error( messages.add(ValidationMessage.error(
'Verify that all connected devices have been paired with this computer in Xcode.\n' 'ios-deploy out of date ($iosDeployMinimumVersion is required). To upgrade with Brew:\n'
'If all devices have been paired, libimobiledevice and ideviceinstaller may require updating.\n' ' brew upgrade ios-deploy'
'To update, run:\n'
' brew update\n'
' brew uninstall --ignore-dependencies libimobiledevice\n'
' brew uninstall --ignore-dependencies usbmuxd\n'
' brew install --HEAD usbmuxd\n'
' brew unlink usbmuxd\n'
' brew link usbmuxd\n'
' brew install --HEAD libimobiledevice\n'
' brew install ideviceinstaller'
)); ));
} else if (!await hasIDeviceInstaller) { } else {
brewStatus = ValidationType.partial; checksFailed += 1;
messages.add(ValidationMessage.error( messages.add(ValidationMessage.error(
'ideviceinstaller is not installed; this is used to discover connected iOS devices.\n' 'ios-deploy not installed. To install with Brew:\n'
'To install, run:\n' ' brew install ios-deploy'
' brew install --HEAD usbmuxd\n'
' brew link usbmuxd\n'
' brew install --HEAD libimobiledevice\n'
' brew install ideviceinstaller'
)); ));
} }
}
// Check ios-deploy is installed at meets version requirements. // If one of the checks for the packages failed, we may need brew so that we can install
if (await hasIosDeploy) { // the necessary packages. If they're all there, however, we don't even need it.
messages.add(ValidationMessage('ios-deploy ${await iosDeployVersionText}')); if (checksFailed == totalChecks)
} packageManagerStatus = ValidationType.missing;
if (!await _iosDeployIsInstalledAndMeetsVersionCheck) { if (checksFailed > 0 && !hasHomebrew) {
brewStatus = ValidationType.partial;
if (await hasIosDeploy) {
messages.add(ValidationMessage.error(
'ios-deploy out of date ($iosDeployMinimumVersion is required). To upgrade:\n'
' brew upgrade ios-deploy'
));
} else {
messages.add(ValidationMessage.error(
'ios-deploy not installed. To install:\n'
' brew install ios-deploy'
));
}
}
} else {
brewStatus = ValidationType.missing;
messages.add(ValidationMessage.error( messages.add(ValidationMessage.error(
'Brew not installed; use this to install tools for iOS device development.\n' 'Brew can be used to install tools for iOS device development.\n'
'Download brew at https://brew.sh/.' 'Download brew at https://brew.sh/.'
)); ));
} }
return ValidationResult( return ValidationResult(
<ValidationType>[xcodeStatus, brewStatus].reduce(_mergeValidationTypes), <ValidationType>[xcodeStatus, packageManagerStatus].reduce(_mergeValidationTypes),
messages, messages,
statusInfo: xcodeVersionInfo statusInfo: xcodeVersionInfo
); );
......
...@@ -21,6 +21,7 @@ import '../src/context.dart'; ...@@ -21,6 +21,7 @@ import '../src/context.dart';
void main() { void main() {
group('iOS Workflow validation', () { group('iOS Workflow validation', () {
MockIMobileDevice iMobileDevice; MockIMobileDevice iMobileDevice;
MockIMobileDevice iMobileDeviceUninstalled;
MockXcode xcode; MockXcode xcode;
MockProcessManager processManager; MockProcessManager processManager;
MockCocoaPods cocoaPods; MockCocoaPods cocoaPods;
...@@ -28,6 +29,7 @@ void main() { ...@@ -28,6 +29,7 @@ void main() {
setUp(() { setUp(() {
iMobileDevice = MockIMobileDevice(); iMobileDevice = MockIMobileDevice();
iMobileDeviceUninstalled = MockIMobileDevice(isInstalled: false);
xcode = MockXcode(); xcode = MockXcode();
processManager = MockProcessManager(); processManager = MockProcessManager();
cocoaPods = MockCocoaPods(); cocoaPods = MockCocoaPods();
...@@ -45,11 +47,13 @@ void main() { ...@@ -45,11 +47,13 @@ void main() {
final IOSWorkflowTestTarget workflow = IOSWorkflowTestTarget( final IOSWorkflowTestTarget workflow = IOSWorkflowTestTarget(
hasHomebrew: false, hasHomebrew: false,
hasIosDeploy: false, hasIosDeploy: false,
hasIDeviceInstaller: false,
iosDeployVersionText: '0.0.0',
); );
final ValidationResult result = await workflow.validate(); final ValidationResult result = await workflow.validate();
expect(result.type, ValidationType.missing); expect(result.type, ValidationType.missing);
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
IMobileDevice: () => iMobileDevice, IMobileDevice: () => iMobileDeviceUninstalled,
Xcode: () => xcode, Xcode: () => xcode,
CocoaPods: () => cocoaPods, CocoaPods: () => cocoaPods,
}); });
...@@ -110,7 +114,7 @@ void main() { ...@@ -110,7 +114,7 @@ void main() {
CocoaPods: () => cocoaPods, CocoaPods: () => cocoaPods,
}); });
testUsingContext('Emits partial status when homebrew not installed', () async { testUsingContext('Emits installed status when homebrew not installed, but not needed', () async {
when(xcode.isInstalled).thenReturn(true); when(xcode.isInstalled).thenReturn(true);
when(xcode.versionText) when(xcode.versionText)
.thenReturn('Xcode 8.2.1\nBuild version 8C1002\n'); .thenReturn('Xcode 8.2.1\nBuild version 8C1002\n');
...@@ -119,7 +123,7 @@ void main() { ...@@ -119,7 +123,7 @@ void main() {
when(xcode.isSimctlInstalled).thenReturn(true); when(xcode.isSimctlInstalled).thenReturn(true);
final IOSWorkflowTestTarget workflow = IOSWorkflowTestTarget(hasHomebrew: false); final IOSWorkflowTestTarget workflow = IOSWorkflowTestTarget(hasHomebrew: false);
final ValidationResult result = await workflow.validate(); final ValidationResult result = await workflow.validate();
expect(result.type, ValidationType.partial); expect(result.type, ValidationType.installed);
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
IMobileDevice: () => iMobileDevice, IMobileDevice: () => iMobileDevice,
Xcode: () => xcode, Xcode: () => xcode,
......
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