@@ -87,6 +87,7 @@ void setupReadMocks({
8787}) {
8888 final MockFile mockFile = MockFile ();
8989 when (mockFileSystem.file (any)).thenReturn (mockFile);
90+ when (mockFileSystem.currentDirectory).thenThrow (FileSystemException ('' , '' , OSError ('' , errorCode)));
9091 when (mockFile.readAsStringSync (
9192 encoding: anyNamed ('encoding' ),
9293 )).thenThrow (FileSystemException ('' , '' , OSError ('' , errorCode)));
@@ -345,7 +346,7 @@ void main() {
345346 throwsToolExit (message: expectedMessage));
346347 });
347348
348- testWithoutContext ('When reading from a file without permission' , () {
349+ testWithoutContext ('When reading from a file or directory without permission' , () {
349350 setupReadMocks (
350351 mockFileSystem: mockFileSystem,
351352 fs: fs,
@@ -357,6 +358,8 @@ void main() {
357358 const String expectedMessage = 'Flutter failed to read a file at' ;
358359 expect (() => file.readAsStringSync (),
359360 throwsToolExit (message: expectedMessage));
361+ expect (() => fs.currentDirectory,
362+ throwsToolExit (message: 'The flutter tool cannot access the file or directory' ));
360363 });
361364 });
362365
@@ -579,7 +582,7 @@ void main() {
579582 throwsToolExit (message: expectedMessage));
580583 });
581584
582- testWithoutContext ('When reading from a file without permission' , () {
585+ testWithoutContext ('When reading from a file or directory without permission' , () {
583586 setupReadMocks (
584587 mockFileSystem: mockFileSystem,
585588 fs: fs,
@@ -591,6 +594,8 @@ void main() {
591594 const String expectedMessage = 'Flutter failed to read a file at' ;
592595 expect (() => file.readAsStringSync (),
593596 throwsToolExit (message: expectedMessage));
597+ expect (() => fs.currentDirectory,
598+ throwsToolExit (message: 'The flutter tool cannot access the file or directory' ));
594599 });
595600 });
596601
0 commit comments