diff --git a/dev/bots/analyze.dart b/dev/bots/analyze.dart index e24c1fd5730..0b1de1a3e30 100644 --- a/dev/bots/analyze.dart +++ b/dev/bots/analyze.dart @@ -70,7 +70,7 @@ Future run(List arguments) async { await verifyNoBadImportsInFlutterTools(flutterRoot); print('$clock Internationalization...'); - await verifyInternationalizations(); + await verifyInternationalizations(flutterRoot, dart); print('$clock Integration test timeouts...'); await verifyIntegrationTestTimeouts(flutterRoot); @@ -422,26 +422,26 @@ Future verifyIntegrationTestTimeouts(String workingDirectory) async { } } -Future verifyInternationalizations() async { +Future verifyInternationalizations(String workingDirectory, String dartExecutable) async { final EvalResult materialGenResult = await _evalCommand( - dart, + dartExecutable, [ path.join('dev', 'tools', 'localization', 'bin', 'gen_localizations.dart'), '--material', ], - workingDirectory: flutterRoot, + workingDirectory: workingDirectory, ); final EvalResult cupertinoGenResult = await _evalCommand( - dart, + dartExecutable, [ path.join('dev', 'tools', 'localization', 'bin', 'gen_localizations.dart'), '--cupertino', ], - workingDirectory: flutterRoot, + workingDirectory: workingDirectory, ); - final String materialLocalizationsFile = path.join('packages', 'flutter_localizations', 'lib', 'src', 'l10n', 'generated_material_localizations.dart'); - final String cupertinoLocalizationsFile = path.join('packages', 'flutter_localizations', 'lib', 'src', 'l10n', 'generated_cupertino_localizations.dart'); + final String materialLocalizationsFile = path.join(workingDirectory, 'packages', 'flutter_localizations', 'lib', 'src', 'l10n', 'generated_material_localizations.dart'); + final String cupertinoLocalizationsFile = path.join(workingDirectory, 'packages', 'flutter_localizations', 'lib', 'src', 'l10n', 'generated_cupertino_localizations.dart'); final String expectedMaterialResult = await File(materialLocalizationsFile).readAsString(); final String expectedCupertinoResult = await File(cupertinoLocalizationsFile).readAsString(); diff --git a/dev/bots/test/analyze-test-input/root/dev/tools/localization/bin/gen_localizations.dart b/dev/bots/test/analyze-test-input/root/dev/tools/localization/bin/gen_localizations.dart new file mode 100644 index 00000000000..8505054ed5e --- /dev/null +++ b/dev/bots/test/analyze-test-input/root/dev/tools/localization/bin/gen_localizations.dart @@ -0,0 +1,22 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +void main(List args) { + String type = ''; + if (args[0] == '--material') { + type = 'material'; + } + if (args[0] == '--cupertino') { + type = 'cupertino'; + } + print(''' +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +void main(List args) { + print('Expected output $type'); +} +'''); +} diff --git a/dev/bots/test/analyze-test-input/root/packages/flutter_localizations/lib/src/l10n/generated_cupertino_localizations.dart b/dev/bots/test/analyze-test-input/root/packages/flutter_localizations/lib/src/l10n/generated_cupertino_localizations.dart new file mode 100644 index 00000000000..ee328bafed5 --- /dev/null +++ b/dev/bots/test/analyze-test-input/root/packages/flutter_localizations/lib/src/l10n/generated_cupertino_localizations.dart @@ -0,0 +1,7 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +void main(List args) { + print('Unexpected output cupertino'); +} diff --git a/dev/bots/test/analyze-test-input/root/packages/flutter_localizations/lib/src/l10n/generated_material_localizations.dart b/dev/bots/test/analyze-test-input/root/packages/flutter_localizations/lib/src/l10n/generated_material_localizations.dart new file mode 100644 index 00000000000..db40bf28f41 --- /dev/null +++ b/dev/bots/test/analyze-test-input/root/packages/flutter_localizations/lib/src/l10n/generated_material_localizations.dart @@ -0,0 +1,7 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +void main(List args) { + print('Unexpected output material'); +} diff --git a/dev/bots/test/analyze_test.dart b/dev/bots/test/analyze_test.dart index 1bffc6caded..2dc53d42cfa 100644 --- a/dev/bots/test/analyze_test.dart +++ b/dev/bots/test/analyze_test.dart @@ -38,6 +38,8 @@ Future capture(AsyncVoidCallback callback, { int exitCode = 0 }) async { void main() { final String testRootPath = path.join('test', 'analyze-test-input', 'root'); + final String dartName = Platform.isWindows ? 'dart.exe' : 'dart'; + final String dartPath = path.canonicalize(path.join('..', '..', 'bin', 'cache', 'dart-sdk', 'bin', dartName)); test('analyze.dart - verifyDeprecations', () async { final String result = await capture(() => verifyDeprecations(testRootPath, minimumMatches: 2), exitCode: 1); @@ -124,6 +126,21 @@ void main() { } }); + test('analyze.dart - verifyInternationalizations - comparison fails', () async { + final String result = await capture(() => verifyInternationalizations(testRootPath, dartPath), exitCode: 1); + final String genLocalizationsScript = path.join('dev', 'tools', 'localization', 'bin', 'gen_localizations.dart'); + expect(result, + contains('$dartName $genLocalizationsScript --cupertino')); + expect(result, + contains('$dartName $genLocalizationsScript --material')); + final String generatedFile = path.join(testRootPath, 'packages', 'flutter_localizations', + 'lib', 'src', 'l10n', 'generated_material_localizations.dart'); + expect(result, + contains('The contents of $generatedFile are different from that produced by gen_localizations.')); + expect(result, + contains(r'Did you forget to run gen_localizations.dart after updating a .arb file?')); + }); + test('analyze.dart - verifyNoBinaries - negative', () async { await capture(() => verifyNoBinaries( testRootPath,