anchor.diff:               throwsToolExit(message: expectedMessage));
       });
   
  -    testWithoutContext('When reading from a file or directory without permission', () {
  -      setupReadMocks(
  -        mockFileSystem: mockFileSystem,
  -        fs: fs,
  -        errorCode: eacces,
  -      );
  -
  -      final File file = fs.file('file');
  +    testWithoutContext('When reading from a file without permission', () {
  +       final ErrorHandlingFileSystem fileSystem = ErrorHandlingFileSystem(
  +        delegate: MemoryFileSystem.test(opHandle: exceptionHandler.opHandle),
  +        platform: linuxPlatform,
  +      );
  +      final File file = fileSystem.file('file');
  +
  +      exceptionHandler.addError(
  +        file,
  +        FileSystemOp.read,
  +        FileSystemException('', file.path, const OSError('', eacces)),
  +      );
   
         const String expectedMessage = 'Flutter failed to read a file at';
         expect(() => file.readAsStringSync(),
                throwsToolExit(message: expectedMessage));
  -      expect(() => fs.currentDirectory,
  +    });
  +
  +    testWithoutContext('When reading from current directory without permission', () {
  +     final ErrorHandlingFileSystem fileSystem = ErrorHandlingFileSystem(
  +        delegate: ThrowsOnCurrentDirectoryFileSystem()..errorCode = eacces,
  +        platform: linuxPlatform,
  +      );
  +
  +      expect(() => fileSystem.currentDirectory,
                throwsToolExit(message: 'The flutter tool cannot access the file or directory'));
       });
     });
  
positive.code:     throw _exception;
    }
  }
  
negative.code:     });
  
      testWithoutContext('When the current working directory disappears', () async {
       final ErrorHandlingFileSystem fileSystem = ErrorHandlingFileSystem(
          delegate: ThrowsOnCurrentDirectoryFileSystem()..errorCode = kSystemCannotFindFile,
          platform: linuxPlatform,
        );
  
        expect(() => fileSystem.currentDirectory, throwsToolExit(message: 'Unable to read current working directory'));
      });
  
      testWithoutContext('Rethrows os error $kSystemCannotFindFile', () {
         final ErrorHandlingFileSystem fileSystem = ErrorHandlingFileSystem(
          delegate: MemoryFileSystem.test(opHandle: exceptionHandler.opHandle),
          platform: linuxPlatform,
        );
        final File file = fileSystem.file('file');
  
        exceptionHandler.addError(
          file,
          FileSystemOp.read,
          FileSystemException('', file.path, const OSError('', kSystemCannotFindFile)),
        );
  
        // Error is not caught by other operations.
        expect(() => fileSystem.file('foo').readAsStringSync(), throwsFileSystemException(kSystemCannotFindFile));
      });
    });
  
  