Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
ea1b5e3f
Unverified
Commit
ea1b5e3f
authored
Apr 27, 2021
by
Christopher Fujino
Committed by
GitHub
Apr 27, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow flutterManifest to handle empty lists, add unit tests (#81324)
parent
25c72078
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
81 additions
and
5 deletions
+81
-5
flutter_manifest.dart
packages/flutter_tools/lib/src/flutter_manifest.dart
+24
-5
flutter_manifest_test.dart
...utter_tools/test/general.shard/flutter_manifest_test.dart
+57
-0
No files found.
packages/flutter_tools/lib/src/flutter_manifest.dart
View file @
ea1b5e3f
...
...
@@ -495,22 +495,41 @@ void _validateFlutter(YamlMap? yaml, List<String> errors) {
}
break
;
case
'assets'
:
if
(
yamlValue
is
!
YamlList
||
yamlValue
[
0
]
is
!
String
)
{
if
(
yamlValue
is
!
YamlList
)
{
errors
.
add
(
'Expected "
$yamlKey
" to be a list, but got
$yamlValue
(
${yamlValue.runtimeType}
).'
);
}
else
if
(
yamlValue
.
isEmpty
)
{
break
;
}
else
if
(
yamlValue
[
0
]
is
!
String
)
{
errors
.
add
(
'Expected "
$yamlKey
" to be a list of strings, but the first element is
$yamlValue
(
${yamlValue.runtimeType}
).'
,
);
}
break
;
case
'fonts'
:
if
(
yamlValue
is
!
YamlList
||
yamlValue
[
0
]
is
!
YamlMap
)
{
if
(
yamlValue
is
!
YamlList
)
{
errors
.
add
(
'Expected "
$yamlKey
" to be a list, but got
$yamlValue
(
${yamlValue.runtimeType}
).'
);
}
else
if
(
yamlValue
.
isEmpty
)
{
break
;
}
else
if
(
yamlValue
.
first
is
!
YamlMap
)
{
errors
.
add
(
'Expected "
$yamlKey
" to contain maps, but the first element is
$yamlValue
(
${yamlValue.runtimeType}
).'
,
);
}
else
{
_validateFonts
(
yamlValue
,
errors
);
}
break
;
case
'licenses'
:
if
(
yamlValue
is
YamlList
)
{
_validateListType
<
String
>(
yamlValue
,
errors
,
'"
$yamlKey
"'
,
'files'
);
}
else
{
if
(
yamlValue
is
!
YamlList
)
{
errors
.
add
(
'Expected "
$yamlKey
" to be a list of files, but got
$yamlValue
(
${yamlValue.runtimeType}
)'
);
}
else
if
(
yamlValue
.
isEmpty
)
{
break
;
}
else
if
(
yamlValue
.
first
is
!
String
)
{
errors
.
add
(
'Expected "
$yamlKey
" to contain strings, but the first element is
$yamlValue
(
${yamlValue.runtimeType}
).'
,
);
}
else
{
_validateListType
<
String
>(
yamlValue
,
errors
,
'"
$yamlKey
"'
,
'files'
);
}
break
;
case
'module'
:
...
...
packages/flutter_tools/test/general.shard/flutter_manifest_test.dart
View file @
ea1b5e3f
...
...
@@ -767,6 +767,44 @@ flutter:
contains
(
'Expected "fonts" to either be null or a list.'
));
});
testWithoutContext
(
'FlutterManifest ignores empty list of fonts'
,
()
{
const
String
manifest
=
'''
name: test
dependencies:
flutter:
sdk: flutter
flutter:
fonts: []
'''
;
final
BufferLogger
logger
=
BufferLogger
.
test
();
final
FlutterManifest
?
flutterManifest
=
FlutterManifest
.
createFromString
(
manifest
,
logger:
logger
,
);
expect
(
flutterManifest
,
isNotNull
);
expect
(
flutterManifest
!.
fonts
.
length
,
0
);
});
testWithoutContext
(
'FlutterManifest ignores empty list of assets'
,
()
{
const
String
manifest
=
'''
name: test
dependencies:
flutter:
sdk: flutter
flutter:
assets: []
'''
;
final
BufferLogger
logger
=
BufferLogger
.
test
();
final
FlutterManifest
?
flutterManifest
=
FlutterManifest
.
createFromString
(
manifest
,
logger:
logger
,
);
expect
(
flutterManifest
,
isNotNull
);
expect
(
flutterManifest
!.
assets
.
length
,
0
);
});
testWithoutContext
(
'FlutterManifest returns proper error when font detail is '
'not a list of maps'
,
()
{
const
String
manifest
=
'''
...
...
@@ -1086,6 +1124,25 @@ flutter:
contains
(
'Cannot find the `flutter.plugin.platforms` key in the `pubspec.yaml` file. '
));
});
testWithoutContext
(
'FlutterManifest handles empty licenses list'
,
()
async
{
const
String
manifest
=
'''
name: test
dependencies:
flutter:
sdk: flutter
flutter:
licenses: []
'''
;
final
BufferLogger
logger
=
BufferLogger
.
test
();
final
FlutterManifest
?
flutterManifest
=
FlutterManifest
.
createFromString
(
manifest
,
logger:
logger
,
);
expect
(
flutterManifest
,
isNotNull
);
expect
(
flutterManifest
!.
additionalLicenses
.
length
,
0
);
});
testWithoutContext
(
'FlutterManifest can specify additional LICENSE files'
,
()
async
{
const
String
manifest
=
'''
name: test
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment