Unverified Commit abb48f49 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] add error handling wrapping for File.createSync (#73890)

parent 1eb0bb52
......@@ -263,6 +263,17 @@ class ErrorHandlingFile
);
}
@override
void createSync({bool recursive = false}) {
_runSync<void>(
() => delegate.createSync(
recursive: recursive,
),
platform: _platform,
failureMessage: 'Flutter failed to create file at "${delegate.path}"',
);
}
@override
RandomAccessFile openSync({FileMode mode = FileMode.read}) {
return _runSync<RandomAccessFile>(
......
......@@ -76,6 +76,8 @@ void setupWriteMocks({
when(mockFile.openSync(
mode: anyNamed('mode'),
)).thenThrow(FileSystemException('', '', OSError('', errorCode)));
when(mockFile.createSync(recursive: anyNamed('recursive')))
.thenThrow(FileSystemException('', '', OSError('', errorCode)));
}
void setupReadMocks({
......@@ -230,6 +232,8 @@ void main() {
throwsToolExit(message: expectedMessage));
expect(() => file.openSync(),
throwsToolExit(message: expectedMessage));
expect(() => file.createSync(),
throwsToolExit(message: expectedMessage));
});
testWithoutContext('when writing to a full device', () async {
......@@ -293,6 +297,8 @@ void main() {
throwsToolExit(message: expectedMessage));
expect(() => file.openSync(),
throwsToolExit(message: expectedMessage));
expect(() => file.createSync(),
throwsToolExit(message: expectedMessage));
});
testWithoutContext('when creating a temporary dir on a full device', () async {
......@@ -390,6 +396,8 @@ void main() {
throwsToolExit(message: expectedMessage));
expect(() => file.openSync(),
throwsToolExit(message: expectedMessage));
expect(() => file.createSync(),
throwsToolExit(message: expectedMessage));
});
testWithoutContext('when access is denied for directories', () async {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment