Unverified Commit 57224f81 authored by Greg Spencer's avatar Greg Spencer Committed by GitHub

Fix analysis script to run from anywhere (#86683)

Fixes a small problem with the analyze.dart script that fixes it so that it can be invoked from any directory, not just the Flutter root.
parent cf4ba2f8
......@@ -70,7 +70,7 @@ Future<void> run(List<String> 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<void> verifyIntegrationTestTimeouts(String workingDirectory) async {
}
}
Future<void> verifyInternationalizations() async {
Future<void> verifyInternationalizations(String workingDirectory, String dartExecutable) async {
final EvalResult materialGenResult = await _evalCommand(
dart,
dartExecutable,
<String>[
path.join('dev', 'tools', 'localization', 'bin', 'gen_localizations.dart'),
'--material',
],
workingDirectory: flutterRoot,
workingDirectory: workingDirectory,
);
final EvalResult cupertinoGenResult = await _evalCommand(
dart,
dartExecutable,
<String>[
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();
......
// 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<String> 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<String> args) {
print('Expected output $type');
}
''');
}
// 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<String> args) {
print('Unexpected output cupertino');
}
// 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<String> args) {
print('Unexpected output material');
}
......@@ -38,6 +38,8 @@ Future<String> 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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment