[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
This commit is contained in:
Jonah Williams 2020-09-25 14:29:22 -07:00 committed by GitHub
parent fd0e223b74
commit 99d0954857
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 2 deletions

View File

@ -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,

View File

@ -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<ErrorHandlingDirectory>());
});
});
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;