Normalize localizations with dartfmt in presubmit check (#160395)
Makes the presubmit check independent of whether the files in the repo are dartfmt formatted or not.
This commit is contained in:
parent
79506323b9
commit
9802c1cde7
@ -14,6 +14,7 @@ import 'package:analyzer/dart/ast/ast.dart';
|
||||
import 'package:analyzer/dart/ast/visitor.dart';
|
||||
import 'package:collection/equality.dart';
|
||||
import 'package:crypto/crypto.dart';
|
||||
import 'package:dart_style/dart_style.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
@ -1042,6 +1043,8 @@ Future<void> verifyIntegrationTestTimeouts(String workingDirectory) async {
|
||||
}
|
||||
}
|
||||
|
||||
final DartFormatter _formatter = DartFormatter(languageVersion: DartFormatter.latestLanguageVersion);
|
||||
|
||||
Future<void> verifyInternationalizations(String workingDirectory, String dartExecutable) async {
|
||||
final EvalResult materialGenResult = await _evalCommand(
|
||||
dartExecutable,
|
||||
@ -1067,24 +1070,30 @@ Future<void> verifyInternationalizations(String workingDirectory, String dartExe
|
||||
final String expectedMaterialResult = await File(materialLocalizationsFile).readAsString();
|
||||
final String expectedCupertinoResult = await File(cupertinoLocalizationsFile).readAsString();
|
||||
|
||||
if (materialGenResult.stdout.trim() != expectedMaterialResult.trim()) {
|
||||
// Normalize both with the Dart formatter.
|
||||
final String formattedMaterialGenResult = _formatter.format(materialGenResult.stdout.trim());
|
||||
final String formattedExpectedMaterialResult = _formatter.format(expectedMaterialResult.trim());
|
||||
|
||||
if (formattedMaterialGenResult != formattedExpectedMaterialResult) {
|
||||
foundError(<String>[
|
||||
'<<<<<<< $materialLocalizationsFile',
|
||||
expectedMaterialResult.trim(),
|
||||
formattedExpectedMaterialResult,
|
||||
'=======',
|
||||
materialGenResult.stdout.trim(),
|
||||
formattedMaterialGenResult,
|
||||
'>>>>>>> gen_localizations',
|
||||
'The contents of $materialLocalizationsFile are different from that produced by gen_localizations.',
|
||||
'',
|
||||
'Did you forget to run gen_localizations.dart after updating a .arb file?',
|
||||
]);
|
||||
}
|
||||
if (cupertinoGenResult.stdout.trim() != expectedCupertinoResult.trim()) {
|
||||
final String formattedCupertinoGenResult = _formatter.format(cupertinoGenResult.stdout.trim());
|
||||
final String formattedExpectedCupertinoResult = _formatter.format(expectedCupertinoResult.trim());
|
||||
if (formattedCupertinoGenResult != formattedExpectedCupertinoResult) {
|
||||
foundError(<String>[
|
||||
'<<<<<<< $cupertinoLocalizationsFile',
|
||||
expectedCupertinoResult.trim(),
|
||||
formattedExpectedCupertinoResult,
|
||||
'=======',
|
||||
cupertinoGenResult.stdout.trim(),
|
||||
formattedCupertinoGenResult,
|
||||
'>>>>>>> gen_localizations',
|
||||
'The contents of $cupertinoLocalizationsFile are different from that produced by gen_localizations.',
|
||||
'',
|
||||
|
@ -8,6 +8,7 @@ dependencies:
|
||||
analyzer: 6.11.0
|
||||
args: 2.6.0
|
||||
crypto: 3.0.6
|
||||
dart_style: 2.3.7
|
||||
intl: 0.19.0
|
||||
file: 7.0.1
|
||||
flutter_devicelab:
|
||||
@ -77,4 +78,4 @@ dependencies:
|
||||
dev_dependencies:
|
||||
test_api: 0.7.4
|
||||
|
||||
# PUBSPEC CHECKSUM: cbf1
|
||||
# PUBSPEC CHECKSUM: e284
|
||||
|
Loading…
x
Reference in New Issue
Block a user