Skip to content

Commit

Permalink
Handle FormatException from SkiaGoldClient (#143755)
Browse files Browse the repository at this point in the history
  • Loading branch information
zanderso authored Feb 20, 2024
1 parent 6200026 commit 8a8616f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/flutter_goldens/lib/flutter_goldens.dart
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,13 @@ class FlutterLocalFileComparator extends FlutterGoldenFileComparator with LocalC
'SocketException occurred, could not reach Gold. '
'Switching to FlutterSkippingGoldenFileComparator.',
);
} on FormatException catch (_) {
return FlutterSkippingFileComparator(
baseDirectory.uri,
goldens,
'FormatException occurred, could not reach Gold. '
'Switching to FlutterSkippingGoldenFileComparator.',
);
}

return FlutterLocalFileComparator(baseDirectory.uri, goldens);
Expand Down
10 changes: 10 additions & 0 deletions packages/flutter_goldens/test/flutter_goldens_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1160,6 +1160,16 @@ void main() {
baseDirectory: fakeDirectory,
);
expect(comparator.runtimeType, FlutterSkippingFileComparator);

fakeSkiaClient.getExpectationForTestThrowable = const FormatException("Can't reach Gold");

comparator = await FlutterLocalFileComparator.fromDefaultComparator(
platform,
goldens: fakeSkiaClient,
baseDirectory: fakeDirectory,
);
expect(comparator.runtimeType, FlutterSkippingFileComparator);

// reset property or it will carry on to other tests
fakeSkiaClient.getExpectationForTestThrowable = null;
});
Expand Down

0 comments on commit 8a8616f

Please sign in to comment.