mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
[gen_l10n] Throw error when arb file does not exist (#107583)
This commit is contained in:
parent
c4975d9be0
commit
2da228593f
@ -942,7 +942,13 @@ class LocalizationsGenerator {
|
||||
@visibleForTesting
|
||||
static File templateArbFileFromFileName(String templateArbFileName, Directory inputDirectory) {
|
||||
final File templateArbFile = inputDirectory.childFile(templateArbFileName);
|
||||
final String templateArbFileStatModeString = templateArbFile.statSync().modeString();
|
||||
final FileStat templateArbFileStat = templateArbFile.statSync();
|
||||
if (templateArbFileStat.type == FileSystemEntityType.notFound) {
|
||||
throw L10nException(
|
||||
"The 'template-arb-file', $templateArbFile, does not exist."
|
||||
);
|
||||
}
|
||||
final String templateArbFileStatModeString = templateArbFileStat.modeString();
|
||||
if (templateArbFileStatModeString[0] == '-' && templateArbFileStatModeString[3] == '-') {
|
||||
throw L10nException(
|
||||
"The 'template-arb-file', $templateArbFile, is not readable.\n"
|
||||
|
@ -180,6 +180,32 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWithoutContext('throws error when arb file does not exist', () {
|
||||
// Set up project directory.
|
||||
fs.currentDirectory
|
||||
.childDirectory('lib')
|
||||
.childDirectory('l10n')
|
||||
.createSync(recursive: true);
|
||||
|
||||
// Arb file should be nonexistent in the l10n directory.
|
||||
expect(
|
||||
() => LocalizationsGenerator(
|
||||
fileSystem: fs,
|
||||
projectPathString: './',
|
||||
inputPathString: defaultL10nPathString,
|
||||
outputPathString: defaultL10nPathString,
|
||||
templateArbFileName: defaultTemplateArbFileName,
|
||||
outputFileString: defaultOutputFileString,
|
||||
classNameString: defaultClassNameString,
|
||||
),
|
||||
throwsA(isA<L10nException>().having(
|
||||
(L10nException e) => e.message,
|
||||
'message',
|
||||
contains(', does not exist.'),
|
||||
)),
|
||||
);
|
||||
});
|
||||
|
||||
group('className should only take valid Dart class names', () {
|
||||
setUp(() {
|
||||
_standardFlutterDirectoryL10nSetup(fs);
|
||||
|
Loading…
Reference in New Issue
Block a user