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,14 +128,13 @@ class IOSValidator extends DoctorValidator { ...@@ -125,14 +128,13 @@ 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;
packageManagerStatus = ValidationType.partial;
messages.add(ValidationMessage.error( messages.add(ValidationMessage.error(
'libimobiledevice and ideviceinstaller are not installed. To install, run:\n' 'libimobiledevice and ideviceinstaller are not installed. To install with Brew, run:\n'
' brew update\n' ' brew update\n'
' brew install --HEAD usbmuxd\n' ' brew install --HEAD usbmuxd\n'
' brew link usbmuxd\n' ' brew link usbmuxd\n'
...@@ -140,11 +142,12 @@ class IOSValidator extends DoctorValidator { ...@@ -140,11 +142,12 @@ class IOSValidator extends DoctorValidator {
' brew install ideviceinstaller' ' brew install ideviceinstaller'
)); ));
} else if (!await iMobileDevice.isWorking) { } else if (!await iMobileDevice.isWorking) {
brewStatus = ValidationType.partial; checksFailed += 2;
packageManagerStatus = ValidationType.partial;
messages.add(ValidationMessage.error( messages.add(ValidationMessage.error(
'Verify that all connected devices have been paired with this computer in Xcode.\n' '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' 'If all devices have been paired, libimobiledevice and ideviceinstaller may require updating.\n'
'To update, run:\n' 'To update with Brew, run:\n'
' brew update\n' ' brew update\n'
' brew uninstall --ignore-dependencies libimobiledevice\n' ' brew uninstall --ignore-dependencies libimobiledevice\n'
' brew uninstall --ignore-dependencies usbmuxd\n' ' brew uninstall --ignore-dependencies usbmuxd\n'
...@@ -155,10 +158,11 @@ class IOSValidator extends DoctorValidator { ...@@ -155,10 +158,11 @@ class IOSValidator extends DoctorValidator {
' brew install ideviceinstaller' ' brew install ideviceinstaller'
)); ));
} else if (!await hasIDeviceInstaller) { } else if (!await hasIDeviceInstaller) {
brewStatus = ValidationType.partial; checksFailed += 1;
packageManagerStatus = ValidationType.partial;
messages.add(ValidationMessage.error( messages.add(ValidationMessage.error(
'ideviceinstaller is not installed; this is used to discover connected iOS devices.\n' 'ideviceinstaller is not installed; this is used to discover connected iOS devices.\n'
'To install, run:\n' 'To install with Brew, run:\n'
' brew install --HEAD usbmuxd\n' ' brew install --HEAD usbmuxd\n'
' brew link usbmuxd\n' ' brew link usbmuxd\n'
' brew install --HEAD libimobiledevice\n' ' brew install --HEAD libimobiledevice\n'
...@@ -166,35 +170,42 @@ class IOSValidator extends DoctorValidator { ...@@ -166,35 +170,42 @@ class IOSValidator extends DoctorValidator {
)); ));
} }
final bool iHasIosDeploy = await hasIosDeploy;
// Check ios-deploy is installed at meets version requirements. // Check ios-deploy is installed at meets version requirements.
if (await hasIosDeploy) { if (iHasIosDeploy) {
messages.add(ValidationMessage('ios-deploy ${await iosDeployVersionText}')); messages.add(
ValidationMessage('ios-deploy ${await iosDeployVersionText}'));
} }
if (!await _iosDeployIsInstalledAndMeetsVersionCheck) { if (!await _iosDeployIsInstalledAndMeetsVersionCheck) {
brewStatus = ValidationType.partial; packageManagerStatus = ValidationType.partial;
if (await hasIosDeploy) { if (iHasIosDeploy) {
messages.add(ValidationMessage.error( messages.add(ValidationMessage.error(
'ios-deploy out of date ($iosDeployMinimumVersion is required). To upgrade:\n' 'ios-deploy out of date ($iosDeployMinimumVersion is required). To upgrade with Brew:\n'
' brew upgrade ios-deploy' ' brew upgrade ios-deploy'
)); ));
} else { } else {
checksFailed += 1;
messages.add(ValidationMessage.error( messages.add(ValidationMessage.error(
'ios-deploy not installed. To install:\n' 'ios-deploy not installed. To install with Brew:\n'
' brew install ios-deploy' ' brew install ios-deploy'
)); ));
} }
} }
} else { // If one of the checks for the packages failed, we may need brew so that we can install
brewStatus = ValidationType.missing; // the necessary packages. If they're all there, however, we don't even need it.
if (checksFailed == totalChecks)
packageManagerStatus = ValidationType.missing;
if (checksFailed > 0 && !hasHomebrew) {
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