Commit 83514d67 authored by Chris Bracken's avatar Chris Bracken Committed by GitHub

Add doctor check for Python 'six' module (#7807)

* Add doctor check for Python 'six' module

Required as part of Xcode lldb module. In all likelihood, if we
encounter this situation, the developer is using a custom Python install
(e.g., via MacPorts or Homebrew).
parent 9c4b1001
...@@ -40,6 +40,8 @@ class IOSWorkflow extends DoctorValidator implements Workflow { ...@@ -40,6 +40,8 @@ class IOSWorkflow extends DoctorValidator implements Workflow {
bool get hasHomebrew => os.which('brew') != null; bool get hasHomebrew => os.which('brew') != null;
bool get hasPythonSixModule => exitsHappy(<String>['python', '-c', 'import six']);
bool get _iosDeployIsInstalledAndMeetsVersionCheck { bool get _iosDeployIsInstalledAndMeetsVersionCheck {
if (!hasIosDeploy) if (!hasIosDeploy)
return false; return false;
...@@ -55,6 +57,7 @@ class IOSWorkflow extends DoctorValidator implements Workflow { ...@@ -55,6 +57,7 @@ class IOSWorkflow extends DoctorValidator implements Workflow {
Future<ValidationResult> validate() async { Future<ValidationResult> validate() async {
List<ValidationMessage> messages = <ValidationMessage>[]; List<ValidationMessage> messages = <ValidationMessage>[];
ValidationType xcodeStatus = ValidationType.missing; ValidationType xcodeStatus = ValidationType.missing;
ValidationType pythonStatus = ValidationType.missing;
ValidationType brewStatus = ValidationType.missing; ValidationType brewStatus = ValidationType.missing;
String xcodeVersionInfo; String xcodeVersionInfo;
...@@ -90,6 +93,17 @@ class IOSWorkflow extends DoctorValidator implements Workflow { ...@@ -90,6 +93,17 @@ class IOSWorkflow extends DoctorValidator implements Workflow {
)); ));
} }
// Python dependencies installed
if (hasPythonSixModule) {
pythonStatus = ValidationType.installed;
} else {
pythonStatus = ValidationType.missing;
messages.add(new ValidationMessage.error(
'Python installation missing module "six".\n'
'Install via \'pip install six\' or \'sudo easy_install six\'.'
));
}
// brew installed // brew installed
if (hasHomebrew) { if (hasHomebrew) {
brewStatus = ValidationType.installed; brewStatus = ValidationType.installed;
...@@ -134,7 +148,7 @@ class IOSWorkflow extends DoctorValidator implements Workflow { ...@@ -134,7 +148,7 @@ class IOSWorkflow extends DoctorValidator implements Workflow {
} }
return new ValidationResult( return new ValidationResult(
<ValidationType>[xcodeStatus, brewStatus].reduce(_mergeValidationTypes), <ValidationType>[xcodeStatus, pythonStatus, brewStatus].reduce(_mergeValidationTypes),
messages, messages,
statusInfo: xcodeVersionInfo statusInfo: xcodeVersionInfo
); );
......
...@@ -21,6 +21,7 @@ void main() { ...@@ -21,6 +21,7 @@ void main() {
testUsingContext('Emit missing status when nothing is installed', () async { testUsingContext('Emit missing status when nothing is installed', () async {
when(xcode.isInstalled).thenReturn(false); when(xcode.isInstalled).thenReturn(false);
IOSWorkflowTestTarget workflow = new IOSWorkflowTestTarget() IOSWorkflowTestTarget workflow = new IOSWorkflowTestTarget()
..hasPythonSixModule = false
..hasHomebrew = false ..hasHomebrew = false
..hasIosDeploy = false; ..hasIosDeploy = false;
ValidationResult result = await workflow.validate(); ValidationResult result = await workflow.validate();
...@@ -56,6 +57,18 @@ void main() { ...@@ -56,6 +57,18 @@ void main() {
expect(result.type, ValidationType.partial); expect(result.type, ValidationType.partial);
}, overrides: <Type, Generator>{ Xcode: () => xcode }); }, overrides: <Type, Generator>{ Xcode: () => xcode });
testUsingContext('Emits partial status when python six 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);
IOSWorkflowTestTarget workflow = new IOSWorkflowTestTarget()
..hasPythonSixModule = false;
ValidationResult result = await workflow.validate();
expect(result.type, ValidationType.partial);
}, overrides: <Type, Generator>{ Xcode: () => xcode });
testUsingContext('Emits partial status when homebrew not installed', () async { testUsingContext('Emits partial status when homebrew not installed', () async {
when(xcode.isInstalled).thenReturn(true); when(xcode.isInstalled).thenReturn(true);
when(xcode.xcodeVersionText) when(xcode.xcodeVersionText)
...@@ -107,6 +120,9 @@ void main() { ...@@ -107,6 +120,9 @@ void main() {
class MockXcode extends Mock implements Xcode {} class MockXcode extends Mock implements Xcode {}
class IOSWorkflowTestTarget extends IOSWorkflow { class IOSWorkflowTestTarget extends IOSWorkflow {
@override
bool hasPythonSixModule = true;
@override @override
bool hasHomebrew = true; bool hasHomebrew = true;
......
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