@@ -585,7 +585,49 @@ STDERR STUFF
585
585
Platform : () => macosPlatform,
586
586
});
587
587
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 {
589
631
final BuildCommand command = BuildCommand (
590
632
artifacts: artifacts,
591
633
androidSdk: FakeAndroidSdk (),
@@ -614,8 +656,10 @@ STDERR STUFF
614
656
}, overrides: < Type , Generator > {
615
657
FileSystem : () => fileSystem,
616
658
ProcessManager : () => FakeProcessManager .list (< FakeCommand > [
659
+ // These are generated by gen_snapshot because flutter assemble passes
660
+ // extra flags specifying this output path
617
661
setUpFakeXcodeBuildHandler ('Release' , onRun: () {
618
- fileSystem.file ('build/flutter_size_01/snapshot.x86_64 .json' )
662
+ fileSystem.file ('build/flutter_size_01/snapshot.arm64 .json' )
619
663
..createSync (recursive: true )
620
664
..writeAsStringSync ('''
621
665
[
@@ -626,7 +670,7 @@ STDERR STUFF
626
670
"s": 2400
627
671
}
628
672
]''' );
629
- fileSystem.file ('build/flutter_size_01/trace.x86_64 .json' )
673
+ fileSystem.file ('build/flutter_size_01/trace.arm64 .json' )
630
674
..createSync (recursive: true )
631
675
..writeAsStringSync ('{}' );
632
676
}),
0 commit comments