[flutter_tools] add EPERM to set of immediate exit errors (#66159)
This commit is contained in:
@@ -85,6 +85,14 @@ void setupDirectoryMocks({
|
||||
.thenThrow(FileSystemException('', '', OSError('', errorCode)));
|
||||
when(mockDirectory.createSync(recursive: anyNamed('recursive')))
|
||||
.thenThrow(FileSystemException('', '', OSError('', errorCode)));
|
||||
when(mockDirectory.create())
|
||||
.thenThrow(FileSystemException('', '', OSError('', errorCode)));
|
||||
when(mockDirectory.createSync())
|
||||
.thenThrow(FileSystemException('', '', OSError('', errorCode)));
|
||||
when(mockDirectory.delete())
|
||||
.thenThrow(FileSystemException('', '', OSError('', errorCode)));
|
||||
when(mockDirectory.deleteSync())
|
||||
.thenThrow(FileSystemException('', '', OSError('', errorCode)));
|
||||
}
|
||||
|
||||
void main() {
|
||||
@@ -198,6 +206,7 @@ void main() {
|
||||
});
|
||||
|
||||
group('throws ToolExit on Linux', () {
|
||||
const int eperm = 1;
|
||||
const int enospc = 28;
|
||||
const int eacces = 13;
|
||||
MockFileSystem mockFileSystem;
|
||||
@@ -221,7 +230,7 @@ void main() {
|
||||
|
||||
final File file = fs.file('file');
|
||||
|
||||
const String expectedMessage = 'The flutter tool cannot access the file';
|
||||
const String expectedMessage = 'The flutter tool cannot access the file or directory';
|
||||
expect(() async => await file.writeAsBytes(<int>[0]),
|
||||
throwsToolExit(message: expectedMessage));
|
||||
expect(() async => await file.writeAsString(''),
|
||||
@@ -234,6 +243,26 @@ void main() {
|
||||
throwsToolExit(message: expectedMessage));
|
||||
});
|
||||
|
||||
testWithoutContext('when access is denied for directories', () async {
|
||||
setupDirectoryMocks(
|
||||
mockFileSystem: mockFileSystem,
|
||||
fs: fs,
|
||||
errorCode: eperm,
|
||||
);
|
||||
|
||||
final Directory directory = fs.directory('file');
|
||||
|
||||
const String expectedMessage = 'The flutter tool cannot access the file or directory';
|
||||
expect(() async => await directory.create(),
|
||||
throwsToolExit(message: expectedMessage));
|
||||
expect(() async => await directory.delete(),
|
||||
throwsToolExit(message: expectedMessage));
|
||||
expect(() => directory.createSync(),
|
||||
throwsToolExit(message: expectedMessage));
|
||||
expect(() => directory.deleteSync(),
|
||||
throwsToolExit(message: expectedMessage));
|
||||
});
|
||||
|
||||
testWithoutContext('when writing to a full device', () async {
|
||||
setupWriteMocks(
|
||||
mockFileSystem: mockFileSystem,
|
||||
@@ -273,6 +302,7 @@ void main() {
|
||||
|
||||
|
||||
group('throws ToolExit on macOS', () {
|
||||
const int eperm = 1;
|
||||
const int enospc = 28;
|
||||
const int eacces = 13;
|
||||
MockFileSystem mockFileSystem;
|
||||
@@ -309,6 +339,26 @@ void main() {
|
||||
throwsToolExit(message: expectedMessage));
|
||||
});
|
||||
|
||||
testWithoutContext('when access is denied for directories', () async {
|
||||
setupDirectoryMocks(
|
||||
mockFileSystem: mockFileSystem,
|
||||
fs: fs,
|
||||
errorCode: eperm,
|
||||
);
|
||||
|
||||
final Directory directory = fs.directory('file');
|
||||
|
||||
const String expectedMessage = 'The flutter tool cannot access the file or directory';
|
||||
expect(() async => await directory.create(),
|
||||
throwsToolExit(message: expectedMessage));
|
||||
expect(() async => await directory.delete(),
|
||||
throwsToolExit(message: expectedMessage));
|
||||
expect(() => directory.createSync(),
|
||||
throwsToolExit(message: expectedMessage));
|
||||
expect(() => directory.deleteSync(),
|
||||
throwsToolExit(message: expectedMessage));
|
||||
});
|
||||
|
||||
testWithoutContext('when writing to a full device', () async {
|
||||
setupWriteMocks(
|
||||
mockFileSystem: mockFileSystem,
|
||||
|
||||
Reference in New Issue
Block a user