anchor.diff:  ]
   ''';
   
  -        when(processManager.run(<String>['xcrun', 'xcdevice', 'list', '--timeout', '2']))
  -          .thenAnswer((_) => Future<ProcessResult>.value(ProcessResult(1, 0, devicesOutput, '')));
  -        final List<IOSDevice> devices = await xcdevice.getAvailableTetheredIOSDevices();
  -        expect(devices[0].cpuArchitecture, DarwinArch.armv7);
  -        expect(devices[1].cpuArchitecture, DarwinArch.arm64);
  -      }, overrides: <Type, Generator>{
  -        Platform: () => macPlatform,
  -      });
  -    });
  -
  -    group('diagnostics', () {
  -      final FakePlatform macPlatform = FakePlatform(operatingSystem: 'macos');
  -
  -      testWithoutContext('Xcode not installed', () async {
  -        when(mockXcode.isInstalledAndMeetsVersionCheck).thenReturn(false);
  -
  -        expect(await xcdevice.getDiagnostics(), isEmpty);
  -        verifyNever(processManager.run(any));
  -      });
  -
  -      testWithoutContext('xcdevice fails', () async {
  -        when(mockXcode.isInstalledAndMeetsVersionCheck).thenReturn(true);
  -
  -        when(processManager.runSync(<String>['xcrun', '--find', 'xcdevice']))
  -            .thenReturn(ProcessResult(1, 0, '/path/to/xcdevice', ''));
  -
  -        when(processManager.run(<String>['xcrun', 'xcdevice', 'list', '--timeout', '2']))
  -            .thenThrow(const ProcessException('xcrun', <String>['xcdevice', 'list', '--timeout', '2']));
  -
  -        expect(await xcdevice.getDiagnostics(), isEmpty);
  -      });
  -
  -      testUsingContext('uses cache', () async {
  -        when(mockXcode.isInstalledAndMeetsVersionCheck).thenReturn(true);
  -
  -        when(processManager.runSync(<String>['xcrun', '--find', 'xcdevice']))
  -            .thenReturn(ProcessResult(1, 0, '/path/to/xcdevice', ''));
  -
  -        const String devicesOutput = '''
  +          fakeProcessManager.addCommand(const FakeCommand(
  +            command: <String>['xcrun', 'xcdevice', 'list', '--timeout', '2'],
  +            stdout: devicesOutput,
  +          ));
  +          final List<IOSDevice> devices = await xcdevice.getAvailableTetheredIOSDevices();
  +          expect(devices[0].cpuArchitecture, DarwinArch.armv7);
  +          expect(devices[1].cpuArchitecture, DarwinArch.arm64);
  +          expect(fakeProcessManager.hasRemainingExpectations, isFalse);
  +        }, overrides: <Type, Generator>{
  +          Platform: () => macPlatform,
  +        });
  +      });
  +
  +      group('diagnostics', () {
  +        final FakePlatform macPlatform = FakePlatform(operatingSystem: 'macos');
  +
  +        testWithoutContext('Xcode not installed', () async {
  +          when(mockXcode.isInstalledAndMeetsVersionCheck).thenReturn(false);
  +
  +          expect(await xcdevice.getDiagnostics(), isEmpty);
  +        });
  +
  +        testUsingContext('uses cache', () async {
  +          when(mockXcode.isInstalledAndMeetsVersionCheck).thenReturn(true);
  +          fakeProcessManager.addCommand(const FakeCommand(
  +            command: <String>['xcrun', '--find', 'xcdevice'],
  +            stdout: '/path/to/xcdevice',
  +          ));
  +
  +          const String devicesOutput = '''
   [
     {
       "simulator" : false,
  
positive.code: 
  import 'package:file/memory.dart';
  import 'package:flutter_tools/src/artifacts.dart';
  import 'package:flutter_tools/src/base/file_system.dart';
  import 'package:flutter_tools/src/base/io.dart' show ProcessException, ProcessResult;
  import 'package:flutter_tools/src/base/logger.dart';
  import 'package:flutter_tools/src/base/platform.dart';
  
negative.code: import '../../src/context.dart';
  
  void main() {
    Logger logger;
  
    setUp(() {
      logger = BufferLogger.test();
    });
  
    // Group exists to work around https://github.com/flutter/flutter/issues/56415.
    // Do not add more `MockProcessManager` tests.
    group('MockProcessManager', () {
      ProcessManager processManager;
  
      setUp(() {
        processManager = MockProcessManager();
      });
  
      group('Xcode', () {
        Xcode xcode;
  
        setUp(() {
          xcode = Xcode(
            logger: logger,
            platform: MockPlatform(),
            fileSystem: MemoryFileSystem.test(),
            processManager: processManager,
            xcodeProjectInterpreter: MockXcodeProjectInterpreter(),
          );
        });
  
        testWithoutContext('xcodeSelectPath returns null when xcode-select is not installed', () {
          when(processManager.runSync(<String>['/usr/bin/xcode-select', '--print-path']))
            .thenThrow(const ProcessException('/usr/bin/xcode-select', <String>['--print-path']));
          expect(xcode.xcodeSelectPath, isNull);
          when(processManager.runSync(<String>['/usr/bin/xcode-select', '--print-path']))
            .thenThrow(ArgumentError('Invalid argument(s): Cannot find executable for /usr/bin/xcode-select'));
  
          expect(xcode.xcodeSelectPath, isNull);
        });
  
        testWithoutContext('eulaSigned is false when clang is not installed', () {
          when(processManager.runSync(<String>['/usr/bin/xcrun', 'clang']))
            .thenThrow(const ProcessException('/usr/bin/xcrun', <String>['clang']));
  
          expect(xcode.eulaSigned, isFalse);
        });
      });
  
      group('xcdevice', () {
        XCDevice xcdevice;
        MockXcode mockXcode;
  
        setUp(() {
          mockXcode = MockXcode();
          xcdevice = XCDevice(
            processManager: processManager,
            logger: logger,
            xcode: mockXcode,
            platform: null,
            artifacts: MockArtifacts(),
            cache: MockCache(),
          );
        });
  
        testWithoutContext("xcrun can't find xcdevice", () {
          when(mockXcode.isInstalledAndMeetsVersionCheck).thenReturn(true);
  
          when(processManager.runSync(<String>['xcrun', '--find', 'xcdevice']))
            .thenThrow(const ProcessException('xcrun', <String>['--find', 'xcdevice']));
          expect(xcdevice.isInstalled, false);
          verify(processManager.runSync(any)).called(1);
        });
  
        testWithoutContext('available devices xcdevice fails', () async {
          when(mockXcode.isInstalledAndMeetsVersionCheck).thenReturn(true);
  
          when(processManager.runSync(<String>['xcrun', '--find', 'xcdevice']))
            .thenReturn(ProcessResult(1, 0, '/path/to/xcdevice', ''));
  
          when(processManager.run(<String>['xcrun', 'xcdevice', 'list', '--timeout', '2']))
            .thenThrow(const ProcessException('xcrun', <String>['xcdevice', 'list', '--timeout', '2']));
  
          expect(await xcdevice.getAvailableTetheredIOSDevices(), isEmpty);
        });
  
        testWithoutContext('diagnostics xcdevice fails', () async {
          when(mockXcode.isInstalledAndMeetsVersionCheck).thenReturn(true);
  
          when(processManager.runSync(<String>['xcrun', '--find', 'xcdevice']))
            .thenReturn(ProcessResult(1, 0, '/path/to/xcdevice', ''));
  
          when(processManager.run(<String>['xcrun', 'xcdevice', 'list', '--timeout', '2']))
            .thenThrow(const ProcessException('xcrun', <String>['xcdevice', 'list', '--timeout', '2']));
  
          expect(await xcdevice.getDiagnostics(), isEmpty);
        });
      });
    });
  
    group('FakeProcessManager', () {
      FakeProcessManager fakeProcessManager;
  
      setUp(() {
        fakeProcessManager = FakeProcessManager.list(<FakeCommand>[]);
      });
  
      group('Xcode', () {
        Xcode xcode;
        MockXcodeProjectInterpreter mockXcodeProjectInterpreter;
        MockPlatform platform;
  
        setUp(() {
          mockXcodeProjectInterpreter = MockXcodeProjectInterpreter();
          platform = MockPlatform();
          xcode = Xcode(
            logger: logger,
            platform: platform,
            fileSystem: MemoryFileSystem.test(),
            processManager: fakeProcessManager,
            xcodeProjectInterpreter: mockXcodeProjectInterpreter,
          );
        });
  
        testWithoutContext('xcodeSelectPath returns path when xcode-select is installed', () {
          const String xcodePath = '/Applications/Xcode8.0.app/Contents/Developer';
          fakeProcessManager.addCommand(const FakeCommand(
            command: <String>['/usr/bin/xcode-select', '--print-path'],
            stdout: xcodePath,
          ));
  
          expect(xcode.xcodeSelectPath, xcodePath);
          expect(fakeProcessManager.hasRemainingExpectations, isFalse);
        });
  
        testWithoutContext('xcodeVersionSatisfactory is false when version is less than minimum', () {
          when(mockXcodeProjectInterpreter.isInstalled).thenReturn(true);
          when(mockXcodeProjectInterpreter.majorVersion).thenReturn(9);
          when(mockXcodeProjectInterpreter.minorVersion).thenReturn(0);
  
          expect(xcode.isVersionSatisfactory, isFalse);
        });
  
        testWithoutContext('xcodeVersionSatisfactory is false when xcodebuild tools are not installed', () {
          when(mockXcodeProjectInterpreter.isInstalled).thenReturn(false);
  
          expect(xcode.isVersionSatisfactory, isFalse);
        });
  
        testWithoutContext('xcodeVersionSatisfactory is true when version meets minimum', () {
          when(mockXcodeProjectInterpreter.isInstalled).thenReturn(true);
          when(mockXcodeProjectInterpreter.majorVersion).thenReturn(11);
          when(mockXcodeProjectInterpreter.minorVersion).thenReturn(0);
  
          expect(xcode.isVersionSatisfactory, isTrue);
        });
  
        testWithoutContext('xcodeVersionSatisfactory is true when major version exceeds minimum', () {
          when(mockXcodeProjectInterpreter.isInstalled).thenReturn(true);
          when(mockXcodeProjectInterpreter.majorVersion).thenReturn(12);
          when(mockXcodeProjectInterpreter.minorVersion).thenReturn(0);
  
          expect(xcode.isVersionSatisfactory, isTrue);
        });
  
        testWithoutContext('xcodeVersionSatisfactory is true when minor version exceeds minimum', () {
          when(mockXcodeProjectInterpreter.isInstalled).thenReturn(true);
          when(mockXcodeProjectInterpreter.majorVersion).thenReturn(11);
          when(mockXcodeProjectInterpreter.minorVersion).thenReturn(3);
  
          expect(xcode.isVersionSatisfactory, isTrue);
        });
  
        testWithoutContext('isInstalledAndMeetsVersionCheck is false when not macOS', () {
          when(platform.isMacOS).thenReturn(false);
  
          expect(xcode.isInstalledAndMeetsVersionCheck, isFalse);
        });
  
        testWithoutContext('isInstalledAndMeetsVersionCheck is false when not installed', () {
          when(platform.isMacOS).thenReturn(true);
          fakeProcessManager.addCommand(const FakeCommand(
            command: <String>['/usr/bin/xcode-select', '--print-path'],
            stdout: '/Applications/Xcode8.0.app/Contents/Developer',
          ));
          when(mockXcodeProjectInterpreter.isInstalled).thenReturn(false);
  
          expect(xcode.isInstalledAndMeetsVersionCheck, isFalse);
          expect(fakeProcessManager.hasRemainingExpectations, isFalse);
        });
  
        testWithoutContext('isInstalledAndMeetsVersionCheck is false when no xcode-select', () {
          when(platform.isMacOS).thenReturn(true);
          fakeProcessManager.addCommand(const FakeCommand(
            command: <String>['/usr/bin/xcode-select', '--print-path'],
            exitCode: 127,
            stderr: 'ERROR',
          ));
          when(mockXcodeProjectInterpreter.isInstalled).thenReturn(true);
          when(mockXcodeProjectInterpreter.majorVersion).thenReturn(11);
          when(mockXcodeProjectInterpreter.minorVersion).thenReturn(0);
  
          expect(xcode.isInstalledAndMeetsVersionCheck, isFalse);
          expect(fakeProcessManager.hasRemainingExpectations, isFalse);
        });
  
        testWithoutContext('isInstalledAndMeetsVersionCheck is false when version not satisfied', () {
          when(platform.isMacOS).thenReturn(true);
          fakeProcessManager.addCommand(const FakeCommand(
            command: <String>['/usr/bin/xcode-select', '--print-path'],
            stdout: '/Applications/Xcode8.0.app/Contents/Developer',
          ));
          when(mockXcodeProjectInterpreter.isInstalled).thenReturn(true);
          when(mockXcodeProjectInterpreter.majorVersion).thenReturn(10);
          when(mockXcodeProjectInterpreter.minorVersion).thenReturn(2);
  
          expect(xcode.isInstalledAndMeetsVersionCheck, isFalse);
          expect(fakeProcessManager.hasRemainingExpectations, isFalse);
        });
  
        testWithoutContext('isInstalledAndMeetsVersionCheck is true when macOS and installed and version is satisfied', () {
          when(platform.isMacOS).thenReturn(true);
          fakeProcessManager.addCommand(const FakeCommand(
            command: <String>['/usr/bin/xcode-select', '--print-path'],
            stdout: '/Applications/Xcode8.0.app/Contents/Developer',
          ));
          when(mockXcodeProjectInterpreter.isInstalled).thenReturn(true);
          when(mockXcodeProjectInterpreter.majorVersion).thenReturn(11);
          when(mockXcodeProjectInterpreter.minorVersion).thenReturn(0);
  
          expect(xcode.isInstalledAndMeetsVersionCheck, isTrue);
          expect(fakeProcessManager.hasRemainingExpectations, isFalse);
        });
  
        testWithoutContext('eulaSigned is false when clang output indicates EULA not yet accepted', () {
          fakeProcessManager.addCommand(const FakeCommand(
            command: <String>['/usr/bin/xcrun', 'clang'],
            exitCode: 1,
            stderr: 'Xcode EULA has not been accepted.\nLaunch Xcode and accept the license.',
          ));
  
          expect(xcode.eulaSigned, isFalse);
          expect(fakeProcessManager.hasRemainingExpectations, isFalse);
        });
  
        testWithoutContext('eulaSigned is true when clang output indicates EULA has been accepted', () {
          fakeProcessManager.addCommand(const FakeCommand(
            command: <String>['/usr/bin/xcrun', 'clang'],
            exitCode: 1,
            stderr: 'clang: error: no input files',
          ));
  
          expect(xcode.eulaSigned, isTrue);
          expect(fakeProcessManager.hasRemainingExpectations, isFalse);
        });
  
        testWithoutContext('SDK name', () {
          expect(getNameForSdk(SdkType.iPhone), 'iphoneos');
          expect(getNameForSdk(SdkType.iPhoneSimulator), 'iphonesimulator');
          expect(getNameForSdk(SdkType.macOS), 'macosx');
        });
  
        group('SDK location', () {
          const String sdkroot = 'Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.2.sdk';
  
          testWithoutContext('--show-sdk-path iphoneos', () async {
            fakeProcessManager.addCommand(const FakeCommand(
              command: <String>['xcrun', '--sdk', 'iphoneos', '--show-sdk-path'],
              stdout: sdkroot,
            ));
  
            expect(await xcode.sdkLocation(SdkType.iPhone), sdkroot);
            expect(fakeProcessManager.hasRemainingExpectations, isFalse);
          });
  
          testWithoutContext('--show-sdk-path macosx', () async {
            fakeProcessManager.addCommand(const FakeCommand(
              command: <String>['xcrun', '--sdk', 'macosx', '--show-sdk-path'],
              stdout: sdkroot,
            ));
  
            expect(await xcode.sdkLocation(SdkType.macOS), sdkroot);
            expect(fakeProcessManager.hasRemainingExpectations, isFalse);
          });
  
          testWithoutContext('--show-sdk-path fails', () async {
            fakeProcessManager.addCommand(const FakeCommand(
              command: <String>['xcrun', '--sdk', 'iphoneos', '--show-sdk-path'],
              exitCode: 1,
              stderr: 'xcrun: error:',
            ));
  
            expect(() async => await xcode.sdkLocation(SdkType.iPhone),
              throwsToolExit(message: 'Could not find SDK location'));
            expect(fakeProcessManager.hasRemainingExpectations, isFalse);
          });
        });
      });
  
      group('xcdevice', () {
        XCDevice xcdevice;
        MockXcode mockXcode;
        MockArtifacts mockArtifacts;
        MockCache mockCache;
  
        setUp(() {
          mockXcode = MockXcode();
          mockArtifacts = MockArtifacts();
          mockCache = MockCache();
          xcdevice = XCDevice(
            processManager: fakeProcessManager,
            logger: logger,
            xcode: mockXcode,
            platform: null,
            artifacts: mockArtifacts,
            cache: mockCache,
          );
        });
  
        group('installed', () {
          testWithoutContext('Xcode not installed', () {
            when(mockXcode.isInstalledAndMeetsVersionCheck).thenReturn(false);
            expect(xcdevice.isInstalled, false);
          });
  
          testWithoutContext('is installed', () {
            when(mockXcode.isInstalledAndMeetsVersionCheck).thenReturn(true);
            fakeProcessManager.addCommand(const FakeCommand(
              command: <String>['xcrun', '--find', 'xcdevice'],
              stdout: '/path/to/xcdevice',
            ));
  
            expect(xcdevice.isInstalled, true);
            expect(fakeProcessManager.hasRemainingExpectations, isFalse);
          });
        });
  
        group('available devices', () {
          final FakePlatform macPlatform = FakePlatform(operatingSystem: 'macos');
  
          testWithoutContext('Xcode not installed', () async {
            when(mockXcode.isInstalledAndMeetsVersionCheck).thenReturn(false);
  
            expect(await xcdevice.getAvailableTetheredIOSDevices(), isEmpty);
          });
  
          testUsingContext('returns devices', () async {
            when(mockXcode.isInstalledAndMeetsVersionCheck).thenReturn(true);
            fakeProcessManager.addCommand(const FakeCommand(
              command: <String>['xcrun', '--find', 'xcdevice'],
              stdout: '/path/to/xcdevice',
            ));
  
            const String devicesOutput = '''
  [
    {
      "simulator" : true,
  