Skip to content

Commit e1691db

Browse files
goderbauermaheshj01
authored andcommitted
Check that localization files of stocks app are up-to-date (flutter#161608)
Fixes flutter#160473
1 parent 9fe9267 commit e1691db

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed

.ci.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,6 @@ targets:
389389
- name: Linux packages_autoroller
390390
presubmit: false
391391
recipe: pub_autoroller/pub_autoroller
392-
bringup: true # https://github.com/flutter/flutter/issues/160473
393392
# This takes a while because we need to fetch network dependencies and run
394393
# Gradle for every android app in the repo
395394
timeout: 45

dev/benchmarks/test_apps/stocks/l10n.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,5 @@ template-arb-file: stocks_en.arb
2020
## StockStrings getter. This removes the need for adding null checks
2121
## in the Flutter application itself.
2222
nullable-getter: false
23+
## Run the formatter on the generated localization files.
24+
format: true

dev/bots/analyze.dart

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ Future<void> run(List<String> arguments) async {
152152
printProgress('Internationalization...');
153153
await verifyInternationalizations(flutterRoot, dart);
154154

155+
printProgress('Localization files of stocks app...');
156+
await verifyStockAppLocalizations(flutterRoot);
157+
155158
printProgress('Integration test timeouts...');
156159
await verifyIntegrationTestTimeouts(flutterRoot);
157160

@@ -1312,6 +1315,49 @@ Future<void> verifyInternationalizations(String workingDirectory, String dartExe
13121315
}
13131316
}
13141317

1318+
Future<void> verifyStockAppLocalizations(String workingDirectory) async {
1319+
final Directory appRoot = Directory(
1320+
path.join(workingDirectory, 'dev', 'benchmarks', 'test_apps', 'stocks'),
1321+
);
1322+
if (!appRoot.existsSync()) {
1323+
foundError(<String>['Stocks app does not exist at expected location: ${appRoot.path}']);
1324+
}
1325+
1326+
// Regenerate the localizations.
1327+
final String flutterExecutable = path.join(
1328+
workingDirectory,
1329+
'bin',
1330+
'flutter${Platform.isWindows ? '.bat' : ''}',
1331+
);
1332+
await _evalCommand(flutterExecutable, const <String>['gen-l10n'], workingDirectory: appRoot.path);
1333+
final Directory i10nDirectory = Directory(path.join(appRoot.path, 'lib', 'i18n'));
1334+
if (!i10nDirectory.existsSync()) {
1335+
foundError(<String>[
1336+
'Localization files for stocks app not found at expected location: ${i10nDirectory.path}',
1337+
]);
1338+
}
1339+
1340+
// Check that regeneration did not dirty the tree.
1341+
final EvalResult result = await _evalCommand('git', <String>[
1342+
'diff',
1343+
'--name-only',
1344+
'--exit-code',
1345+
i10nDirectory.path,
1346+
], workingDirectory: workingDirectory);
1347+
if (result.exitCode == 1) {
1348+
foundError(<String>[
1349+
'The following localization files for the stocks app appear to be out of date:',
1350+
...(const LineSplitter().convert(result.stdout).map((String line) => ' * $line')),
1351+
'Run "flutter gen-l10n" in "${path.relative(appRoot.path, from: workingDirectory)}" to regenerate.',
1352+
]);
1353+
} else if (result.exitCode != 0) {
1354+
foundError(<String>[
1355+
'Failed to run "git diff" on localization files of stocks app:',
1356+
result.stderr,
1357+
]);
1358+
}
1359+
}
1360+
13151361
/// Verifies that all instances of "checked mode" have been migrated to "debug mode".
13161362
Future<void> verifyNoCheckedMode(String workingDirectory) async {
13171363
final String flutterPackages = path.join(workingDirectory, 'packages');

0 commit comments

Comments
 (0)