build_macos_test.dart 20.7 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3 4
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5 6
import 'dart:async';

7
import 'package:args/command_runner.dart';
8
import 'package:file/memory.dart';
9
import 'package:flutter_tools/src/artifacts.dart';
10
import 'package:flutter_tools/src/base/file_system.dart';
11
import 'package:flutter_tools/src/base/logger.dart';
12
import 'package:flutter_tools/src/base/platform.dart';
13
import 'package:flutter_tools/src/build_info.dart';
14
import 'package:flutter_tools/src/build_system/build_system.dart';
15 16
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/build.dart';
17
import 'package:flutter_tools/src/commands/build_macos.dart';
18
import 'package:flutter_tools/src/features.dart';
19
import 'package:flutter_tools/src/ios/xcodeproj.dart';
20
import 'package:flutter_tools/src/project.dart';
21
import 'package:flutter_tools/src/reporting/reporting.dart';
22

23 24
import '../../src/common.dart';
import '../../src/context.dart';
25
import '../../src/fake_process_manager.dart';
26
import '../../src/fakes.dart';
27
import '../../src/test_build_system.dart';
28
import '../../src/test_flutter_command_runner.dart';
29

30 31
class FakeXcodeProjectInterpreterWithProfile extends FakeXcodeProjectInterpreter {
  @override
32
  Future<XcodeProjectInfo> getInfo(String projectPath, { String? projectFilename }) async {
33 34 35 36
    return XcodeProjectInfo(
      <String>['Runner'],
      <String>['Debug', 'Profile', 'Release'],
      <String>['Runner'],
37
      BufferLogger.test(),
38 39 40 41
    );
  }
}

42 43 44 45
final Platform macosPlatform = FakePlatform(
  operatingSystem: 'macos',
  environment: <String, String>{
    'FLUTTER_ROOT': '/',
46
    'HOME': '/',
47 48
  }
);
49 50 51 52 53 54 55 56 57

final FakePlatform macosPlatformCustomEnv = FakePlatform(
    operatingSystem: 'macos',
    environment: <String, String>{
      'FLUTTER_ROOT': '/',
      'HOME': '/',
    }
);

58 59 60 61 62 63
final Platform notMacosPlatform = FakePlatform(
  environment: <String, String>{
    'FLUTTER_ROOT': '/',
  }
);

64
void main() {
65 66 67 68
  late FileSystem fileSystem;
  late TestUsage usage;
  late FakeProcessManager fakeProcessManager;
  late XcodeProjectInterpreter xcodeProjectInterpreter;
69

70 71
  setUpAll(() {
    Cache.disableLocking();
72
  });
73 74

  setUp(() {
75
    fileSystem = MemoryFileSystem.test();
76
    usage = TestUsage();
77 78
    fakeProcessManager = FakeProcessManager.empty();
    xcodeProjectInterpreter = FakeXcodeProjectInterpreter();
79
  });
80

81 82
  // Sets up the minimal mock project files necessary to look like a Flutter project.
  void createCoreMockProjectFiles() {
83 84 85
    fileSystem.file('pubspec.yaml').createSync();
    fileSystem.file('.packages').createSync();
    fileSystem.file(fileSystem.path.join('lib', 'main.dart')).createSync(recursive: true);
86 87
  }

88 89
  // Sets up the minimal mock project files necessary for macOS builds to succeed.
  void createMinimalMockProjectFiles() {
90
    fileSystem.directory(fileSystem.path.join('macos', 'Runner.xcworkspace')).createSync(recursive: true);
91 92 93
    createCoreMockProjectFiles();
  }

94
  // Creates a FakeCommand for the xcodebuild call to build the app
95
  // in the given configuration.
96
  FakeCommand setUpFakeXcodeBuildHandler(String configuration, { bool verbose = false, void Function()? onRun }) {
97 98 99 100 101 102 103
    final FlutterProject flutterProject = FlutterProject.fromDirectory(fileSystem.currentDirectory);
    final Directory flutterBuildDir = fileSystem.directory(getMacOSBuildDirectory());
    return FakeCommand(
      command: <String>[
        '/usr/bin/env',
        'xcrun',
        'xcodebuild',
104
        '-workspace', flutterProject.macos.xcodeWorkspace!.path,
105 106 107
        '-configuration', configuration,
        '-scheme', 'Runner',
        '-derivedDataPath', flutterBuildDir.absolute.path,
108
        '-destination', 'platform=macOS',
109 110
        'OBJROOT=${fileSystem.path.join(flutterBuildDir.absolute.path, 'Build', 'Intermediates.noindex')}',
        'SYMROOT=${fileSystem.path.join(flutterBuildDir.absolute.path, 'Build', 'Products')}',
111
        if (verbose)
112 113 114
          'VERBOSE_SCRIPT_LOGGING=YES'
        else
          '-quiet',
115 116
        'COMPILER_INDEX_STORE_ENABLE=NO',
      ],
117 118 119 120 121 122 123 124 125 126 127 128
      stdout: '''
STDOUT STUFF
note: Using new build system
note: Planning
note: Build preparation complete
note: Building targets in dependency order
''',
        stderr: '''
2022-03-24 10:07:21.954 xcodebuild[2096:1927385] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionSentinelHostApplications for extension Xcode.DebuggerFoundation.AppExtensionHosts.watchOS of plug-in com.apple.dt.IDEWatchSupportCore
2022-03-24 10:07:21.954 xcodebuild[2096:1927385] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionPointIdentifierToBundleIdentifier for extension Xcode.DebuggerFoundation.AppExtensionToBundleIdentifierMap.watchOS of plug-in com.apple.dt.IDEWatchSupportCore
STDERR STUFF
''',
129 130 131 132
      onRun: () {
        fileSystem.file(fileSystem.path.join('macos', 'Flutter', 'ephemeral', '.app_filename'))
          ..createSync(recursive: true)
          ..writeAsStringSync('example.app');
133 134 135
        if (onRun != null) {
          onRun();
        }
136 137
      }
    );
138 139
  }

140
  testUsingContext('macOS build fails when there is no macos project', () async {
141 142 143 144 145 146 147
    final BuildCommand command = BuildCommand(
      androidSdk: FakeAndroidSdk(),
      buildSystem: TestBuildSystem.all(BuildResult(success: true)),
      fileSystem: MemoryFileSystem.test(),
      logger: BufferLogger.test(),
      osUtils: FakeOperatingSystemUtils(),
    );
148
    createCoreMockProjectFiles();
149

150
    expect(createTestCommandRunner(command).run(
151
      const <String>['build', 'macos', '--no-pub']
152
    ), throwsToolExit(message: 'No macOS desktop project configured. See '
153
      'https://docs.flutter.dev/desktop#add-desktop-support-to-an-existing-flutter-app '
154
      'to learn about adding macOS support to a project.'));
155 156
  }, overrides: <Type, Generator>{
    Platform: () => macosPlatform,
157
    FileSystem: () => fileSystem,
158
    ProcessManager: () => FakeProcessManager.any(),
159
    FeatureFlags: () => TestFeatureFlags(isMacOSEnabled: true),
160 161 162
  });

  testUsingContext('macOS build fails on non-macOS platform', () async {
163 164 165 166 167 168 169
    final BuildCommand command = BuildCommand(
      androidSdk: FakeAndroidSdk(),
      buildSystem: TestBuildSystem.all(BuildResult(success: true)),
      fileSystem: MemoryFileSystem.test(),
      logger: BufferLogger.test(),
      osUtils: FakeOperatingSystemUtils(),
    );
170 171 172
    fileSystem.file('pubspec.yaml').createSync();
    fileSystem.file(fileSystem.path.join('lib', 'main.dart'))
      .createSync(recursive: true);
173 174

    expect(createTestCommandRunner(command).run(
175
      const <String>['build', 'macos', '--no-pub']
176
    ), throwsA(isA<UsageException>()));
177 178
  }, overrides: <Type, Generator>{
    Platform: () => notMacosPlatform,
179
    FileSystem: () => fileSystem,
180
    ProcessManager: () => FakeProcessManager.any(),
181
    FeatureFlags: () => TestFeatureFlags(isMacOSEnabled: true),
182 183
  });

184
  testUsingContext('macOS build fails when feature is disabled', () async {
185 186 187 188 189 190 191
    final BuildCommand command = BuildCommand(
      androidSdk: FakeAndroidSdk(),
      buildSystem: TestBuildSystem.all(BuildResult(success: true)),
      fileSystem: MemoryFileSystem.test(),
      logger: BufferLogger.test(),
      osUtils: FakeOperatingSystemUtils(),
    );
192 193 194 195 196 197 198 199 200 201 202
    fileSystem.file('pubspec.yaml').createSync();
    fileSystem.file(fileSystem.path.join('lib', 'main.dart'))
        .createSync(recursive: true);

    expect(createTestCommandRunner(command).run(
        const <String>['build', 'macos', '--no-pub']
    ), throwsToolExit(message: '"build macos" is not currently supported. To enable, run "flutter config --enable-macos-desktop".'));
  }, overrides: <Type, Generator>{
    Platform: () => macosPlatform,
    FileSystem: () => fileSystem,
    ProcessManager: () => FakeProcessManager.any(),
203
    FeatureFlags: () => TestFeatureFlags(),
204 205
  });

206
  testUsingContext('macOS build forwards error stdout to status logger error', () async {
207 208 209 210 211 212 213
    final BuildCommand command = BuildCommand(
      androidSdk: FakeAndroidSdk(),
      buildSystem: TestBuildSystem.all(BuildResult(success: true)),
      fileSystem: MemoryFileSystem.test(),
      logger: BufferLogger.test(),
      osUtils: FakeOperatingSystemUtils(),
    );
214 215 216
    createMinimalMockProjectFiles();

    await createTestCommandRunner(command).run(
217
      const <String>['build', 'macos', '--debug', '--no-pub']
218
    );
219
    expect(testLogger.statusText, isNot(contains('STDOUT STUFF')));
220 221
    expect(testLogger.traceText, isNot(contains('STDOUT STUFF')));
    expect(testLogger.errorText, contains('STDOUT STUFF'));
222 223 224 225 226
    expect(testLogger.errorText, contains('STDERR STUFF'));
    // Filters out some xcodebuild logging spew.
    expect(testLogger.errorText, isNot(contains('xcodebuild[2096:1927385]')));
    expect(testLogger.errorText, isNot(contains('Using new build system')));
    expect(testLogger.errorText, isNot(contains('Building targets in dependency order')));
227
  }, overrides: <Type, Generator>{
228 229
    FileSystem: () => fileSystem,
    ProcessManager: () => FakeProcessManager.list(<FakeCommand>[
230
      setUpFakeXcodeBuildHandler('Debug'),
231
    ]),
232 233
    Platform: () => macosPlatform,
    FeatureFlags: () => TestFeatureFlags(isMacOSEnabled: true),
234 235
  });

236
  testUsingContext('macOS build invokes xcode build (debug)', () async {
237 238 239 240 241 242 243
    final BuildCommand command = BuildCommand(
      androidSdk: FakeAndroidSdk(),
      buildSystem: TestBuildSystem.all(BuildResult(success: true)),
      fileSystem: MemoryFileSystem.test(),
      logger: BufferLogger.test(),
      osUtils: FakeOperatingSystemUtils(),
    );
244 245 246
    createMinimalMockProjectFiles();

    await createTestCommandRunner(command).run(
247
      const <String>['build', 'macos', '--debug', '--no-pub']
248 249
    );
  }, overrides: <Type, Generator>{
250 251
    FileSystem: () => fileSystem,
    ProcessManager: () => FakeProcessManager.list(<FakeCommand>[
252
      setUpFakeXcodeBuildHandler('Debug'),
253
    ]),
254 255 256 257
    Platform: () => macosPlatform,
    FeatureFlags: () => TestFeatureFlags(isMacOSEnabled: true),
  });

258
  testUsingContext('macOS build invokes xcode build (debug) with verbosity', () async {
259 260 261 262 263 264 265
    final BuildCommand command = BuildCommand(
      androidSdk: FakeAndroidSdk(),
      buildSystem: TestBuildSystem.all(BuildResult(success: true)),
      fileSystem: MemoryFileSystem.test(),
      logger: BufferLogger.test(),
      osUtils: FakeOperatingSystemUtils(),
    );
266 267 268
    createMinimalMockProjectFiles();

    await createTestCommandRunner(command).run(
269
      const <String>['build', 'macos', '--debug', '--no-pub', '-v']
270 271 272 273
    );
  }, overrides: <Type, Generator>{
    FileSystem: () => fileSystem,
    ProcessManager: () => FakeProcessManager.list(<FakeCommand>[
274
      setUpFakeXcodeBuildHandler('Debug', verbose: true),
275 276 277 278 279 280
    ]),
    Platform: () => macosPlatform,
    FeatureFlags: () => TestFeatureFlags(isMacOSEnabled: true),
  });


281
  testUsingContext('macOS build invokes xcode build (profile)', () async {
282 283 284 285 286 287 288
    final BuildCommand command = BuildCommand(
      androidSdk: FakeAndroidSdk(),
      buildSystem: TestBuildSystem.all(BuildResult(success: true)),
      fileSystem: MemoryFileSystem.test(),
      logger: BufferLogger.test(),
      osUtils: FakeOperatingSystemUtils(),
    );
289 290 291
    createMinimalMockProjectFiles();

    await createTestCommandRunner(command).run(
292
      const <String>['build', 'macos', '--profile', '--no-pub']
293 294
    );
  }, overrides: <Type, Generator>{
295 296
    FileSystem: () => fileSystem,
    ProcessManager: () => FakeProcessManager.list(<FakeCommand>[
297
      setUpFakeXcodeBuildHandler('Profile'),
298
    ]),
299 300 301 302 303 304
    Platform: () => macosPlatform,
    XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithProfile(),
    FeatureFlags: () => TestFeatureFlags(isMacOSEnabled: true),
  });

  testUsingContext('macOS build invokes xcode build (release)', () async {
305 306 307 308 309 310 311
    final BuildCommand command = BuildCommand(
      androidSdk: FakeAndroidSdk(),
      buildSystem: TestBuildSystem.all(BuildResult(success: true)),
      fileSystem: MemoryFileSystem.test(),
      logger: BufferLogger.test(),
      osUtils: FakeOperatingSystemUtils(),
    );
312
    createMinimalMockProjectFiles();
313

314
    await createTestCommandRunner(command).run(
315
      const <String>['build', 'macos', '--release', '--no-pub']
316
    );
317
  }, overrides: <Type, Generator>{
318 319
    FileSystem: () => fileSystem,
    ProcessManager: () => FakeProcessManager.list(<FakeCommand>[
320
      setUpFakeXcodeBuildHandler('Release'),
321
    ]),
322
    Platform: () => macosPlatform,
323 324 325
    FeatureFlags: () => TestFeatureFlags(isMacOSEnabled: true),
  });

326
  testUsingContext('macOS build supports standard desktop build options', () async {
327 328 329 330 331 332 333
    final BuildCommand command = BuildCommand(
      androidSdk: FakeAndroidSdk(),
      buildSystem: TestBuildSystem.all(BuildResult(success: true)),
      fileSystem: MemoryFileSystem.test(),
      logger: BufferLogger.test(),
      osUtils: FakeOperatingSystemUtils(),
    );
334 335 336
    createMinimalMockProjectFiles();
    fileSystem.file('lib/other.dart')
      .createSync(recursive: true);
337 338
    fileSystem.file('foo/bar.sksl.json')
      .createSync(recursive: true);
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360

    await createTestCommandRunner(command).run(
      const <String>[
        'build',
        'macos',
        '--target=lib/other.dart',
        '--no-pub',
        '--track-widget-creation',
        '--split-debug-info=foo/',
        '--enable-experiment=non-nullable',
        '--obfuscate',
        '--dart-define=foo.bar=2',
        '--dart-define=fizz.far=3',
        '--tree-shake-icons',
        '--bundle-sksl-path=foo/bar.sksl.json',
      ]
    );
    final List<String> contents = fileSystem
      .file('./macos/Flutter/ephemeral/Flutter-Generated.xcconfig')
      .readAsLinesSync();

    expect(contents, containsAll(<String>[
361 362 363 364 365 366
      'FLUTTER_APPLICATION_PATH=/',
      'FLUTTER_TARGET=lib/other.dart',
      'FLUTTER_BUILD_DIR=build',
      'FLUTTER_BUILD_NAME=1.0.0',
      'FLUTTER_BUILD_NUMBER=1',
      'DART_DEFINES=Zm9vLmJhcj0y,Zml6ei5mYXI9Mw==',
367
      'DART_OBFUSCATION=true',
368 369
      'EXTRA_FRONT_END_OPTIONS=--enable-experiment=non-nullable',
      'EXTRA_GEN_SNAPSHOT_OPTIONS=--enable-experiment=non-nullable',
370 371 372 373
      'SPLIT_DEBUG_INFO=foo/',
      'TRACK_WIDGET_CREATION=true',
      'TREE_SHAKE_ICONS=true',
      'BUNDLE_SKSL_PATH=foo/bar.sksl.json',
374 375
      'PACKAGE_CONFIG=/.dart_tool/package_config.json',
      'COCOAPODS_PARALLEL_CODE_SIGN=true',
376
    ]));
377
    expect(contents, isNot(contains('EXCLUDED_ARCHS')));
378 379 380
  }, overrides: <Type, Generator>{
    FileSystem: () => fileSystem,
    ProcessManager: () => FakeProcessManager.list(<FakeCommand>[
381
      setUpFakeXcodeBuildHandler('Release'),
382 383 384
    ]),
    Platform: () => macosPlatform,
    FeatureFlags: () => TestFeatureFlags(isMacOSEnabled: true),
385
    Artifacts: () => Artifacts.test(),
386 387
  });

388 389 390
  testUsingContext('build settings contains Flutter Xcode environment variables', () async {

    macosPlatformCustomEnv.environment = Map<String, String>.unmodifiable(<String, String>{
391
      'FLUTTER_XCODE_ASSETCATALOG_COMPILER_APPICON_NAME': 'AppIcon.special',
392 393 394 395
    });

    final FlutterProject flutterProject = FlutterProject.fromDirectory(fileSystem.currentDirectory);
    final Directory flutterBuildDir = fileSystem.directory(getMacOSBuildDirectory());
396
    createMinimalMockProjectFiles();
397 398 399 400 401 402 403

    fakeProcessManager.addCommands(<FakeCommand>[
      FakeCommand(
        command: <String>[
          '/usr/bin/env',
          'xcrun',
          'xcodebuild',
404
          '-workspace', flutterProject.macos.xcodeWorkspace!.path,
405 406 407
          '-configuration', 'Debug',
          '-scheme', 'Runner',
          '-derivedDataPath', flutterBuildDir.absolute.path,
408
          '-destination', 'platform=macOS',
409 410 411 412 413 414 415 416 417
          'OBJROOT=${fileSystem.path.join(flutterBuildDir.absolute.path, 'Build', 'Intermediates.noindex')}',
          'SYMROOT=${fileSystem.path.join(flutterBuildDir.absolute.path, 'Build', 'Products')}',
          '-quiet',
          'COMPILER_INDEX_STORE_ENABLE=NO',
          'ASSETCATALOG_COMPILER_APPICON_NAME=AppIcon.special',
        ],
      ),
    ]);

418 419 420 421 422 423 424
    final BuildCommand command = BuildCommand(
      androidSdk: FakeAndroidSdk(),
      buildSystem: TestBuildSystem.all(BuildResult(success: true)),
      fileSystem: fileSystem,
      logger: BufferLogger.test(),
      osUtils: FakeOperatingSystemUtils(),
    );
425 426 427 428 429

    await createTestCommandRunner(command).run(
        const <String>['build', 'macos', '--debug', '--no-pub']
    );

430
    expect(fakeProcessManager, hasNoRemainingExpectations);
431 432 433 434 435 436 437 438
  }, overrides: <Type, Generator>{
    FileSystem: () => fileSystem,
    ProcessManager: () => fakeProcessManager,
    Platform: () => macosPlatformCustomEnv,
    FeatureFlags: () => TestFeatureFlags(isMacOSEnabled: true),
    XcodeProjectInterpreter: () => xcodeProjectInterpreter,
  });

439
  testUsingContext('macOS build supports build-name and build-number', () async {
440 441 442 443 444 445 446
    final BuildCommand command = BuildCommand(
      androidSdk: FakeAndroidSdk(),
      buildSystem: TestBuildSystem.all(BuildResult(success: true)),
      fileSystem: MemoryFileSystem.test(),
      logger: BufferLogger.test(),
      osUtils: FakeOperatingSystemUtils(),
    );
447 448 449 450 451 452 453
    createMinimalMockProjectFiles();

    await createTestCommandRunner(command).run(
      const <String>[
        'build',
        'macos',
        '--debug',
454
        '--no-pub',
455 456 457 458 459 460 461 462 463 464 465 466 467
        '--build-name=1.2.3',
        '--build-number=42',
      ],
    );
    final String contents = fileSystem
      .file('./macos/Flutter/ephemeral/Flutter-Generated.xcconfig')
      .readAsStringSync();

    expect(contents, contains('FLUTTER_BUILD_NAME=1.2.3'));
    expect(contents, contains('FLUTTER_BUILD_NUMBER=42'));
  }, overrides: <Type, Generator>{
    FileSystem: () => fileSystem,
    ProcessManager: () => FakeProcessManager.list(<FakeCommand>[
468
      setUpFakeXcodeBuildHandler('Debug'),
469 470 471 472 473
    ]),
    Platform: () => macosPlatform,
    FeatureFlags: () => TestFeatureFlags(isMacOSEnabled: true),
  });

474
  testUsingContext('Refuses to build for macOS when feature is disabled', () {
475 476 477 478 479 480 481 482 483
    final CommandRunner<void> runner = createTestCommandRunner(BuildCommand(
      androidSdk: FakeAndroidSdk(),
      buildSystem: TestBuildSystem.all(BuildResult(success: true)),
      fileSystem: MemoryFileSystem.test(),
      logger: BufferLogger.test(),
      osUtils: FakeOperatingSystemUtils(),
    ));

    final bool supported = BuildMacosCommand(logger: BufferLogger.test(), verboseHelp: false).supported;
484
    expect(() => runner.run(<String>['build', 'macos', '--no-pub']),
485
      supported ? throwsToolExit() : throwsA(isA<UsageException>()));
486
  }, overrides: <Type, Generator>{
487
    FeatureFlags: () => TestFeatureFlags(),
488
  });
489 490

  testUsingContext('hidden when not enabled on macOS host', () {
491
    expect(BuildMacosCommand(logger: BufferLogger.test(), verboseHelp: false).hidden, true);
492
  }, overrides: <Type, Generator>{
493
    FeatureFlags: () => TestFeatureFlags(),
494
    Platform: () => macosPlatform,
495 496 497
  });

  testUsingContext('Not hidden when enabled and on macOS host', () {
498
    expect(BuildMacosCommand(logger: BufferLogger.test(), verboseHelp: false).hidden, false);
499 500
  }, overrides: <Type, Generator>{
    FeatureFlags: () => TestFeatureFlags(isMacOSEnabled: true),
501
    Platform: () => macosPlatform,
502
  });
503 504

  testUsingContext('Performs code size analysis and sends analytics', () async {
505 506 507 508 509 510 511
    final BuildCommand command = BuildCommand(
      androidSdk: FakeAndroidSdk(),
      buildSystem: TestBuildSystem.all(BuildResult(success: true)),
      fileSystem: MemoryFileSystem.test(),
      logger: BufferLogger.test(),
      osUtils: FakeOperatingSystemUtils(),
    );
512 513 514 515 516 517
    createMinimalMockProjectFiles();

    fileSystem.file('build/macos/Build/Products/Release/Runner.app/App')
      ..createSync(recursive: true)
      ..writeAsBytesSync(List<int>.generate(10000, (int index) => 0));

518 519
    await createTestCommandRunner(command).run(
      const <String>['build', 'macos', '--no-pub', '--analyze-size']
520 521 522
    );

    expect(testLogger.statusText, contains('A summary of your macOS bundle analysis can be found at'));
523
    expect(testLogger.statusText, contains('flutter pub global activate devtools; flutter pub global run devtools --appSizeBase='));
524 525 526
    expect(usage.events, contains(
      const TestUsageEvent('code-size-analysis', 'macos'),
    ));
527 528 529
  }, overrides: <Type, Generator>{
    FileSystem: () => fileSystem,
    ProcessManager: () => FakeProcessManager.list(<FakeCommand>[
530
      setUpFakeXcodeBuildHandler('Release', onRun: () {
531 532
        fileSystem.file('build/flutter_size_01/snapshot.x86_64.json')
          ..createSync(recursive: true)
533 534 535 536 537 538 539 540 541
          ..writeAsStringSync('''
[
  {
    "l": "dart:_internal",
    "c": "SubListIterable",
    "n": "[Optimized] skip",
    "s": 2400
  }
]''');
542 543 544 545 546 547 548 549 550 551 552
        fileSystem.file('build/flutter_size_01/trace.x86_64.json')
          ..createSync(recursive: true)
          ..writeAsStringSync('{}');
      }),
    ]),
    Platform: () => macosPlatform,
    FeatureFlags: () => TestFeatureFlags(isMacOSEnabled: true),
    FileSystemUtils: () => FileSystemUtils(fileSystem: fileSystem, platform: macosPlatform),
    Usage: () => usage,
  });
}