@@ -585,7 +585,49 @@ STDERR STUFF
585585 Platform : () => macosPlatform,
586586 });
587587
588- testUsingContext ('Performs code size analysis and sends analytics' , () async {
588+ testUsingContext ('code size analysis throws StateError if no code size snapshot generated by gen_snapshot' , () async {
589+ final BuildCommand command = BuildCommand (
590+ artifacts: artifacts,
591+ androidSdk: FakeAndroidSdk (),
592+ buildSystem: TestBuildSystem .all (BuildResult (success: true )),
593+ fileSystem: fileSystem,
594+ logger: logger,
595+ processUtils: processUtils,
596+ osUtils: FakeOperatingSystemUtils (),
597+ );
598+ createMinimalMockProjectFiles ();
599+
600+ fileSystem.file ('build/macos/Build/Products/Release/Runner.app/App' )
601+ ..createSync (recursive: true )
602+ ..writeAsBytesSync (List <int >.generate (10000 , (int index) => 0 ));
603+
604+ expect (
605+ () => createTestCommandRunner (command).run (
606+ const < String > ['build' , 'macos' , '--no-pub' , '--analyze-size' ]
607+ ),
608+ throwsA (
609+ isA <StateError >().having (
610+ (StateError err) => err.message,
611+ 'message' ,
612+ 'No code size snapshot file (snapshot.<ARCH>.json) found in build/flutter_size_01' ,
613+ ),
614+ ),
615+ );
616+
617+ expect (testLogger.statusText, isEmpty);
618+ }, overrides: < Type , Generator > {
619+ FileSystem : () => fileSystem,
620+ ProcessManager : () => FakeProcessManager .list (< FakeCommand > [
621+ // we never generate code size snapshot here
622+ setUpFakeXcodeBuildHandler ('Release' ),
623+ ]),
624+ Platform : () => macosPlatform,
625+ FeatureFlags : () => TestFeatureFlags (isMacOSEnabled: true ),
626+ FileSystemUtils : () => FileSystemUtils (fileSystem: fileSystem, platform: macosPlatform),
627+ Usage : () => usage,
628+ Analytics : () => fakeAnalytics,
629+ });
630+ testUsingContext ('Performs code size analysis and sends analytics from arm64 host' , () async {
589631 final BuildCommand command = BuildCommand (
590632 artifacts: artifacts,
591633 androidSdk: FakeAndroidSdk (),
@@ -614,8 +656,10 @@ STDERR STUFF
614656 }, overrides: < Type , Generator > {
615657 FileSystem : () => fileSystem,
616658 ProcessManager : () => FakeProcessManager .list (< FakeCommand > [
659+ // These are generated by gen_snapshot because flutter assemble passes
660+ // extra flags specifying this output path
617661 setUpFakeXcodeBuildHandler ('Release' , onRun: () {
618- fileSystem.file ('build/flutter_size_01/snapshot.x86_64 .json' )
662+ fileSystem.file ('build/flutter_size_01/snapshot.arm64 .json' )
619663 ..createSync (recursive: true )
620664 ..writeAsStringSync ('''
621665[
@@ -626,7 +670,7 @@ STDERR STUFF
626670 "s": 2400
627671 }
628672]''' );
629- fileSystem.file ('build/flutter_size_01/trace.x86_64 .json' )
673+ fileSystem.file ('build/flutter_size_01/trace.arm64 .json' )
630674 ..createSync (recursive: true )
631675 ..writeAsStringSync ('{}' );
632676 }),
0 commit comments