@@ -626,90 +626,29 @@ void main() {
626626 });
627627
628628 group ('unzip on macOS' , () {
629- testWithoutContext ('unzip and copy to empty folder ' , () {
629+ testWithoutContext ('falls back to unzip when rsync cannot run ' , () {
630630 final FileSystem fileSystem = MemoryFileSystem .test ();
631+ fakeProcessManager.excludedExecutables.add ('rsync' );
631632
633+ final BufferLogger logger = BufferLogger .test ();
632634 final OperatingSystemUtils macOSUtils = OperatingSystemUtils (
633635 fileSystem: fileSystem,
634- logger: BufferLogger .test (),
635- platform: FakePlatform (operatingSystem: 'macos' ),
636- processManager: fakeProcessManager,
637- );
638-
639- final Directory targetDirectory = fileSystem.currentDirectory;
640- final Directory tempDirectory = fileSystem.systemTempDirectory.childDirectory ('flutter_foo.zip.rand0' );
641- fakeProcessManager.addCommands (< FakeCommand > [
642- FakeCommand (
643- command: < String > [
644- 'unzip' ,
645- '-o' ,
646- '-q' ,
647- 'foo.zip' ,
648- '-d' ,
649- tempDirectory.path,
650- ],
651- onRun: () {
652- expect (tempDirectory, exists);
653- tempDirectory.childDirectory ('dirA' ).childFile ('fileA' ).createSync (recursive: true );
654- tempDirectory.childDirectory ('dirB' ).childFile ('fileB' ).createSync (recursive: true );
655- },
656- ),
657- ]);
658-
659- macOSUtils.unzip (fileSystem.file ('foo.zip' ), fileSystem.currentDirectory);
660- expect (fakeProcessManager, hasNoRemainingExpectations);
661- expect (tempDirectory, isNot (exists));
662- expect (targetDirectory.childDirectory ('dirA' ).childFile ('fileA' ).existsSync (), isTrue);
663- expect (targetDirectory.childDirectory ('dirB' ).childFile ('fileB' ).existsSync (), isTrue);
664- });
665-
666- testWithoutContext ('unzip and copy to preexisting folder' , () {
667- final FileSystem fileSystem = MemoryFileSystem .test ();
668-
669- final OperatingSystemUtils macOSUtils = OperatingSystemUtils (
670- fileSystem: fileSystem,
671- logger: BufferLogger .test (),
636+ logger: logger,
672637 platform: FakePlatform (operatingSystem: 'macos' ),
673638 processManager: fakeProcessManager,
674639 );
675640
676641 final Directory targetDirectory = fileSystem.currentDirectory;
677- final File origFileA = targetDirectory.childDirectory ('dirA' ).childFile ('fileA' );
678- origFileA.createSync (recursive: true );
679- origFileA.writeAsStringSync ('old' );
680- expect (targetDirectory.childDirectory ('dirA' ).childFile ('fileA' ).existsSync (), isTrue);
681- expect (targetDirectory.childDirectory ('dirA' ).childFile ('fileA' ).readAsStringSync (), 'old' );
682-
683- final Directory tempDirectory = fileSystem.systemTempDirectory.childDirectory ('flutter_foo.zip.rand0' );
684- fakeProcessManager.addCommands (< FakeCommand > [
685- FakeCommand (
686- command: < String > [
687- 'unzip' ,
688- '-o' ,
689- '-q' ,
690- 'foo.zip' ,
691- '-d' ,
692- tempDirectory.path,
693- ],
694- onRun: () {
695- expect (tempDirectory, exists);
696- final File newFileA = tempDirectory.childDirectory ('dirA' ).childFile ('fileA' );
697- newFileA.createSync (recursive: true );
698- newFileA.writeAsStringSync ('new' );
699- tempDirectory.childDirectory ('dirB' ).childFile ('fileB' ).createSync (recursive: true );
700- },
701- ),
702- ]);
642+ fakeProcessManager.addCommand (FakeCommand (
643+ command: < String > ['unzip' , '-o' , '-q' , 'foo.zip' , '-d' , targetDirectory.path],
644+ ));
703645
704- macOSUtils.unzip (fileSystem.file ('foo.zip' ), fileSystem.currentDirectory );
646+ macOSUtils.unzip (fileSystem.file ('foo.zip' ), targetDirectory );
705647 expect (fakeProcessManager, hasNoRemainingExpectations);
706- expect (tempDirectory, isNot (exists));
707- expect (targetDirectory.childDirectory ('dirA' ).childFile ('fileA' ).existsSync (), isTrue);
708- expect (targetDirectory.childDirectory ('dirA' ).childFile ('fileA' ).readAsStringSync (), 'new' );
709- expect (targetDirectory.childDirectory ('dirB' ).childFile ('fileB' ).existsSync (), isTrue);
648+ expect (logger.traceText, contains ('Unable to find rsync' ));
710649 });
711650
712- testWithoutContext ('unzip and copy to preexisting folder with type mismatch ' , () {
651+ testWithoutContext ('unzip and rsyncs ' , () {
713652 final FileSystem fileSystem = MemoryFileSystem .test ();
714653
715654 final OperatingSystemUtils macOSUtils = OperatingSystemUtils (
@@ -720,10 +659,6 @@ void main() {
720659 );
721660
722661 final Directory targetDirectory = fileSystem.currentDirectory;
723- final Directory origFileA = targetDirectory.childDirectory ('dirA' ).childDirectory ('fileA' );
724- origFileA.createSync (recursive: true );
725- expect (targetDirectory.childDirectory ('dirA' ).childDirectory ('fileA' ).existsSync (), isTrue);
726-
727662 final Directory tempDirectory = fileSystem.systemTempDirectory.childDirectory ('flutter_foo.zip.rand0' );
728663 fakeProcessManager.addCommands (< FakeCommand > [
729664 FakeCommand (
@@ -741,13 +676,27 @@ void main() {
741676 tempDirectory.childDirectory ('dirB' ).childFile ('fileB' ).createSync (recursive: true );
742677 },
743678 ),
679+ FakeCommand (command: < String > [
680+ 'rsync' ,
681+ '-8' ,
682+ '-av' ,
683+ '--delete' ,
684+ tempDirectory.childDirectory ('dirA' ).path,
685+ targetDirectory.path,
686+ ]),
687+ FakeCommand (command: < String > [
688+ 'rsync' ,
689+ '-8' ,
690+ '-av' ,
691+ '--delete' ,
692+ tempDirectory.childDirectory ('dirB' ).path,
693+ targetDirectory.path,
694+ ]),
744695 ]);
745696
746697 macOSUtils.unzip (fileSystem.file ('foo.zip' ), fileSystem.currentDirectory);
747698 expect (fakeProcessManager, hasNoRemainingExpectations);
748699 expect (tempDirectory, isNot (exists));
749- expect (targetDirectory.childDirectory ('dirA' ).childFile ('fileA' ).existsSync (), isTrue);
750- expect (targetDirectory.childDirectory ('dirB' ).childFile ('fileB' ).existsSync (), isTrue);
751700 });
752701 });
753702
0 commit comments