Unverified Commit 131f59f1 authored by Perqin's avatar Perqin Committed by GitHub

[flutter_tools] Avoid duplicated calls to l10n generation (#76066)

parent 3e5efc02
...@@ -74,3 +74,4 @@ Andrey Kabylin <andrey@kabylin.ru> ...@@ -74,3 +74,4 @@ Andrey Kabylin <andrey@kabylin.ru>
vimerzhao <vimerzhao@gmail.com> vimerzhao <vimerzhao@gmail.com>
Pedro Massango <pedromassango.developer@gmail.com> Pedro Massango <pedromassango.developer@gmail.com>
Hidenori Matsubayashi <Hidenori.Matsubayashi@sony.com> Hidenori Matsubayashi <Hidenori.Matsubayashi@sony.com>
Perqin Xie <perqinxie@gmail.com>
...@@ -37,15 +37,9 @@ Future<void> generateLocalizationsSyntheticPackage({ ...@@ -37,15 +37,9 @@ Future<void> generateLocalizationsSyntheticPackage({
); );
} }
BuildResult result; // If an l10n.yaml file exists and is not empty, attempt to parse settings in
// If an l10n.yaml file exists but is empty, attempt to build synthetic // it.
// package with default settings. if (yamlNode.value != null) {
if (yamlNode.value == null) {
result = await buildSystem.build(
const GenerateLocalizationsTarget(),
environment,
);
} else {
final YamlMap yamlMap = yamlNode as YamlMap; final YamlMap yamlMap = yamlNode as YamlMap;
final Object value = yamlMap['synthetic-package']; final Object value = yamlMap['synthetic-package'];
if (value is! bool && value != null) { if (value is! bool && value != null) {
...@@ -63,7 +57,7 @@ Future<void> generateLocalizationsSyntheticPackage({ ...@@ -63,7 +57,7 @@ Future<void> generateLocalizationsSyntheticPackage({
} }
} }
result = await buildSystem.build( final BuildResult result = await buildSystem.build(
const GenerateLocalizationsTarget(), const GenerateLocalizationsTarget(),
environment, environment,
); );
......
...@@ -18,7 +18,7 @@ import '../../src/context.dart'; ...@@ -18,7 +18,7 @@ import '../../src/context.dart';
import '../../src/fake_process_manager.dart'; import '../../src/fake_process_manager.dart';
void main() { void main() {
testWithoutContext('calls buildSystem.build with blank l10n.yaml file', () { testWithoutContext('calls buildSystem.build with blank l10n.yaml file', () async {
// Project directory setup for gen_l10n logic // Project directory setup for gen_l10n logic
final MemoryFileSystem fileSystem = MemoryFileSystem.test(); final MemoryFileSystem fileSystem = MemoryFileSystem.test();
...@@ -44,7 +44,7 @@ void main() { ...@@ -44,7 +44,7 @@ void main() {
); );
final BuildSystem buildSystem = MockBuildSystem(); final BuildSystem buildSystem = MockBuildSystem();
expect( await expectLater(
() => generateLocalizationsSyntheticPackage( () => generateLocalizationsSyntheticPackage(
environment: environment, environment: environment,
buildSystem: buildSystem, buildSystem: buildSystem,
...@@ -58,7 +58,7 @@ void main() { ...@@ -58,7 +58,7 @@ void main() {
)).called(1); )).called(1);
}); });
testWithoutContext('calls buildSystem.build with l10n.yaml synthetic-package: true', () { testWithoutContext('calls buildSystem.build with l10n.yaml synthetic-package: true', () async {
// Project directory setup for gen_l10n logic // Project directory setup for gen_l10n logic
final MemoryFileSystem fileSystem = MemoryFileSystem.test(); final MemoryFileSystem fileSystem = MemoryFileSystem.test();
...@@ -85,7 +85,7 @@ void main() { ...@@ -85,7 +85,7 @@ void main() {
); );
final BuildSystem buildSystem = MockBuildSystem(); final BuildSystem buildSystem = MockBuildSystem();
expect( await expectLater(
() => generateLocalizationsSyntheticPackage( () => generateLocalizationsSyntheticPackage(
environment: environment, environment: environment,
buildSystem: buildSystem, buildSystem: buildSystem,
...@@ -99,7 +99,7 @@ void main() { ...@@ -99,7 +99,7 @@ void main() {
)).called(1); )).called(1);
}); });
testWithoutContext('calls buildSystem.build with l10n.yaml synthetic-package: null', () { testWithoutContext('calls buildSystem.build with l10n.yaml synthetic-package: null', () async {
// Project directory setup for gen_l10n logic // Project directory setup for gen_l10n logic
final MemoryFileSystem fileSystem = MemoryFileSystem.test(); final MemoryFileSystem fileSystem = MemoryFileSystem.test();
...@@ -124,7 +124,7 @@ void main() { ...@@ -124,7 +124,7 @@ void main() {
); );
final BuildSystem buildSystem = MockBuildSystem(); final BuildSystem buildSystem = MockBuildSystem();
expect( await expectLater(
() => generateLocalizationsSyntheticPackage( () => generateLocalizationsSyntheticPackage(
environment: environment, environment: environment,
buildSystem: buildSystem, buildSystem: buildSystem,
...@@ -171,7 +171,7 @@ void main() { ...@@ -171,7 +171,7 @@ void main() {
)); ));
}); });
testWithoutContext('does not call buildSystem.build with incorrect l10n.yaml format', () { testWithoutContext('does not call buildSystem.build with incorrect l10n.yaml format', () async {
// Project directory setup for gen_l10n logic // Project directory setup for gen_l10n logic
final MemoryFileSystem fileSystem = MemoryFileSystem.test(); final MemoryFileSystem fileSystem = MemoryFileSystem.test();
...@@ -196,7 +196,7 @@ void main() { ...@@ -196,7 +196,7 @@ void main() {
); );
final BuildSystem buildSystem = MockBuildSystem(); final BuildSystem buildSystem = MockBuildSystem();
expect( await expectLater(
() => generateLocalizationsSyntheticPackage( () => generateLocalizationsSyntheticPackage(
environment: environment, environment: environment,
buildSystem: buildSystem, buildSystem: buildSystem,
...@@ -210,7 +210,7 @@ void main() { ...@@ -210,7 +210,7 @@ void main() {
)); ));
}); });
testWithoutContext('does not call buildSystem.build with non-bool "synthetic-package" value', () { testWithoutContext('does not call buildSystem.build with non-bool "synthetic-package" value', () async {
// Project directory setup for gen_l10n logic // Project directory setup for gen_l10n logic
final MemoryFileSystem fileSystem = MemoryFileSystem.test(); final MemoryFileSystem fileSystem = MemoryFileSystem.test();
...@@ -235,7 +235,7 @@ void main() { ...@@ -235,7 +235,7 @@ void main() {
); );
final BuildSystem buildSystem = MockBuildSystem(); final BuildSystem buildSystem = MockBuildSystem();
expect( await expectLater(
() => generateLocalizationsSyntheticPackage( () => generateLocalizationsSyntheticPackage(
environment: environment, environment: environment,
buildSystem: buildSystem, buildSystem: buildSystem,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment