Skip to content

Commit 2e9cb0a

Browse files
authored
[CP] Catch error for missing directory in FontConfigManager (flutter#138496) (flutter#139743)
Closes: - flutter#138434 We will catch any errors while attempting to clear the temp directories that don't exist for the `FontConfigManager` class
1 parent 7417c4e commit 2e9cb0a

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

packages/flutter_tools/lib/src/test/font_config_manager.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ class FontConfigManager {
3434
Future<void> dispose() async {
3535
if (_fontsDirectory != null) {
3636
globals.printTrace('Deleting ${_fontsDirectory!.path}...');
37-
await _fontsDirectory!.delete(recursive: true);
37+
try {
38+
await _fontsDirectory!.delete(recursive: true);
39+
} on FileSystemException {
40+
// Silently exit
41+
}
3842
_fontsDirectory = null;
3943
}
4044
}

packages/flutter_tools/test/general.shard/flutter_tester_device_test.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,18 @@ void main() {
5050
uriConverter: (String input) => '$input/converted',
5151
);
5252

53+
testUsingContext('Missing dir error caught for FontConfigManger.dispose', () async {
54+
final FontConfigManager fontConfigManager = FontConfigManager();
55+
56+
final Directory fontsDirectory = fileSystem.file(fontConfigManager.fontConfigFile).parent;
57+
fontsDirectory.deleteSync(recursive: true);
58+
59+
await fontConfigManager.dispose();
60+
}, overrides: <Type, Generator>{
61+
FileSystem: () => fileSystem,
62+
ProcessManager: () => processManager,
63+
});
64+
5365
group('The FLUTTER_TEST environment variable is passed to the test process', () {
5466
setUp(() {
5567
processManager = FakeProcessManager.list(<FakeCommand>[]);

0 commit comments

Comments
 (0)