Unverified Commit d220631e authored by Zachary Anderson's avatar Zachary Anderson Committed by GitHub

[flutter_tool] Fix bug in manifest yaml validation (#38472)

parent 9cba33d0
......@@ -355,8 +355,9 @@ void _validateFlutter(YamlMap yaml, List<String> errors) {
case 'fonts':
if (kvp.value is! YamlList || kvp.value[0] is! YamlMap) {
errors.add('Expected "${kvp.key}" to be a list, but got ${kvp.value} (${kvp.value.runtimeType}).');
} else {
_validateFonts(kvp.value, errors);
}
_validateFonts(kvp.value, errors);
break;
case 'module':
if (kvp.value is! YamlMap) {
......
......@@ -519,6 +519,25 @@ flutter:
expect(logger.errorText, contains('Expected "fonts" to either be null or a list.'));
});
testUsingContext('Returns proper error when font is a map instead of a list', () async {
final BufferLogger logger = context.get<Logger>();
const String manifest = '''
name: test
dependencies:
flutter:
sdk: flutter
flutter:
fonts:
family: foo
fonts:
-asset: a/bar
''';
final FlutterManifest flutterManifest = FlutterManifest.createFromString(manifest);
expect(flutterManifest, null);
expect(logger.errorText, contains('Expected "fonts" to be a list'));
});
testUsingContext('Returns proper error when second font family is invalid', () async {
final BufferLogger logger = context.get<Logger>();
const String manifest = '''
......
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