mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Fix import statements in flutter_tools (#13911)
This commit is contained in:
parent
7b6af52c92
commit
18c60d3301
@ -171,7 +171,7 @@ dependencies:
|
|||||||
errors.removeLast();
|
errors.removeLast();
|
||||||
int errorCount = 0;
|
int errorCount = 0;
|
||||||
for (String error in errors) {
|
for (String error in errors) {
|
||||||
const String kBullet = ' • ';
|
final String kBullet = Platform.isWindows ? ' - ' : ' • ';
|
||||||
const String kColon = ':';
|
const String kColon = ':';
|
||||||
final RegExp atRegExp = new RegExp(r' at .*main.dart:');
|
final RegExp atRegExp = new RegExp(r' at .*main.dart:');
|
||||||
final int start = error.indexOf(kBullet);
|
final int start = error.indexOf(kBullet);
|
||||||
|
@ -45,10 +45,17 @@ const Map<String, ShardRunner> _kShards = const <String, ShardRunner>{
|
|||||||
Future<Null> main(List<String> args) async {
|
Future<Null> main(List<String> args) async {
|
||||||
flutterTestArgs.addAll(args);
|
flutterTestArgs.addAll(args);
|
||||||
|
|
||||||
final String shard = Platform.environment['SHARD'] ?? 'tests';
|
final String shard = Platform.environment['SHARD'];
|
||||||
|
if (shard != null) {
|
||||||
if (!_kShards.containsKey(shard))
|
if (!_kShards.containsKey(shard))
|
||||||
throw new ArgumentError('Invalid shard: $shard');
|
throw new ArgumentError('Invalid shard: $shard');
|
||||||
await _kShards[shard]();
|
await _kShards[shard]();
|
||||||
|
} else {
|
||||||
|
for (String currentShard in _kShards.keys) {
|
||||||
|
print('${bold}SHARD=$currentShard$reset');
|
||||||
|
await _kShards[currentShard]();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Null> _generateDocs() async {
|
Future<Null> _generateDocs() async {
|
||||||
@ -88,7 +95,8 @@ Future<Null> _verifyInternationalizations() async {
|
|||||||
|
|
||||||
Future<Null> _analyzeRepo() async {
|
Future<Null> _analyzeRepo() async {
|
||||||
await _verifyGeneratedPluginRegistrants(flutterRoot);
|
await _verifyGeneratedPluginRegistrants(flutterRoot);
|
||||||
await _verifyNoBadImports(flutterRoot);
|
await _verifyNoBadImportsInFlutter(flutterRoot);
|
||||||
|
await _verifyNoBadImportsInFlutterTools(flutterRoot);
|
||||||
await _verifyInternationalizations();
|
await _verifyInternationalizations();
|
||||||
|
|
||||||
// Analyze all the Dart code in the repo.
|
// Analyze all the Dart code in the repo.
|
||||||
@ -181,6 +189,10 @@ Future<Null> _runCoverage() async {
|
|||||||
print('${bold}DONE: test.dart does not run coverage in Travis$reset');
|
print('${bold}DONE: test.dart does not run coverage in Travis$reset');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (Platform.isWindows) {
|
||||||
|
print('${bold}DONE: test.dart does not run coverage on Windows$reset');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
final File coverageFile = new File(path.join(flutterRoot, 'packages', 'flutter', 'coverage', 'lcov.info'));
|
final File coverageFile = new File(path.join(flutterRoot, 'packages', 'flutter', 'coverage', 'lcov.info'));
|
||||||
if (!coverageFile.existsSync()) {
|
if (!coverageFile.existsSync()) {
|
||||||
@ -214,8 +226,11 @@ Future<Null> _pubRunTest(
|
|||||||
if (new Directory(pubCache).existsSync()) {
|
if (new Directory(pubCache).existsSync()) {
|
||||||
pubEnvironment['PUB_CACHE'] = pubCache;
|
pubEnvironment['PUB_CACHE'] = pubCache;
|
||||||
}
|
}
|
||||||
return _runCommand(pub, args, workingDirectory: workingDirectory,
|
return _runCommand(
|
||||||
environment: pubEnvironment);
|
pub, args,
|
||||||
|
workingDirectory: workingDirectory,
|
||||||
|
environment: pubEnvironment,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
class EvalResult {
|
class EvalResult {
|
||||||
@ -329,7 +344,7 @@ Future<Null> _runFlutterTest(String workingDirectory, {
|
|||||||
workingDirectory: workingDirectory,
|
workingDirectory: workingDirectory,
|
||||||
expectFailure: expectFailure,
|
expectFailure: expectFailure,
|
||||||
printOutput: printOutput,
|
printOutput: printOutput,
|
||||||
skip: skip || Platform.isWindows, // TODO(goderbauer): run on Windows when sky_shell is available
|
skip: skip,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -351,7 +366,7 @@ Future<Null> _runFlutterAnalyze(String workingDirectory, {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Null> _verifyNoBadImports(String workingDirectory) async {
|
Future<Null> _verifyNoBadImportsInFlutter(String workingDirectory) async {
|
||||||
final List<String> errors = <String>[];
|
final List<String> errors = <String>[];
|
||||||
final String libPath = path.join(workingDirectory, 'packages', 'flutter', 'lib');
|
final String libPath = path.join(workingDirectory, 'packages', 'flutter', 'lib');
|
||||||
final String srcPath = path.join(workingDirectory, 'packages', 'flutter', 'lib', 'src');
|
final String srcPath = path.join(workingDirectory, 'packages', 'flutter', 'lib', 'src');
|
||||||
@ -424,7 +439,7 @@ final RegExp _importPattern = new RegExp(r"import 'package:flutter/([^.]+)\.dart
|
|||||||
final RegExp _importMetaPattern = new RegExp(r"import 'package:meta/meta.dart'");
|
final RegExp _importMetaPattern = new RegExp(r"import 'package:meta/meta.dart'");
|
||||||
|
|
||||||
Set<String> _findDependencies(String srcPath, List<String> errors, { bool checkForMeta: false }) {
|
Set<String> _findDependencies(String srcPath, List<String> errors, { bool checkForMeta: false }) {
|
||||||
return new Directory(srcPath).listSync().where((FileSystemEntity entity) {
|
return new Directory(srcPath).listSync(recursive: true).where((FileSystemEntity entity) {
|
||||||
return entity is File && path.extension(entity.path) == '.dart';
|
return entity is File && path.extension(entity.path) == '.dart';
|
||||||
}).map<Set<String>>((FileSystemEntity entity) {
|
}).map<Set<String>>((FileSystemEntity entity) {
|
||||||
final Set<String> result = new Set<String>();
|
final Set<String> result = new Set<String>();
|
||||||
@ -475,6 +490,30 @@ List<T> _deepSearch<T>(Map<T, Set<T>> map, T start, [ Set<T> seen ]) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<Null> _verifyNoBadImportsInFlutterTools(String workingDirectory) async {
|
||||||
|
final List<String> errors = <String>[];
|
||||||
|
for (FileSystemEntity entity in new Directory(path.join(workingDirectory, 'packages', 'flutter_tools', 'lib'))
|
||||||
|
.listSync(recursive: true)
|
||||||
|
.where((FileSystemEntity entity) => entity is File && path.extension(entity.path) == '.dart')) {
|
||||||
|
final File file = entity;
|
||||||
|
if (file.readAsStringSync().contains('package:flutter_tools/')) {
|
||||||
|
errors.add('$yellow${file.path}$reset imports flutter_tools.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Fail if any errors
|
||||||
|
if (errors.isNotEmpty) {
|
||||||
|
print('$red━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━$reset');
|
||||||
|
if (errors.length == 1) {
|
||||||
|
print('${bold}An error was detected when looking at import dependencies within the flutter_tools package:$reset\n');
|
||||||
|
} else {
|
||||||
|
print('${bold}Multiple errors were detected when looking at import dependencies within the flutter_tools package:$reset\n');
|
||||||
|
}
|
||||||
|
print(errors.join('\n\n'));
|
||||||
|
print('$red━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━$reset\n');
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void _printProgress(String action, String workingDir, String command) {
|
void _printProgress(String action, String workingDir, String command) {
|
||||||
const String arrow = '⏩';
|
const String arrow = '⏩';
|
||||||
print('$arrow $action: cd $cyan$workingDir$reset; $yellow$command$reset');
|
print('$arrow $action: cd $cyan$workingDir$reset; $yellow$command$reset');
|
||||||
|
@ -5,9 +5,9 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:collection';
|
import 'dart:collection';
|
||||||
|
|
||||||
import 'package:flutter_tools/src/base/common.dart';
|
|
||||||
import 'package:meta/meta.dart';
|
import 'package:meta/meta.dart';
|
||||||
|
|
||||||
|
import '../base/common.dart';
|
||||||
import '../base/file_system.dart';
|
import '../base/file_system.dart';
|
||||||
import '../base/logger.dart';
|
import '../base/logger.dart';
|
||||||
import '../base/net.dart';
|
import '../base/net.dart';
|
||||||
|
@ -5,11 +5,10 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:flutter_tools/src/base/common.dart';
|
|
||||||
import 'package:flutter_tools/src/base/process_manager.dart';
|
|
||||||
import 'package:usage/uuid/uuid.dart';
|
import 'package:usage/uuid/uuid.dart';
|
||||||
|
|
||||||
import 'artifacts.dart';
|
import 'artifacts.dart';
|
||||||
|
import 'base/common.dart';
|
||||||
import 'base/file_system.dart';
|
import 'base/file_system.dart';
|
||||||
import 'base/io.dart';
|
import 'base/io.dart';
|
||||||
import 'base/process_manager.dart';
|
import 'base/process_manager.dart';
|
||||||
|
@ -4,12 +4,12 @@
|
|||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter_tools/src/globals.dart';
|
|
||||||
import 'package:json_schema/json_schema.dart';
|
import 'package:json_schema/json_schema.dart';
|
||||||
import 'package:yaml/yaml.dart';
|
import 'package:yaml/yaml.dart';
|
||||||
|
|
||||||
import 'base/file_system.dart';
|
import 'base/file_system.dart';
|
||||||
import 'cache.dart';
|
import 'cache.dart';
|
||||||
|
import 'globals.dart';
|
||||||
|
|
||||||
/// A wrapper around the `flutter` section in the `pubspec.yaml` file.
|
/// A wrapper around the `flutter` section in the `pubspec.yaml` file.
|
||||||
class FlutterManifest {
|
class FlutterManifest {
|
||||||
|
Loading…
Reference in New Issue
Block a user