Unverified Commit 9a7e1870 authored by Christopher Fujino's avatar Christopher Fujino Committed by GitHub

[flutter_tools] fix Cannot delete file ENOENT from fuchsia_asset_builder (#119867)

* fix

* add test
parent be4c8c0e
...@@ -116,7 +116,11 @@ class Config { ...@@ -116,7 +116,11 @@ class Config {
if (managed) { if (managed) {
rethrow; rethrow;
} else { } else {
_file.deleteSync(); try {
_file.deleteSync();
} on FileSystemException {
// ignore
}
} }
} on Exception catch (err) { } on Exception catch (err) {
_logger _logger
......
...@@ -130,6 +130,26 @@ void main() { ...@@ -130,6 +130,26 @@ void main() {
expect(bufferLogger.errorText, contains(r'sudo chown -R $(whoami) /testfile')); expect(bufferLogger.errorText, contains(r'sudo chown -R $(whoami) /testfile'));
}); });
testWithoutContext('Config.createForTesting does not error when failing to delete a file', () {
final BufferLogger bufferLogger = BufferLogger.test();
final FileExceptionHandler handler = FileExceptionHandler();
final MemoryFileSystem fs = MemoryFileSystem.test(opHandle: handler.opHandle);
final File file = fs.file('testfile')
// We write invalid JSON so that we test catching a `FormatException`
..writeAsStringSync('{"This is not valid JSON"');
handler.addError(
file,
FileSystemOp.delete,
const FileSystemException(
"Cannot delete file, path = 'testfile' (OS Error: No such file or directory, errno = 2)",
),
);
// Should not throw a FileSystemException
Config.createForTesting(file, bufferLogger);
});
testWithoutContext('Config in home dir is used if it exists', () { testWithoutContext('Config in home dir is used if it exists', () {
memoryFileSystem.file('.flutter_example').writeAsStringSync('{"hello":"bar"}'); memoryFileSystem.file('.flutter_example').writeAsStringSync('{"hello":"bar"}');
config = Config( config = Config(
......
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