From 99d09548572ffca01fc7e355ec2da012d135946b Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Fri, 25 Sep 2020 14:29:22 -0700 Subject: [PATCH] [flutter_tools] ensure ErrorHandlingFileSystem wraps current directory (#66680) The lack of current directory wrapping was letting some of the already handled errors through Fixes #66675 --- .../lib/src/base/error_handling_io.dart | 3 +++ .../base/error_handling_io_test.dart | 21 +++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/packages/flutter_tools/lib/src/base/error_handling_io.dart b/packages/flutter_tools/lib/src/base/error_handling_io.dart index 88a798c50aa..26198839da9 100644 --- a/packages/flutter_tools/lib/src/base/error_handling_io.dart +++ b/packages/flutter_tools/lib/src/base/error_handling_io.dart @@ -45,6 +45,9 @@ class ErrorHandlingFileSystem extends ForwardingFileSystem { final Platform _platform; + @override + Directory get currentDirectory => directory(delegate.currentDirectory); + @override File file(dynamic path) => ErrorHandlingFile( platform: _platform, diff --git a/packages/flutter_tools/test/general.shard/base/error_handling_io_test.dart b/packages/flutter_tools/test/general.shard/base/error_handling_io_test.dart index 05b93b03960..f43bd4588b2 100644 --- a/packages/flutter_tools/test/general.shard/base/error_handling_io_test.dart +++ b/packages/flutter_tools/test/general.shard/base/error_handling_io_test.dart @@ -300,7 +300,6 @@ void main() { }); }); - group('throws ToolExit on macOS', () { const int eperm = 1; const int enospc = 28; @@ -445,6 +444,24 @@ void main() { expect(mockFile.toString(), isNotNull); expect(fs.file('file').toString(), equals(mockFile.toString())); }); + + testWithoutContext('ErrorHandlingDirectory', () { + final MockFileSystem mockFileSystem = MockFileSystem(); + final FileSystem fs = ErrorHandlingFileSystem( + delegate: mockFileSystem, + platform: const LocalPlatform(), + ); + final MockDirectory mockDirectory = MockDirectory(); + when(mockFileSystem.directory(any)).thenReturn(mockDirectory); + + expect(mockDirectory.toString(), isNotNull); + expect(fs.directory('directory').toString(), equals(mockDirectory.toString())); + + when(mockFileSystem.currentDirectory).thenReturn(mockDirectory); + + expect(fs.currentDirectory.toString(), equals(mockDirectory.toString())); + expect(fs.currentDirectory, isA()); + }); }); group('ProcessManager on windows throws tool exit', () { @@ -563,7 +580,7 @@ void main() { }); }); - group('ProcessManager on macOS throws tool exit', () { + group('ProcessManager on macOS throws tool exit', () { const int enospc = 28; const int eacces = 13;