[flutter_tools] handle OSError 2 from current working directory (#78380)
This commit is contained in:
@@ -8,6 +8,7 @@ import 'dart:io' as io; // ignore: dart_io_import;
|
||||
|
||||
import 'package:file/file.dart';
|
||||
import 'package:file/memory.dart';
|
||||
import 'package:file_testing/file_testing.dart';
|
||||
import 'package:flutter_tools/src/base/common.dart';
|
||||
import 'package:flutter_tools/src/base/error_handling_io.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
@@ -370,6 +371,7 @@ void main() {
|
||||
const int eperm = 1;
|
||||
const int enospc = 28;
|
||||
const int eacces = 13;
|
||||
|
||||
MockFileSystem mockFileSystem;
|
||||
ErrorHandlingFileSystem fs;
|
||||
|
||||
@@ -475,6 +477,19 @@ void main() {
|
||||
expect(() => directory.existsSync(),
|
||||
throwsToolExit(message: expectedMessage));
|
||||
});
|
||||
|
||||
testWithoutContext('When the current working directory disappears', () async {
|
||||
setupReadMocks(
|
||||
mockFileSystem: mockFileSystem,
|
||||
fs: fs,
|
||||
errorCode: kSystemCannotFindFile,
|
||||
);
|
||||
|
||||
expect(() => fs.currentDirectory, throwsToolExit(message: 'Unable to read current working directory'));
|
||||
|
||||
// Error is not caught by other operations.
|
||||
expect(() => fs.file('foo').readAsStringSync(), throwsFileSystemException(kSystemCannotFindFile));
|
||||
});
|
||||
});
|
||||
|
||||
group('throws ToolExit on macOS', () {
|
||||
|
||||
Reference in New Issue
Block a user