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>
vimerzhao <vimerzhao@gmail.com>
Pedro Massango <pedromassango.developer@gmail.com>
Hidenori Matsubayashi <Hidenori.Matsubayashi@sony.com>
Perqin Xie <perqinxie@gmail.com>
......@@ -37,15 +37,9 @@ Future<void> generateLocalizationsSyntheticPackage({
);
}
BuildResult result;
// If an l10n.yaml file exists but is empty, attempt to build synthetic
// package with default settings.
if (yamlNode.value == null) {
result = await buildSystem.build(
const GenerateLocalizationsTarget(),
environment,
);
} else {
// If an l10n.yaml file exists and is not empty, attempt to parse settings in
// it.
if (yamlNode.value != null) {
final YamlMap yamlMap = yamlNode as YamlMap;
final Object value = yamlMap['synthetic-package'];
if (value is! bool && value != null) {
......@@ -63,7 +57,7 @@ Future<void> generateLocalizationsSyntheticPackage({
}
}
result = await buildSystem.build(
final BuildResult result = await buildSystem.build(
const GenerateLocalizationsTarget(),
environment,
);
......
......@@ -18,7 +18,7 @@ import '../../src/context.dart';
import '../../src/fake_process_manager.dart';
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
final MemoryFileSystem fileSystem = MemoryFileSystem.test();
......@@ -44,7 +44,7 @@ void main() {
);
final BuildSystem buildSystem = MockBuildSystem();
expect(
await expectLater(
() => generateLocalizationsSyntheticPackage(
environment: environment,
buildSystem: buildSystem,
......@@ -58,7 +58,7 @@ void main() {
)).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
final MemoryFileSystem fileSystem = MemoryFileSystem.test();
......@@ -85,7 +85,7 @@ void main() {
);
final BuildSystem buildSystem = MockBuildSystem();
expect(
await expectLater(
() => generateLocalizationsSyntheticPackage(
environment: environment,
buildSystem: buildSystem,
......@@ -99,7 +99,7 @@ void main() {
)).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
final MemoryFileSystem fileSystem = MemoryFileSystem.test();
......@@ -124,7 +124,7 @@ void main() {
);
final BuildSystem buildSystem = MockBuildSystem();
expect(
await expectLater(
() => generateLocalizationsSyntheticPackage(
environment: environment,
buildSystem: buildSystem,
......@@ -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
final MemoryFileSystem fileSystem = MemoryFileSystem.test();
......@@ -196,7 +196,7 @@ void main() {
);
final BuildSystem buildSystem = MockBuildSystem();
expect(
await expectLater(
() => generateLocalizationsSyntheticPackage(
environment: environment,
buildSystem: buildSystem,
......@@ -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
final MemoryFileSystem fileSystem = MemoryFileSystem.test();
......@@ -235,7 +235,7 @@ void main() {
);
final BuildSystem buildSystem = MockBuildSystem();
expect(
await expectLater(
() => generateLocalizationsSyntheticPackage(
environment: environment,
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