File tree Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -942,7 +942,13 @@ class LocalizationsGenerator {
942
942
@visibleForTesting
943
943
static File templateArbFileFromFileName (String templateArbFileName, Directory inputDirectory) {
944
944
final File templateArbFile = inputDirectory.childFile (templateArbFileName);
945
- final String templateArbFileStatModeString = templateArbFile.statSync ().modeString ();
945
+ final FileStat templateArbFileStat = templateArbFile.statSync ();
946
+ if (templateArbFileStat.type == FileSystemEntityType .notFound) {
947
+ throw L10nException (
948
+ "The 'template-arb-file', $templateArbFile , does not exist."
949
+ );
950
+ }
951
+ final String templateArbFileStatModeString = templateArbFileStat.modeString ();
946
952
if (templateArbFileStatModeString[0 ] == '-' && templateArbFileStatModeString[3 ] == '-' ) {
947
953
throw L10nException (
948
954
"The 'template-arb-file', $templateArbFile , is not readable.\n "
Original file line number Diff line number Diff line change @@ -180,6 +180,32 @@ void main() {
180
180
);
181
181
});
182
182
183
+ testWithoutContext ('throws error when arb file does not exist' , () {
184
+ // Set up project directory.
185
+ fs.currentDirectory
186
+ .childDirectory ('lib' )
187
+ .childDirectory ('l10n' )
188
+ .createSync (recursive: true );
189
+
190
+ // Arb file should be nonexistent in the l10n directory.
191
+ expect (
192
+ () => LocalizationsGenerator (
193
+ fileSystem: fs,
194
+ projectPathString: './' ,
195
+ inputPathString: defaultL10nPathString,
196
+ outputPathString: defaultL10nPathString,
197
+ templateArbFileName: defaultTemplateArbFileName,
198
+ outputFileString: defaultOutputFileString,
199
+ classNameString: defaultClassNameString,
200
+ ),
201
+ throwsA (isA <L10nException >().having (
202
+ (L10nException e) => e.message,
203
+ 'message' ,
204
+ contains (', does not exist.' ),
205
+ )),
206
+ );
207
+ });
208
+
183
209
group ('className should only take valid Dart class names' , () {
184
210
setUp (() {
185
211
_standardFlutterDirectoryL10nSetup (fs);
You can’t perform that action at this time.
0 commit comments