|
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';
|
@@ -1482,6 +1484,73 @@ The Flutter Preview device does not support the following plugins from your pubs
|
1482 | 1484 | );
|
1483 | 1485 | });
|
1484 | 1486 | });
|
| 1487 | + |
| 1488 | + testUsingContext('exits tool when deleting .plugin_symlinks fails', () async { |
| 1489 | + final FakeFlutterProject flutterProject = FakeFlutterProject() |
| 1490 | + ..directory = globals.fs.currentDirectory.childDirectory('app'); |
| 1491 | + final FakeFlutterManifest flutterManifest = FakeFlutterManifest(); |
| 1492 | + final Directory windowsManagedDirectory = flutterProject.directory |
| 1493 | + .childDirectory('windows') |
| 1494 | + .childDirectory('flutter'); |
| 1495 | + final FakeWindowsProject windowsProject = FakeWindowsProject() |
| 1496 | + ..managedDirectory = windowsManagedDirectory |
| 1497 | + ..cmakeFile = windowsManagedDirectory.parent.childFile('CMakeLists.txt') |
| 1498 | + ..generatedPluginCmakeFile = |
| 1499 | + windowsManagedDirectory.childFile('generated_plugins.mk') |
| 1500 | + ..pluginSymlinkDirectory = windowsManagedDirectory |
| 1501 | + .childDirectory('ephemeral') |
| 1502 | + .childDirectory('.plugin_symlinks') |
| 1503 | + ..exists = true; |
| 1504 | + |
| 1505 | + flutterProject |
| 1506 | + ..manifest = flutterManifest |
| 1507 | + ..flutterPluginsFile = |
| 1508 | + flutterProject.directory.childFile('.flutter-plugins') |
| 1509 | + ..flutterPluginsDependenciesFile = |
| 1510 | + flutterProject.directory.childFile('.flutter-plugins-dependencies') |
| 1511 | + ..windows = windowsProject; |
| 1512 | + |
| 1513 | + flutterProject.directory.childFile('.packages').createSync(recursive: true); |
| 1514 | + |
| 1515 | + createPluginSymlinks( |
| 1516 | + flutterProject, |
| 1517 | + force: true, |
| 1518 | + featureFlagsOverride: TestFeatureFlags(isWindowsEnabled: true), |
| 1519 | + ); |
| 1520 | + |
| 1521 | + expect( |
| 1522 | + () => createPluginSymlinks( |
| 1523 | + flutterProject, |
| 1524 | + force: true, |
| 1525 | + featureFlagsOverride: TestFeatureFlags(isWindowsEnabled: true), |
| 1526 | + ), |
| 1527 | + throwsToolExit( |
| 1528 | + message: RegExp('Unable to delete file or directory at ' |
| 1529 | + r'"C:\\app\\windows\\flutter\\ephemeral\\\.plugin_symlinks"')), |
| 1530 | + ); |
| 1531 | + }, overrides: <Type, Generator>{ |
| 1532 | + FileSystem: () { |
| 1533 | + final FileExceptionHandler handle = FileExceptionHandler(); |
| 1534 | + final ErrorHandlingFileSystem fileSystem = ErrorHandlingFileSystem( |
| 1535 | + platform: FakePlatform(), |
| 1536 | + delegate: MemoryFileSystem.test( |
| 1537 | + style: FileSystemStyle.windows, |
| 1538 | + opHandle: handle.opHandle, |
| 1539 | + ), |
| 1540 | + ); |
| 1541 | + const String symlinkDirectoryPath = r'C:\app\windows\flutter\ephemeral\.plugin_symlinks'; |
| 1542 | + handle.addError( |
| 1543 | + fileSystem.directory(symlinkDirectoryPath), |
| 1544 | + FileSystemOp.delete, |
| 1545 | + const PathNotFoundException( |
| 1546 | + symlinkDirectoryPath, |
| 1547 | + OSError('The system cannot find the path specified.', 3), |
| 1548 | + ), |
| 1549 | + ); |
| 1550 | + return fileSystem; |
| 1551 | + }, |
| 1552 | + ProcessManager: () => FakeProcessManager.empty(), |
| 1553 | + }); |
1485 | 1554 | }
|
1486 | 1555 |
|
1487 | 1556 | class FakeFlutterManifest extends Fake implements FlutterManifest {
|
|
0 commit comments