Commit a4c58292 authored by Todd Volkert's avatar Todd Volkert Committed by GitHub

Fix and enable broken flutter_tools tests (#8720)

(follow-on to #8698)
parent 7ede6b53
...@@ -31,6 +31,8 @@ class IOSWorkflow extends DoctorValidator implements Workflow { ...@@ -31,6 +31,8 @@ class IOSWorkflow extends DoctorValidator implements Workflow {
bool get hasIDeviceId => exitsHappy(<String>['idevice_id', '-h']); bool get hasIDeviceId => exitsHappy(<String>['idevice_id', '-h']);
bool get hasIDeviceInstaller => exitsHappy(<String>['ideviceinstaller', '-h']);
bool get hasIosDeploy => exitsHappy(<String>['ios-deploy', '--version']); bool get hasIosDeploy => exitsHappy(<String>['ios-deploy', '--version']);
String get iosDeployMinimumVersion => '1.9.0'; String get iosDeployMinimumVersion => '1.9.0';
...@@ -132,7 +134,7 @@ class IOSWorkflow extends DoctorValidator implements Workflow { ...@@ -132,7 +134,7 @@ class IOSWorkflow extends DoctorValidator implements Workflow {
if (hasHomebrew) { if (hasHomebrew) {
brewStatus = ValidationType.installed; brewStatus = ValidationType.installed;
if (!exitsHappy(<String>['ideviceinstaller', '-h'])) { if (!hasIDeviceInstaller) {
brewStatus = ValidationType.partial; brewStatus = ValidationType.partial;
messages.add(new ValidationMessage.error( messages.add(new ValidationMessage.error(
'ideviceinstaller not available; this is used to discover connected iOS devices.\n' 'ideviceinstaller not available; this is used to discover connected iOS devices.\n'
......
...@@ -65,10 +65,10 @@ void main() { ...@@ -65,10 +65,10 @@ void main() {
await server.start(); await server.start();
await onDone; await onDone;
expect(errorCount, 2); expect(errorCount, greaterThan(0));
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
OperatingSystemUtils: () => os OperatingSystemUtils: () => os
}, skip: true /* TODO(tvolkert): fix and enable */); });
} }
void _createSampleProject(Directory directory, { bool brokenCode: false }) { void _createSampleProject(Directory directory, { bool brokenCode: false }) {
......
...@@ -2,11 +2,12 @@ ...@@ -2,11 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/doctor.dart'; import 'package:flutter_tools/src/doctor.dart';
import 'package:flutter_tools/src/ios/ios_workflow.dart'; import 'package:flutter_tools/src/ios/ios_workflow.dart';
import 'package:flutter_tools/src/ios/mac.dart'; import 'package:flutter_tools/src/ios/mac.dart';
import 'package:mockito/mockito.dart'; import 'package:mockito/mockito.dart';
import 'package:process/process.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
import '../context.dart'; import '../context.dart';
...@@ -14,8 +15,11 @@ import '../context.dart'; ...@@ -14,8 +15,11 @@ import '../context.dart';
void main() { void main() {
group('iOS Workflow validation', () { group('iOS Workflow validation', () {
MockXcode xcode; MockXcode xcode;
MockProcessManager processManager;
setUp(() { setUp(() {
xcode = new MockXcode(); xcode = new MockXcode();
processManager = new MockProcessManager();
}); });
testUsingContext('Emit missing status when nothing is installed', () async { testUsingContext('Emit missing status when nothing is installed', () async {
...@@ -121,14 +125,30 @@ void main() { ...@@ -121,14 +125,30 @@ void main() {
.thenReturn('Xcode 8.2.1\nBuild version 8C1002\n'); .thenReturn('Xcode 8.2.1\nBuild version 8C1002\n');
when(xcode.isInstalledAndMeetsVersionCheck).thenReturn(true); when(xcode.isInstalledAndMeetsVersionCheck).thenReturn(true);
when(xcode.eulaSigned).thenReturn(true); when(xcode.eulaSigned).thenReturn(true);
when(processManager.runSync(argThat(contains('idevice_id'))))
.thenReturn(exitsHappy);
when(processManager.run(argThat(contains('idevice_id')), workingDirectory: any, environment: any))
.thenReturn(exitsHappy);
final ValidationResult result = await new IOSWorkflowTestTarget().validate(); final ValidationResult result = await new IOSWorkflowTestTarget().validate();
expect(result.type, ValidationType.installed); expect(result.type, ValidationType.installed);
}, overrides: <Type, Generator>{ Xcode: () => xcode }, }, overrides: <Type, Generator>{
skip: true /* TODO(tvolkert): fix and enable */); Xcode: () => xcode,
ProcessManager: () => processManager,
});
}); });
} }
final ProcessResult exitsHappy = new ProcessResult(
1, // pid
0, // exitCode
'', // stdout
'', // stderr
);
class MockXcode extends Mock implements Xcode {} class MockXcode extends Mock implements Xcode {}
class MockProcessManager extends Mock implements ProcessManager {}
class IOSWorkflowTestTarget extends IOSWorkflow { class IOSWorkflowTestTarget extends IOSWorkflow {
@override @override
...@@ -142,4 +162,7 @@ class IOSWorkflowTestTarget extends IOSWorkflow { ...@@ -142,4 +162,7 @@ class IOSWorkflowTestTarget extends IOSWorkflow {
@override @override
String iosDeployVersionText = '1.9.0'; String iosDeployVersionText = '1.9.0';
@override
bool get hasIDeviceInstaller => 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