Commit 91f7902a authored by Jenn Magder's avatar Jenn Magder Committed by Flutter GitHub Bot

Move Xcode context fetch to global.dart (#49458)

parent 2042c7d5
...@@ -244,12 +244,12 @@ class AOTSnapshotter { ...@@ -244,12 +244,12 @@ class AOTSnapshotter {
final String assemblyO = globals.fs.path.join(outputPath, 'snapshot_assembly.o'); final String assemblyO = globals.fs.path.join(outputPath, 'snapshot_assembly.o');
List<String> isysrootArgs; List<String> isysrootArgs;
if (isIOS) { if (isIOS) {
final String iPhoneSDKLocation = await xcode.sdkLocation(SdkType.iPhone); final String iPhoneSDKLocation = await globals.xcode.sdkLocation(SdkType.iPhone);
if (iPhoneSDKLocation != null) { if (iPhoneSDKLocation != null) {
isysrootArgs = <String>['-isysroot', iPhoneSDKLocation]; isysrootArgs = <String>['-isysroot', iPhoneSDKLocation];
} }
} }
final RunResult compileResult = await xcode.cc(<String>[ final RunResult compileResult = await globals.xcode.cc(<String>[
'-arch', targetArch, '-arch', targetArch,
if (isysrootArgs != null) ...isysrootArgs, if (isysrootArgs != null) ...isysrootArgs,
if (bitcode) embedBitcodeArg, if (bitcode) embedBitcodeArg,
...@@ -277,7 +277,7 @@ class AOTSnapshotter { ...@@ -277,7 +277,7 @@ class AOTSnapshotter {
'-o', appLib, '-o', appLib,
assemblyO, assemblyO,
]; ];
final RunResult linkResult = await xcode.clang(linkArgs); final RunResult linkResult = await globals.xcode.clang(linkArgs);
if (linkResult.exitCode != 0) { if (linkResult.exitCode != 0) {
globals.printError('Failed to link AOT snapshot. Linker terminated with exit code ${compileResult.exitCode}'); globals.printError('Failed to link AOT snapshot. Linker terminated with exit code ${compileResult.exitCode}');
} }
......
...@@ -179,7 +179,7 @@ Future<RunResult> createStubAppFramework(File outputFile, SdkType sdk) async { ...@@ -179,7 +179,7 @@ Future<RunResult> createStubAppFramework(File outputFile, SdkType sdk) async {
]; ];
} }
return await xcode.clang(<String>[ return await globals.xcode.clang(<String>[
'-x', '-x',
'c', 'c',
...archFlags, ...archFlags,
...@@ -189,7 +189,7 @@ Future<RunResult> createStubAppFramework(File outputFile, SdkType sdk) async { ...@@ -189,7 +189,7 @@ Future<RunResult> createStubAppFramework(File outputFile, SdkType sdk) async {
'-Xlinker', '-rpath', '-Xlinker', '@executable_path/Frameworks', '-Xlinker', '-rpath', '-Xlinker', '@executable_path/Frameworks',
'-Xlinker', '-rpath', '-Xlinker', '@loader_path/Frameworks', '-Xlinker', '-rpath', '-Xlinker', '@loader_path/Frameworks',
'-install_name', '@rpath/App.framework/App', '-install_name', '@rpath/App.framework/App',
'-isysroot', await xcode.sdkLocation(sdk), '-isysroot', await globals.xcode.sdkLocation(sdk),
'-o', outputFile.path, '-o', outputFile.path,
]); ]);
} finally { } finally {
......
...@@ -9,7 +9,6 @@ import '../../base/io.dart'; ...@@ -9,7 +9,6 @@ import '../../base/io.dart';
import '../../base/process.dart'; import '../../base/process.dart';
import '../../build_info.dart'; import '../../build_info.dart';
import '../../globals.dart' as globals; import '../../globals.dart' as globals;
import '../../macos/xcode.dart';
import '../build_system.dart'; import '../build_system.dart';
import '../depfile.dart'; import '../depfile.dart';
import '../exceptions.dart'; import '../exceptions.dart';
...@@ -155,7 +154,7 @@ class DebugMacOSFramework extends Target { ...@@ -155,7 +154,7 @@ class DebugMacOSFramework extends Target {
..writeAsStringSync(r''' ..writeAsStringSync(r'''
static const int Moo = 88; static const int Moo = 88;
'''); ''');
final RunResult result = await xcode.clang(<String>[ final RunResult result = await globals.xcode.clang(<String>[
'-x', '-x',
'c', 'c',
debugApp.path, debugApp.path,
......
...@@ -127,7 +127,7 @@ class BuildIOSFrameworkCommand extends BuildSubCommand { ...@@ -127,7 +127,7 @@ class BuildIOSFrameworkCommand extends BuildSubCommand {
if (!boolArg('universal') && !boolArg('xcframework')) { if (!boolArg('universal') && !boolArg('xcframework')) {
throwToolExit('--universal or --xcframework is required.'); throwToolExit('--universal or --xcframework is required.');
} }
if (boolArg('xcframework') && xcode.majorVersion < 11) { if (boolArg('xcframework') && globals.xcode.majorVersion < 11) {
throwToolExit('--xcframework requires Xcode 11.'); throwToolExit('--xcframework requires Xcode 11.');
} }
if (buildModes.isEmpty) { if (buildModes.isEmpty) {
......
...@@ -11,7 +11,6 @@ import '../base/logger.dart'; ...@@ -11,7 +11,6 @@ import '../base/logger.dart';
import '../build_info.dart'; import '../build_info.dart';
import '../globals.dart' as globals; import '../globals.dart' as globals;
import '../ios/xcodeproj.dart'; import '../ios/xcodeproj.dart';
import '../macos/xcode.dart';
import '../project.dart'; import '../project.dart';
import '../runner/flutter_command.dart'; import '../runner/flutter_command.dart';
...@@ -34,7 +33,7 @@ class CleanCommand extends FlutterCommand { ...@@ -34,7 +33,7 @@ class CleanCommand extends FlutterCommand {
// Clean Xcode to remove intermediate DerivedData artifacts. // Clean Xcode to remove intermediate DerivedData artifacts.
// Do this before removing ephemeral directory, which would delete the xcworkspace. // Do this before removing ephemeral directory, which would delete the xcworkspace.
final FlutterProject flutterProject = FlutterProject.current(); final FlutterProject flutterProject = FlutterProject.current();
if (xcode.isInstalledAndMeetsVersionCheck) { if (globals.xcode.isInstalledAndMeetsVersionCheck) {
await _cleanXcode(flutterProject.ios); await _cleanXcode(flutterProject.ios);
await _cleanXcode(flutterProject.macos); await _cleanXcode(flutterProject.macos);
} }
......
...@@ -14,6 +14,7 @@ import 'base/io.dart'; ...@@ -14,6 +14,7 @@ import 'base/io.dart';
import 'base/logger.dart'; import 'base/logger.dart';
import 'base/terminal.dart'; import 'base/terminal.dart';
import 'cache.dart'; import 'cache.dart';
import 'macos/xcode.dart';
Logger get logger => context.get<Logger>(); Logger get logger => context.get<Logger>();
Cache get cache => context.get<Cache>(); Cache get cache => context.get<Cache>();
...@@ -40,6 +41,7 @@ const Platform _kLocalPlatform = LocalPlatform(); ...@@ -40,6 +41,7 @@ const Platform _kLocalPlatform = LocalPlatform();
Platform get platform => context.get<Platform>() ?? _kLocalPlatform; Platform get platform => context.get<Platform>() ?? _kLocalPlatform;
Xcode get xcode => context.get<Xcode>();
/// Display an error level message to the user. Commands should use this if they /// Display an error level message to the user. Commands should use this if they
/// fail in some way. /// fail in some way.
......
...@@ -8,7 +8,6 @@ import '../base/process.dart'; ...@@ -8,7 +8,6 @@ import '../base/process.dart';
import '../device.dart'; import '../device.dart';
import '../emulator.dart'; import '../emulator.dart';
import '../globals.dart' as globals; import '../globals.dart' as globals;
import '../macos/xcode.dart';
import 'ios_workflow.dart'; import 'ios_workflow.dart';
import 'simulators.dart'; import 'simulators.dart';
...@@ -45,7 +44,7 @@ class IOSEmulator extends Emulator { ...@@ -45,7 +44,7 @@ class IOSEmulator extends Emulator {
'open', 'open',
...additionalArgs, ...additionalArgs,
'-a', '-a',
xcode.getSimulatorPath(), globals.xcode.getSimulatorPath(),
]; ];
final RunResult launchResult = await processUtils.run(args); final RunResult launchResult = await processUtils.run(args);
...@@ -69,7 +68,7 @@ class IOSEmulator extends Emulator { ...@@ -69,7 +68,7 @@ class IOSEmulator extends Emulator {
/// Return the list of iOS Simulators (there can only be zero or one). /// Return the list of iOS Simulators (there can only be zero or one).
List<IOSEmulator> getEmulators() { List<IOSEmulator> getEmulators() {
final String simulatorPath = xcode.getSimulatorPath(); final String simulatorPath = globals.xcode.getSimulatorPath();
if (simulatorPath == null) { if (simulatorPath == null) {
return <IOSEmulator>[]; return <IOSEmulator>[];
} }
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
import '../base/context.dart'; import '../base/context.dart';
import '../doctor.dart'; import '../doctor.dart';
import '../globals.dart' as globals; import '../globals.dart' as globals;
import '../macos/xcode.dart';
IOSWorkflow get iosWorkflow => context.get<IOSWorkflow>(); IOSWorkflow get iosWorkflow => context.get<IOSWorkflow>();
...@@ -17,12 +16,12 @@ class IOSWorkflow implements Workflow { ...@@ -17,12 +16,12 @@ class IOSWorkflow implements Workflow {
// We need xcode (+simctl) to list simulator devices, and libimobiledevice to list real devices. // We need xcode (+simctl) to list simulator devices, and libimobiledevice to list real devices.
@override @override
bool get canListDevices => xcode.isInstalledAndMeetsVersionCheck && xcode.isSimctlInstalled; bool get canListDevices => globals.xcode.isInstalledAndMeetsVersionCheck && globals.xcode.isSimctlInstalled;
// We need xcode to launch simulator devices, and ideviceinstaller and ios-deploy // We need xcode to launch simulator devices, and ideviceinstaller and ios-deploy
// for real devices. // for real devices.
@override @override
bool get canLaunchDevices => xcode.isInstalledAndMeetsVersionCheck; bool get canLaunchDevices => globals.xcode.isInstalledAndMeetsVersionCheck;
@override @override
bool get canListEmulators => false; bool get canListEmulators => false;
......
...@@ -717,7 +717,7 @@ bool _checkXcodeVersion() { ...@@ -717,7 +717,7 @@ bool _checkXcodeVersion() {
globals.printError('Cannot find "xcodebuild". $_xcodeRequirement'); globals.printError('Cannot find "xcodebuild". $_xcodeRequirement');
return false; return false;
} }
if (!xcode.isVersionSatisfactory) { if (!globals.xcode.isVersionSatisfactory) {
globals.printError('Found "${xcodeProjectInterpreter.versionText}". $_xcodeRequirement'); globals.printError('Found "${xcodeProjectInterpreter.versionText}". $_xcodeRequirement');
return false; return false;
} }
......
...@@ -19,7 +19,6 @@ import '../bundle.dart'; ...@@ -19,7 +19,6 @@ import '../bundle.dart';
import '../convert.dart'; import '../convert.dart';
import '../device.dart'; import '../device.dart';
import '../globals.dart' as globals; import '../globals.dart' as globals;
import '../macos/xcode.dart';
import '../project.dart'; import '../project.dart';
import '../protocol_discovery.dart'; import '../protocol_discovery.dart';
import 'ios_workflow.dart'; import 'ios_workflow.dart';
...@@ -47,7 +46,7 @@ class IOSSimulatorUtils { ...@@ -47,7 +46,7 @@ class IOSSimulatorUtils {
static IOSSimulatorUtils get instance => context.get<IOSSimulatorUtils>(); static IOSSimulatorUtils get instance => context.get<IOSSimulatorUtils>();
Future<List<IOSSimulator>> getAttachedDevices() async { Future<List<IOSSimulator>> getAttachedDevices() async {
if (!xcode.isInstalledAndMeetsVersionCheck) { if (!globals.xcode.isInstalledAndMeetsVersionCheck) {
return <IOSSimulator>[]; return <IOSSimulator>[];
} }
...@@ -519,7 +518,7 @@ class IOSSimulator extends Device { ...@@ -519,7 +518,7 @@ class IOSSimulator extends Device {
} }
bool get _xcodeVersionSupportsScreenshot { bool get _xcodeVersionSupportsScreenshot {
return xcode.majorVersion > 8 || (xcode.majorVersion == 8 && xcode.minorVersion >= 2); return globals.xcode.majorVersion > 8 || (globals.xcode.majorVersion == 8 && globals.xcode.minorVersion >= 2);
} }
@override @override
......
...@@ -9,7 +9,6 @@ import 'package:platform/platform.dart'; ...@@ -9,7 +9,6 @@ import 'package:platform/platform.dart';
import 'package:process/process.dart'; import 'package:process/process.dart';
import '../base/common.dart'; import '../base/common.dart';
import '../base/context.dart';
import '../base/file_system.dart'; import '../base/file_system.dart';
import '../base/io.dart'; import '../base/io.dart';
import '../base/logger.dart'; import '../base/logger.dart';
...@@ -19,8 +18,6 @@ import '../ios/xcodeproj.dart'; ...@@ -19,8 +18,6 @@ import '../ios/xcodeproj.dart';
const int kXcodeRequiredVersionMajor = 10; const int kXcodeRequiredVersionMajor = 10;
const int kXcodeRequiredVersionMinor = 2; const int kXcodeRequiredVersionMinor = 2;
Xcode get xcode => context.get<Xcode>();
enum SdkType { enum SdkType {
iPhone, iPhone,
iPhoneSimulator, iPhoneSimulator,
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
import '../base/context.dart'; import '../base/context.dart';
import '../base/user_messages.dart'; import '../base/user_messages.dart';
import '../doctor.dart'; import '../doctor.dart';
import '../globals.dart' as globals;
import 'xcode.dart'; import 'xcode.dart';
XcodeValidator get xcodeValidator => context.get<XcodeValidator>(); XcodeValidator get xcodeValidator => context.get<XcodeValidator>();
...@@ -18,36 +19,36 @@ class XcodeValidator extends DoctorValidator { ...@@ -18,36 +19,36 @@ class XcodeValidator extends DoctorValidator {
ValidationType xcodeStatus = ValidationType.missing; ValidationType xcodeStatus = ValidationType.missing;
String xcodeVersionInfo; String xcodeVersionInfo;
if (xcode.isInstalled) { if (globals.xcode.isInstalled) {
xcodeStatus = ValidationType.installed; xcodeStatus = ValidationType.installed;
messages.add(ValidationMessage(userMessages.xcodeLocation(xcode.xcodeSelectPath))); messages.add(ValidationMessage(userMessages.xcodeLocation(globals.xcode.xcodeSelectPath)));
xcodeVersionInfo = xcode.versionText; xcodeVersionInfo = globals.xcode.versionText;
if (xcodeVersionInfo.contains(',')) { if (xcodeVersionInfo.contains(',')) {
xcodeVersionInfo = xcodeVersionInfo.substring(0, xcodeVersionInfo.indexOf(',')); xcodeVersionInfo = xcodeVersionInfo.substring(0, xcodeVersionInfo.indexOf(','));
} }
messages.add(ValidationMessage(xcode.versionText)); messages.add(ValidationMessage(globals.xcode.versionText));
if (!xcode.isInstalledAndMeetsVersionCheck) { if (!globals.xcode.isInstalledAndMeetsVersionCheck) {
xcodeStatus = ValidationType.partial; xcodeStatus = ValidationType.partial;
messages.add(ValidationMessage.error( messages.add(ValidationMessage.error(
userMessages.xcodeOutdated(kXcodeRequiredVersionMajor, kXcodeRequiredVersionMinor) userMessages.xcodeOutdated(kXcodeRequiredVersionMajor, kXcodeRequiredVersionMinor)
)); ));
} }
if (!xcode.eulaSigned) { if (!globals.xcode.eulaSigned) {
xcodeStatus = ValidationType.partial; xcodeStatus = ValidationType.partial;
messages.add(ValidationMessage.error(userMessages.xcodeEula)); messages.add(ValidationMessage.error(userMessages.xcodeEula));
} }
if (!xcode.isSimctlInstalled) { if (!globals.xcode.isSimctlInstalled) {
xcodeStatus = ValidationType.partial; xcodeStatus = ValidationType.partial;
messages.add(ValidationMessage.error(userMessages.xcodeMissingSimct)); messages.add(ValidationMessage.error(userMessages.xcodeMissingSimct));
} }
} else { } else {
xcodeStatus = ValidationType.missing; xcodeStatus = ValidationType.missing;
if (xcode.xcodeSelectPath == null || xcode.xcodeSelectPath.isEmpty) { if (globals.xcode.xcodeSelectPath == null || globals.xcode.xcodeSelectPath.isEmpty) {
messages.add(ValidationMessage.error(userMessages.xcodeMissing)); messages.add(ValidationMessage.error(userMessages.xcodeMissing));
} else { } else {
messages.add(ValidationMessage.error(userMessages.xcodeIncomplete)); messages.add(ValidationMessage.error(userMessages.xcodeIncomplete));
......
...@@ -308,8 +308,8 @@ void main() { ...@@ -308,8 +308,8 @@ void main() {
}; };
final RunResult successResult = RunResult(ProcessResult(1, 0, '', ''), <String>['command name', 'arguments...']); final RunResult successResult = RunResult(ProcessResult(1, 0, '', ''), <String>['command name', 'arguments...']);
when(xcode.cc(any)).thenAnswer((_) => Future<RunResult>.value(successResult)); when(mockXcode.cc(any)).thenAnswer((_) => Future<RunResult>.value(successResult));
when(xcode.clang(any)).thenAnswer((_) => Future<RunResult>.value(successResult)); when(mockXcode.clang(any)).thenAnswer((_) => Future<RunResult>.value(successResult));
final int genSnapshotExitCode = await snapshotter.build( final int genSnapshotExitCode = await snapshotter.build(
platform: TargetPlatform.ios, platform: TargetPlatform.ios,
...@@ -334,14 +334,14 @@ void main() { ...@@ -334,14 +334,14 @@ void main() {
'main.dill', 'main.dill',
]); ]);
final VerificationResult toVerifyCC = verify(xcode.cc(captureAny)); final VerificationResult toVerifyCC = verify(mockXcode.cc(captureAny));
expect(toVerifyCC.callCount, 1); expect(toVerifyCC.callCount, 1);
final dynamic ccArgs = toVerifyCC.captured.first; final dynamic ccArgs = toVerifyCC.captured.first;
expect(ccArgs, contains('-fembed-bitcode')); expect(ccArgs, contains('-fembed-bitcode'));
expect(ccArgs, contains('-isysroot')); expect(ccArgs, contains('-isysroot'));
expect(ccArgs, contains(kSDKPath)); expect(ccArgs, contains(kSDKPath));
final VerificationResult toVerifyClang = verify(xcode.clang(captureAny)); final VerificationResult toVerifyClang = verify(mockXcode.clang(captureAny));
expect(toVerifyClang.callCount, 1); expect(toVerifyClang.callCount, 1);
final dynamic clangArgs = toVerifyClang.captured.first; final dynamic clangArgs = toVerifyClang.captured.first;
expect(clangArgs, contains('-fembed-bitcode')); expect(clangArgs, contains('-fembed-bitcode'));
...@@ -365,8 +365,8 @@ void main() { ...@@ -365,8 +365,8 @@ void main() {
}; };
final RunResult successResult = RunResult(ProcessResult(1, 0, '', ''), <String>['command name', 'arguments...']); final RunResult successResult = RunResult(ProcessResult(1, 0, '', ''), <String>['command name', 'arguments...']);
when(xcode.cc(any)).thenAnswer((_) => Future<RunResult>.value(successResult)); when(mockXcode.cc(any)).thenAnswer((_) => Future<RunResult>.value(successResult));
when(xcode.clang(any)).thenAnswer((_) => Future<RunResult>.value(successResult)); when(mockXcode.clang(any)).thenAnswer((_) => Future<RunResult>.value(successResult));
final int genSnapshotExitCode = await snapshotter.build( final int genSnapshotExitCode = await snapshotter.build(
platform: TargetPlatform.ios, platform: TargetPlatform.ios,
...@@ -391,14 +391,14 @@ void main() { ...@@ -391,14 +391,14 @@ void main() {
'main.dill', 'main.dill',
]); ]);
final VerificationResult toVerifyCC = verify(xcode.cc(captureAny)); final VerificationResult toVerifyCC = verify(mockXcode.cc(captureAny));
expect(toVerifyCC.callCount, 1); expect(toVerifyCC.callCount, 1);
final dynamic ccArgs = toVerifyCC.captured.first; final dynamic ccArgs = toVerifyCC.captured.first;
expect(ccArgs, contains('-fembed-bitcode')); expect(ccArgs, contains('-fembed-bitcode'));
expect(ccArgs, contains('-isysroot')); expect(ccArgs, contains('-isysroot'));
expect(ccArgs, contains(kSDKPath)); expect(ccArgs, contains(kSDKPath));
final VerificationResult toVerifyClang = verify(xcode.clang(captureAny)); final VerificationResult toVerifyClang = verify(mockXcode.clang(captureAny));
expect(toVerifyClang.callCount, 1); expect(toVerifyClang.callCount, 1);
final dynamic clangArgs = toVerifyClang.captured.first; final dynamic clangArgs = toVerifyClang.captured.first;
expect(clangArgs, contains('-fembed-bitcode')); expect(clangArgs, contains('-fembed-bitcode'));
...@@ -425,8 +425,8 @@ void main() { ...@@ -425,8 +425,8 @@ void main() {
}; };
final RunResult successResult = RunResult(ProcessResult(1, 0, '', ''), <String>['command name', 'arguments...']); final RunResult successResult = RunResult(ProcessResult(1, 0, '', ''), <String>['command name', 'arguments...']);
when(xcode.cc(any)).thenAnswer((_) => Future<RunResult>.value(successResult)); when(mockXcode.cc(any)).thenAnswer((_) => Future<RunResult>.value(successResult));
when(xcode.clang(any)).thenAnswer((_) => Future<RunResult>.value(successResult)); when(mockXcode.clang(any)).thenAnswer((_) => Future<RunResult>.value(successResult));
final int genSnapshotExitCode = await snapshotter.build( final int genSnapshotExitCode = await snapshotter.build(
platform: TargetPlatform.ios, platform: TargetPlatform.ios,
...@@ -450,11 +450,11 @@ void main() { ...@@ -450,11 +450,11 @@ void main() {
'--no-use-integer-division', '--no-use-integer-division',
'main.dill', 'main.dill',
]); ]);
verifyNever(xcode.cc(argThat(contains('-fembed-bitcode')))); verifyNever(mockXcode.cc(argThat(contains('-fembed-bitcode'))));
verifyNever(xcode.clang(argThat(contains('-fembed-bitcode')))); verifyNever(mockXcode.clang(argThat(contains('-fembed-bitcode'))));
verify(xcode.cc(argThat(contains('-isysroot')))).called(1); verify(mockXcode.cc(argThat(contains('-isysroot')))).called(1);
verify(xcode.clang(argThat(contains('-isysroot')))).called(1); verify(mockXcode.clang(argThat(contains('-isysroot')))).called(1);
final File assemblyFile = globals.fs.file(assembly); final File assemblyFile = globals.fs.file(assembly);
expect(assemblyFile.existsSync(), true); expect(assemblyFile.existsSync(), true);
...@@ -472,8 +472,8 @@ void main() { ...@@ -472,8 +472,8 @@ void main() {
}; };
final RunResult successResult = RunResult(ProcessResult(1, 0, '', ''), <String>['command name', 'arguments...']); final RunResult successResult = RunResult(ProcessResult(1, 0, '', ''), <String>['command name', 'arguments...']);
when(xcode.cc(any)).thenAnswer((_) => Future<RunResult>.value(successResult)); when(mockXcode.cc(any)).thenAnswer((_) => Future<RunResult>.value(successResult));
when(xcode.clang(any)).thenAnswer((_) => Future<RunResult>.value(successResult)); when(mockXcode.clang(any)).thenAnswer((_) => Future<RunResult>.value(successResult));
final int genSnapshotExitCode = await snapshotter.build( final int genSnapshotExitCode = await snapshotter.build(
platform: TargetPlatform.ios, platform: TargetPlatform.ios,
...@@ -508,8 +508,8 @@ void main() { ...@@ -508,8 +508,8 @@ void main() {
}; };
final RunResult successResult = RunResult(ProcessResult(1, 0, '', ''), <String>['command name', 'arguments...']); final RunResult successResult = RunResult(ProcessResult(1, 0, '', ''), <String>['command name', 'arguments...']);
when(xcode.cc(any)).thenAnswer((_) => Future<RunResult>.value(successResult)); when(mockXcode.cc(any)).thenAnswer((_) => Future<RunResult>.value(successResult));
when(xcode.clang(any)).thenAnswer((_) => Future<RunResult>.value(successResult)); when(mockXcode.clang(any)).thenAnswer((_) => Future<RunResult>.value(successResult));
final int genSnapshotExitCode = await snapshotter.build( final int genSnapshotExitCode = await snapshotter.build(
platform: TargetPlatform.ios, platform: TargetPlatform.ios,
...@@ -546,8 +546,8 @@ void main() { ...@@ -546,8 +546,8 @@ void main() {
}; };
final RunResult successResult = RunResult(ProcessResult(1, 0, '', ''), <String>['command name', 'arguments...']); final RunResult successResult = RunResult(ProcessResult(1, 0, '', ''), <String>['command name', 'arguments...']);
when(xcode.cc(any)).thenAnswer((_) => Future<RunResult>.value(successResult)); when(mockXcode.cc(any)).thenAnswer((_) => Future<RunResult>.value(successResult));
when(xcode.clang(any)).thenAnswer((_) => Future<RunResult>.value(successResult)); when(mockXcode.clang(any)).thenAnswer((_) => Future<RunResult>.value(successResult));
final int genSnapshotExitCode = await snapshotter.build( final int genSnapshotExitCode = await snapshotter.build(
platform: TargetPlatform.ios, platform: TargetPlatform.ios,
...@@ -640,8 +640,8 @@ void main() { ...@@ -640,8 +640,8 @@ void main() {
}; };
final RunResult successResult = RunResult(ProcessResult(1, 0, '', ''), <String>['command name', 'arguments...']); final RunResult successResult = RunResult(ProcessResult(1, 0, '', ''), <String>['command name', 'arguments...']);
when(xcode.cc(any)).thenAnswer((_) => Future<RunResult>.value(successResult)); when(mockXcode.cc(any)).thenAnswer((_) => Future<RunResult>.value(successResult));
when(xcode.clang(any)).thenAnswer((_) => Future<RunResult>.value(successResult)); when(mockXcode.clang(any)).thenAnswer((_) => Future<RunResult>.value(successResult));
final int genSnapshotExitCode = await snapshotterWithTimings.build( final int genSnapshotExitCode = await snapshotterWithTimings.build(
platform: TargetPlatform.android_arm, platform: TargetPlatform.android_arm,
......
...@@ -49,6 +49,7 @@ void main() { ...@@ -49,6 +49,7 @@ void main() {
Testbed testbed; Testbed testbed;
Environment environment; Environment environment;
MockPlatform mockPlatform; MockPlatform mockPlatform;
MockXcode mockXcode;
setUpAll(() { setUpAll(() {
Cache.disableLocking(); Cache.disableLocking();
...@@ -56,6 +57,7 @@ void main() { ...@@ -56,6 +57,7 @@ void main() {
}); });
setUp(() { setUp(() {
mockXcode = MockXcode();
mockPlatform = MockPlatform(); mockPlatform = MockPlatform();
when(mockPlatform.isWindows).thenReturn(false); when(mockPlatform.isWindows).thenReturn(false);
when(mockPlatform.isMacOS).thenReturn(true); when(mockPlatform.isMacOS).thenReturn(true);
...@@ -202,10 +204,10 @@ void main() { ...@@ -202,10 +204,10 @@ void main() {
environment.buildDir.childFile('snapshot_assembly.S').createSync(); environment.buildDir.childFile('snapshot_assembly.S').createSync();
return Future<int>.value(0); return Future<int>.value(0);
}); });
when(xcode.cc(any)).thenAnswer((Invocation invocation) { when(mockXcode.cc(any)).thenAnswer((Invocation invocation) {
return Future<RunResult>.value(RunResult(FakeProcessResult()..exitCode = 0, <String>['test'])); return Future<RunResult>.value(RunResult(FakeProcessResult()..exitCode = 0, <String>['test']));
}); });
when(xcode.clang(any)).thenAnswer((Invocation invocation) { when(mockXcode.clang(any)).thenAnswer((Invocation invocation) {
return Future<RunResult>.value(RunResult(FakeProcessResult()..exitCode = 0, <String>['test'])); return Future<RunResult>.value(RunResult(FakeProcessResult()..exitCode = 0, <String>['test']));
}); });
environment.buildDir.childFile('app.dill').createSync(recursive: true); environment.buildDir.childFile('app.dill').createSync(recursive: true);
...@@ -218,7 +220,7 @@ flutter_tools:lib/'''); ...@@ -218,7 +220,7 @@ flutter_tools:lib/''');
await const CompileMacOSFramework().build(environment..defines[kBuildMode] = 'release'); await const CompileMacOSFramework().build(environment..defines[kBuildMode] = 'release');
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
GenSnapshot: () => MockGenSnapshot(), GenSnapshot: () => MockGenSnapshot(),
Xcode: () => MockXCode(), Xcode: () => mockXcode,
})); }));
} }
...@@ -226,7 +228,7 @@ class MockPlatform extends Mock implements Platform {} ...@@ -226,7 +228,7 @@ class MockPlatform extends Mock implements Platform {}
class MockCocoaPods extends Mock implements CocoaPods {} class MockCocoaPods extends Mock implements CocoaPods {}
class MockProcessManager extends Mock implements ProcessManager {} class MockProcessManager extends Mock implements ProcessManager {}
class MockGenSnapshot extends Mock implements GenSnapshot {} class MockGenSnapshot extends Mock implements GenSnapshot {}
class MockXCode extends Mock implements Xcode {} class MockXcode extends Mock implements Xcode {}
class FakeProcessResult implements ProcessResult { class FakeProcessResult implements ProcessResult {
@override @override
int exitCode; int exitCode;
......
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