Unverified Commit 977da4fb authored by Greg Spencer's avatar Greg Spencer Committed by GitHub

Ignore pub-cache when analyzing (#20925)

This adds ".pub-cache" to the list of directories to ignore when checking for dependence upon dart:test, since when people install a downloadable package, their pub cache is in the flutter directory.

Also, I centralized the ANSI "red line" so that they would all use the same final string.
parent 5d6707b7
...@@ -25,6 +25,7 @@ final String green = hasColor ? '\x1B[32m' : ''; ...@@ -25,6 +25,7 @@ final String green = hasColor ? '\x1B[32m' : '';
final String yellow = hasColor ? '\x1B[33m' : ''; final String yellow = hasColor ? '\x1B[33m' : '';
final String cyan = hasColor ? '\x1B[36m' : ''; final String cyan = hasColor ? '\x1B[36m' : '';
final String reset = hasColor ? '\x1B[0m' : ''; final String reset = hasColor ? '\x1B[0m' : '';
final String redLine = '$red━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━$reset';
const String arrow = '⏩'; const String arrow = '⏩';
const String clock = '🕐'; const String clock = '🕐';
...@@ -421,11 +422,11 @@ Future<EvalResult> _evalCommand(String executable, List<String> arguments, { ...@@ -421,11 +422,11 @@ Future<EvalResult> _evalCommand(String executable, List<String> arguments, {
if (exitCode != 0 && !allowNonZeroExit) { if (exitCode != 0 && !allowNonZeroExit) {
stderr.write(result.stderr); stderr.write(result.stderr);
print( print(
'$red━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━$reset\n' '$redLine\n'
'${bold}ERROR:$red Last command exited with $exitCode.$reset\n' '${bold}ERROR:$red Last command exited with $exitCode.$reset\n'
'${bold}Command:$red $commandDescription$reset\n' '${bold}Command:$red $commandDescription$reset\n'
'${bold}Relative working directory:$red $relativeWorkingDir$reset\n' '${bold}Relative working directory:$red $relativeWorkingDir$reset\n'
'$red━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━$reset' '$redLine'
); );
exit(1); exit(1);
} }
...@@ -486,11 +487,11 @@ Future<Null> _runCommand(String executable, List<String> arguments, { ...@@ -486,11 +487,11 @@ Future<Null> _runCommand(String executable, List<String> arguments, {
stderr.writeln(utf8.decode((await savedStderr).expand((List<int> ints) => ints).toList())); stderr.writeln(utf8.decode((await savedStderr).expand((List<int> ints) => ints).toList()));
} }
print( print(
'$red━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━$reset\n' '$redLine\n'
'${bold}ERROR:$red Last command exited with $exitCode (expected: ${expectNonZeroExit ? (expectedExitCode ?? 'non-zero') : 'zero'}).$reset\n' '${bold}ERROR:$red Last command exited with $exitCode (expected: ${expectNonZeroExit ? (expectedExitCode ?? 'non-zero') : 'zero'}).$reset\n'
'${bold}Command:$cyan $commandDescription$reset\n' '${bold}Command:$cyan $commandDescription$reset\n'
'${bold}Relative working directory:$red $relativeWorkingDir$reset\n' '${bold}Relative working directory:$red $relativeWorkingDir$reset\n'
'$red━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━$reset' '$redLine'
); );
exit(1); exit(1);
} }
...@@ -550,7 +551,8 @@ Future<Null> _verifyNoTestPackageImports(String workingDirectory) async { ...@@ -550,7 +551,8 @@ Future<Null> _verifyNoTestPackageImports(String workingDirectory) async {
final File file = entity; final File file = entity;
final String name = path.relative(file.path, from: workingDirectory); final String name = path.relative(file.path, from: workingDirectory);
if (name.startsWith('bin/cache') || if (name.startsWith('bin/cache') ||
name == 'dev/bots/test.dart') name == 'dev/bots/test.dart' ||
name.startsWith('.pub-cache'))
return null; return null;
final String data = file.readAsStringSync(); final String data = file.readAsStringSync();
if (data.contains("import 'package:test/test.dart'")) { if (data.contains("import 'package:test/test.dart'")) {
...@@ -600,7 +602,7 @@ Future<Null> _verifyNoTestPackageImports(String workingDirectory) async { ...@@ -600,7 +602,7 @@ Future<Null> _verifyNoTestPackageImports(String workingDirectory) async {
// Fail if any errors // Fail if any errors
if (errors.isNotEmpty) { if (errors.isNotEmpty) {
print('$red━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━$reset'); print('$redLine');
final String s1 = errors.length == 1 ? 's' : ''; final String s1 = errors.length == 1 ? 's' : '';
final String s2 = errors.length == 1 ? '' : 's'; final String s2 = errors.length == 1 ? '' : 's';
print('${bold}The following file$s2 use$s1 \'package:test\' incorrectly:$reset'); print('${bold}The following file$s2 use$s1 \'package:test\' incorrectly:$reset');
...@@ -608,7 +610,7 @@ Future<Null> _verifyNoTestPackageImports(String workingDirectory) async { ...@@ -608,7 +610,7 @@ Future<Null> _verifyNoTestPackageImports(String workingDirectory) async {
print('Rather than depending on \'package:test\' directly, use one of the shims:'); print('Rather than depending on \'package:test\' directly, use one of the shims:');
print(shims.join('\n')); print(shims.join('\n'));
print('This insulates us from breaking changes in \'package:test\'.'); print('This insulates us from breaking changes in \'package:test\'.');
print('$red━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━$reset\n'); print('$redLine\n');
exit(1); exit(1);
} }
} }
...@@ -658,14 +660,14 @@ Future<Null> _verifyNoBadImportsInFlutter(String workingDirectory) async { ...@@ -658,14 +660,14 @@ Future<Null> _verifyNoBadImportsInFlutter(String workingDirectory) async {
} }
// Fail if any errors // Fail if any errors
if (errors.isNotEmpty) { if (errors.isNotEmpty) {
print('$red━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━$reset'); print('$redLine');
if (errors.length == 1) { if (errors.length == 1) {
print('${bold}An error was detected when looking at import dependencies within the Flutter package:$reset\n'); print('${bold}An error was detected when looking at import dependencies within the Flutter package:$reset\n');
} else { } else {
print('${bold}Multiple errors were detected when looking at import dependencies within the Flutter package:$reset\n'); print('${bold}Multiple errors were detected when looking at import dependencies within the Flutter package:$reset\n');
} }
print(errors.join('\n\n')); print(errors.join('\n\n'));
print('$red━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━$reset\n'); print('$redLine\n');
exit(1); exit(1);
} }
} }
...@@ -749,14 +751,14 @@ Future<Null> _verifyNoBadImportsInFlutterTools(String workingDirectory) async { ...@@ -749,14 +751,14 @@ Future<Null> _verifyNoBadImportsInFlutterTools(String workingDirectory) async {
} }
// Fail if any errors // Fail if any errors
if (errors.isNotEmpty) { if (errors.isNotEmpty) {
print('$red━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━$reset'); print('$redLine');
if (errors.length == 1) { if (errors.length == 1) {
print('${bold}An error was detected when looking at import dependencies within the flutter_tools package:$reset\n'); print('${bold}An error was detected when looking at import dependencies within the flutter_tools package:$reset\n');
} else { } else {
print('${bold}Multiple errors were detected when looking at import dependencies within the flutter_tools package:$reset\n'); print('${bold}Multiple errors were detected when looking at import dependencies within the flutter_tools package:$reset\n');
} }
print(errors.join('\n\n')); print(errors.join('\n\n'));
print('$red━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━$reset\n'); print('$redLine\n');
exit(1); exit(1);
} }
} }
...@@ -799,13 +801,13 @@ Future<Null> _verifyGeneratedPluginRegistrants(String flutterRoot) async { ...@@ -799,13 +801,13 @@ Future<Null> _verifyGeneratedPluginRegistrants(String flutterRoot) async {
} }
if (outOfDate.isNotEmpty) { if (outOfDate.isNotEmpty) {
print('$red━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━$reset'); print('$redLine');
print('${bold}The following GeneratedPluginRegistrants are out of date:$reset'); print('${bold}The following GeneratedPluginRegistrants are out of date:$reset');
for (String registrant in outOfDate) { for (String registrant in outOfDate) {
print(' - $registrant'); print(' - $registrant');
} }
print('\nRun "flutter inject-plugins" in the package that\'s out of date.'); print('\nRun "flutter inject-plugins" in the package that\'s out of date.');
print('$red━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━$reset'); print('$redLine');
exit(1); exit(1);
} }
} }
...@@ -829,23 +831,23 @@ bool _isGeneratedPluginRegistrant(File file) { ...@@ -829,23 +831,23 @@ bool _isGeneratedPluginRegistrant(File file) {
Future<Null> _verifyVersion(String filename) async { Future<Null> _verifyVersion(String filename) async {
if (!new File(filename).existsSync()) { if (!new File(filename).existsSync()) {
print('$red━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━$reset'); print('$redLine');
print('The version logic failed to create the Flutter version file.'); print('The version logic failed to create the Flutter version file.');
print('$red━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━$reset'); print('$redLine');
exit(1); exit(1);
} }
final String version = await new File(filename).readAsString(); final String version = await new File(filename).readAsString();
if (version == '0.0.0-unknown') { if (version == '0.0.0-unknown') {
print('$red━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━$reset'); print('$redLine');
print('The version logic failed to determine the Flutter version.'); print('The version logic failed to determine the Flutter version.');
print('$red━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━$reset'); print('$redLine');
exit(1); exit(1);
} }
final RegExp pattern = new RegExp(r'^[0-9]+\.[0-9]+\.[0-9]+(-pre\.[0-9]+)?$'); final RegExp pattern = new RegExp(r'^[0-9]+\.[0-9]+\.[0-9]+(-pre\.[0-9]+)?$');
if (!version.contains(pattern)) { if (!version.contains(pattern)) {
print('$red━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━$reset'); print('$redLine');
print('The version logic generated an invalid version string.'); print('The version logic generated an invalid version string.');
print('$red━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━$reset'); print('$redLine');
exit(1); exit(1);
} }
} }
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