🐛 Treat empty ARB content as empty map when decoding (#131242)
Fixes #128932.
This commit is contained in:
@@ -10,6 +10,7 @@ import 'package:flutter_tools/src/build_system/build_system.dart';
|
||||
import 'package:flutter_tools/src/build_system/targets/localizations.dart';
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
import 'package:flutter_tools/src/commands/generate_localizations.dart';
|
||||
import 'package:flutter_tools/src/localizations/gen_l10n_types.dart';
|
||||
|
||||
import '../../integration.shard/test_data/basic_project.dart';
|
||||
import '../../src/common.dart';
|
||||
@@ -501,4 +502,33 @@ format: true
|
||||
throwsToolExit(message: 'Unexpected positional argument "false".')
|
||||
);
|
||||
});
|
||||
|
||||
group(AppResourceBundle, () {
|
||||
testWithoutContext("can be parsed without FormatException when it's content is empty", () {
|
||||
final File arbFile = fileSystem.file(fileSystem.path.join('lib', 'l10n', 'app_en.arb'))
|
||||
..createSync(recursive: true);
|
||||
expect(AppResourceBundle(arbFile), isA<AppResourceBundle>());
|
||||
});
|
||||
|
||||
testUsingContext("would not fail the gen-l10n command when it's content is empty", () async {
|
||||
fileSystem.file(fileSystem.path.join('lib', 'l10n', 'app_en.arb')).createSync(recursive: true);
|
||||
final File pubspecFile = fileSystem.file('pubspec.yaml')..createSync();
|
||||
pubspecFile.writeAsStringSync(BasicProjectWithFlutterGen().pubspec);
|
||||
final GenerateLocalizationsCommand command = GenerateLocalizationsCommand(
|
||||
fileSystem: fileSystem,
|
||||
logger: logger,
|
||||
artifacts: artifacts,
|
||||
processManager: processManager,
|
||||
);
|
||||
await createTestCommandRunner(command).run(<String>['gen-l10n']);
|
||||
|
||||
final Directory outputDirectory = fileSystem.directory(fileSystem.path.join('.dart_tool', 'flutter_gen', 'gen_l10n'));
|
||||
expect(outputDirectory.existsSync(), true);
|
||||
expect(outputDirectory.childFile('app_localizations_en.dart').existsSync(), true);
|
||||
expect(outputDirectory.childFile('app_localizations.dart').existsSync(), true);
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fileSystem,
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user