mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
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.
This commit is contained in:
parent
cf4ba2f820
commit
57224f81d5
@ -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();
|
||||
|
||||
|
@ -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<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');
|
||||
}
|
||||
''');
|
||||
}
|
@ -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<String> args) {
|
||||
print('Unexpected output cupertino');
|
||||
}
|
@ -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<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,
|
||||
|
Loading…
Reference in New Issue
Block a user