Unverified Commit 500d7c50 authored by Zachary Anderson's avatar Zachary Anderson Committed by GitHub

[flutter_tool] Additional flutter manifest yaml validation (#37422)

parent 4ccd8119
......@@ -404,7 +404,12 @@ void _validateFonts(YamlList fonts, List<String> errors) {
const Set<int> fontWeights = <int>{
100, 200, 300, 400, 500, 600, 700, 800, 900,
};
for (final YamlMap fontMap in fonts) {
for (final dynamic fontListEntry in fonts) {
if (fontListEntry is! YamlMap) {
errors.add('Unexpected child "$fontListEntry" found under "fonts". Expected a map.');
continue;
}
final YamlMap fontMap = fontListEntry;
for (dynamic key in fontMap.keys.where((dynamic key) => key != 'family' && key != 'fonts')) {
errors.add('Unexpected child "$key" found under "fonts".');
}
......
......@@ -518,6 +518,26 @@ flutter:
expect(flutterManifest, null);
expect(logger.errorText, contains('Expected "fonts" to either be null or a list.'));
});
testUsingContext('Returns proper error when second font family is invalid', () async {
final BufferLogger logger = context.get<Logger>();
const String manifest = '''
name: test
dependencies:
flutter:
sdk: flutter
flutter:
uses-material-design: true
fonts:
- family: foo
fonts:
- asset: a/bar
- string
''';
final FlutterManifest flutterManifest = FlutterManifest.createFromString(manifest);
expect(flutterManifest, null);
expect(logger.errorText, contains('Expected a map.'));
});
});
group('FlutterManifest with MemoryFileSystem', () {
......
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