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
28d70769
Unverified
Commit
28d70769
authored
Mar 22, 2023
by
Christopher Fujino
Committed by
GitHub
Mar 22, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
toolexit on malformed yaml (#123167)
[flutter_tools] toolexit on malformed yaml during gen-l10n
parent
4be45e95
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
1 deletion
+22
-1
localizations_utils.dart
...tter_tools/lib/src/localizations/localizations_utils.dart
+7
-1
localizations_test.dart
...eneral.shard/build_system/targets/localizations_test.dart
+15
-0
No files found.
packages/flutter_tools/lib/src/localizations/localizations_utils.dart
View file @
28d70769
...
...
@@ -5,6 +5,7 @@
import
'package:meta/meta.dart'
;
import
'package:yaml/yaml.dart'
;
import
'../base/common.dart'
;
import
'../base/file_system.dart'
;
import
'../base/logger.dart'
;
import
'gen_l10n_types.dart'
;
...
...
@@ -436,7 +437,12 @@ LocalizationOptions parseLocalizationsOptions({
if
(
contents
.
trim
().
isEmpty
)
{
return
const
LocalizationOptions
();
}
final
YamlNode
yamlNode
=
loadYamlNode
(
file
.
readAsStringSync
());
final
YamlNode
yamlNode
;
try
{
yamlNode
=
loadYamlNode
(
file
.
readAsStringSync
());
}
on
YamlException
catch
(
err
)
{
throwToolExit
(
err
.
message
);
}
if
(
yamlNode
is
!
YamlMap
)
{
logger
.
printError
(
'Expected
${file.path}
to contain a map, instead was
$yamlNode
'
);
throw
Exception
();
...
...
packages/flutter_tools/test/general.shard/build_system/targets/localizations_test.dart
View file @
28d70769
...
...
@@ -98,4 +98,19 @@ use-deferred-loading: string
throwsException
,
);
});
testWithoutContext
(
'parseLocalizationsOptions tool exits on malformed Yaml'
,
()
async
{
final
FileSystem
fileSystem
=
MemoryFileSystem
.
test
();
final
File
configFile
=
fileSystem
.
file
(
'l10n.yaml'
)..
writeAsStringSync
(
'''
template-arb-file: {name}_en.arb
'''
);
expect
(
()
=>
parseLocalizationsOptions
(
file:
configFile
,
logger:
BufferLogger
.
test
(),
),
throwsToolExit
(),
);
});
}
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