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:
committed by
GitHub
parent
818133b8b0
commit
19a212b5ac
1
.ci.yaml
1
.ci.yaml
@@ -389,7 +389,6 @@ targets:
|
||||
- name: Linux packages_autoroller
|
||||
presubmit: false
|
||||
recipe: pub_autoroller/pub_autoroller
|
||||
bringup: true # https://github.com/flutter/flutter/issues/160473
|
||||
# This takes a while because we need to fetch network dependencies and run
|
||||
# Gradle for every android app in the repo
|
||||
timeout: 45
|
||||
|
||||
@@ -20,3 +20,5 @@ template-arb-file: stocks_en.arb
|
||||
## StockStrings getter. This removes the need for adding null checks
|
||||
## in the Flutter application itself.
|
||||
nullable-getter: false
|
||||
## Run the formatter on the generated localization files.
|
||||
format: true
|
||||
|
||||
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user