Check that localization files of stocks app are up-to-date (#161608)

Fixes https://github.com/flutter/flutter/issues/160473
This commit is contained in:
Michael Goderbauer
2025-01-14 12:47:08 -08:00
committed by GitHub
parent 818133b8b0
commit 19a212b5ac
3 changed files with 48 additions and 1 deletions

View File

@@ -152,6 +152,9 @@ Future<void> run(List<String> arguments) async {
printProgress('Internationalization...');
await verifyInternationalizations(flutterRoot, dart);
printProgress('Localization files of stocks app...');
await verifyStockAppLocalizations(flutterRoot);
printProgress('Integration test timeouts...');
await verifyIntegrationTestTimeouts(flutterRoot);
@@ -1312,6 +1315,49 @@ Future<void> verifyInternationalizations(String workingDirectory, String dartExe
}
}
Future<void> verifyStockAppLocalizations(String workingDirectory) async {
final Directory appRoot = Directory(
path.join(workingDirectory, 'dev', 'benchmarks', 'test_apps', 'stocks'),
);
if (!appRoot.existsSync()) {
foundError(<String>['Stocks app does not exist at expected location: ${appRoot.path}']);
}
// Regenerate the localizations.
final String flutterExecutable = path.join(
workingDirectory,
'bin',
'flutter${Platform.isWindows ? '.bat' : ''}',
);
await _evalCommand(flutterExecutable, const <String>['gen-l10n'], workingDirectory: appRoot.path);
final Directory i10nDirectory = Directory(path.join(appRoot.path, 'lib', 'i18n'));
if (!i10nDirectory.existsSync()) {
foundError(<String>[
'Localization files for stocks app not found at expected location: ${i10nDirectory.path}',
]);
}
// Check that regeneration did not dirty the tree.
final EvalResult result = await _evalCommand('git', <String>[
'diff',
'--name-only',
'--exit-code',
i10nDirectory.path,
], workingDirectory: workingDirectory);
if (result.exitCode == 1) {
foundError(<String>[
'The following localization files for the stocks app appear to be out of date:',
...(const LineSplitter().convert(result.stdout).map((String line) => ' * $line')),
'Run "flutter gen-l10n" in "${path.relative(appRoot.path, from: workingDirectory)}" to regenerate.',
]);
} else if (result.exitCode != 0) {
foundError(<String>[
'Failed to run "git diff" on localization files of stocks app:',
result.stderr,
]);
}
}
/// Verifies that all instances of "checked mode" have been migrated to "debug mode".
Future<void> verifyNoCheckedMode(String workingDirectory) async {
final String flutterPackages = path.join(workingDirectory, 'packages');