|
3 | 3 | // found in the LICENSE file.
|
4 | 4 |
|
5 | 5 | import 'dart:convert';
|
| 6 | +import 'dart:io'; |
6 | 7 |
|
7 | 8 | import 'package:file/file.dart';
|
8 | 9 | import 'package:file/memory.dart';
|
9 | 10 | import 'package:file_testing/file_testing.dart';
|
| 11 | +import 'package:flutter_tools/src/base/error_handling_io.dart'; |
10 | 12 | import 'package:flutter_tools/src/base/os.dart';
|
11 | 13 | import 'package:flutter_tools/src/base/platform.dart';
|
12 | 14 | import 'package:flutter_tools/src/base/time.dart';
|
@@ -1752,6 +1754,73 @@ The Flutter Preview device does not support the following plugins from your pubs
|
1752 | 1754 | );
|
1753 | 1755 | });
|
1754 | 1756 | });
|
| 1757 | + |
| 1758 | + testUsingContext('exits tool when deleting .plugin_symlinks fails', () async { |
| 1759 | + final FakeFlutterProject flutterProject = FakeFlutterProject() |
| 1760 | + ..directory = globals.fs.currentDirectory.childDirectory('app'); |
| 1761 | + final FakeFlutterManifest flutterManifest = FakeFlutterManifest(); |
| 1762 | + final Directory windowsManagedDirectory = flutterProject.directory |
| 1763 | + .childDirectory('windows') |
| 1764 | + .childDirectory('flutter'); |
| 1765 | + final FakeWindowsProject windowsProject = FakeWindowsProject() |
| 1766 | + ..managedDirectory = windowsManagedDirectory |
| 1767 | + ..cmakeFile = windowsManagedDirectory.parent.childFile('CMakeLists.txt') |
| 1768 | + ..generatedPluginCmakeFile = |
| 1769 | + windowsManagedDirectory.childFile('generated_plugins.mk') |
| 1770 | + ..pluginSymlinkDirectory = windowsManagedDirectory |
| 1771 | + .childDirectory('ephemeral') |
| 1772 | + .childDirectory('.plugin_symlinks') |
| 1773 | + ..exists = true; |
| 1774 | + |
| 1775 | + flutterProject |
| 1776 | + ..manifest = flutterManifest |
| 1777 | + ..flutterPluginsFile = |
| 1778 | + flutterProject.directory.childFile('.flutter-plugins') |
| 1779 | + ..flutterPluginsDependenciesFile = |
| 1780 | + flutterProject.directory.childFile('.flutter-plugins-dependencies') |
| 1781 | + ..windows = windowsProject; |
| 1782 | + |
| 1783 | + flutterProject.directory.childFile('.packages').createSync(recursive: true); |
| 1784 | + |
| 1785 | + createPluginSymlinks( |
| 1786 | + flutterProject, |
| 1787 | + force: true, |
| 1788 | + featureFlagsOverride: TestFeatureFlags(isWindowsEnabled: true), |
| 1789 | + ); |
| 1790 | + |
| 1791 | + expect( |
| 1792 | + () => createPluginSymlinks( |
| 1793 | + flutterProject, |
| 1794 | + force: true, |
| 1795 | + featureFlagsOverride: TestFeatureFlags(isWindowsEnabled: true), |
| 1796 | + ), |
| 1797 | + throwsToolExit( |
| 1798 | + message: RegExp('Unable to delete file or directory at ' |
| 1799 | + r'"C:\\app\\windows\\flutter\\ephemeral\\\.plugin_symlinks"')), |
| 1800 | + ); |
| 1801 | + }, overrides: <Type, Generator>{ |
| 1802 | + FileSystem: () { |
| 1803 | + final FileExceptionHandler handle = FileExceptionHandler(); |
| 1804 | + final ErrorHandlingFileSystem fileSystem = ErrorHandlingFileSystem( |
| 1805 | + platform: FakePlatform(), |
| 1806 | + delegate: MemoryFileSystem.test( |
| 1807 | + style: FileSystemStyle.windows, |
| 1808 | + opHandle: handle.opHandle, |
| 1809 | + ), |
| 1810 | + ); |
| 1811 | + const String symlinkDirectoryPath = r'C:\app\windows\flutter\ephemeral\.plugin_symlinks'; |
| 1812 | + handle.addError( |
| 1813 | + fileSystem.directory(symlinkDirectoryPath), |
| 1814 | + FileSystemOp.delete, |
| 1815 | + const PathNotFoundException( |
| 1816 | + symlinkDirectoryPath, |
| 1817 | + OSError('The system cannot find the path specified.', 3), |
| 1818 | + ), |
| 1819 | + ); |
| 1820 | + return fileSystem; |
| 1821 | + }, |
| 1822 | + ProcessManager: () => FakeProcessManager.empty(), |
| 1823 | + }); |
1755 | 1824 | }
|
1756 | 1825 |
|
1757 | 1826 | class FakeFlutterManifest extends Fake implements FlutterManifest {
|
|
0 commit comments