Index: pkg/front_end/test/subpackage_relationships_test.dart |
diff --git a/pkg/front_end/test/subpackage_relationships_test.dart b/pkg/front_end/test/subpackage_relationships_test.dart |
index 43c488d9f87d38800681dc699cd9e30f9ad40773..9911b5ed3c26adace12c4c7f2bcd2870eb3579d5 100644 |
--- a/pkg/front_end/test/subpackage_relationships_test.dart |
+++ b/pkg/front_end/test/subpackage_relationships_test.dart |
@@ -13,6 +13,22 @@ main() async { |
exit(await new _SubpackageRelationshipsTest().run()); |
} |
+/// List of packages that front_end is allowed to directly depend on. |
+/// |
+/// TODO(paulberry): remove dependencies on analyzer. |
+final allowedPackageDependencies = [ |
Siggi Cherem (dart-lang)
2017/06/15 17:45:57
do we need to also make the distinction between de
Paul Berry
2017/06/15 17:58:27
This script only checks files in pkg/front_end/lib
|
+ 'analyzer', |
+ 'charcode', |
+ 'convert', |
+ 'crypto', |
+ 'kernel', |
+ 'meta', |
+ 'package_config', |
+ 'path', |
+ 'source_span', |
+ 'testing', |
+]; |
+ |
/// Map from subpackage name to the rules for what the subpackage is allowed to |
/// depend directly on. |
/// |
@@ -178,6 +194,9 @@ class _SubpackageRelationshipsTest { |
/// Indicates whether any problems have been reported yet. |
bool problemsReported = false; |
+ /// Package dependencies that were actually discovered |
+ final actualPackageDependencies = <String>[]; |
+ |
/// Check for problems resulting from URI [src] having a direct dependency on |
/// URI [dst]. |
void checkDependency(Uri src, Uri dst) { |
@@ -186,6 +205,17 @@ class _SubpackageRelationshipsTest { |
problem('$src depends on $dst, which is neither a package: or dart: URI'); |
return; |
} |
+ if (src.scheme == 'package' && |
+ src.pathSegments[0] == 'front_end' && |
+ dst.scheme == 'package' && |
+ dst.pathSegments[0] != 'front_end') { |
+ if (allowedPackageDependencies.contains(dst.pathSegments[0])) { |
+ actualPackageDependencies.add(dst.pathSegments[0]); |
+ } else { |
+ problem('$src depends on package "${dst.pathSegments[0]}", which is ' |
+ 'not found in allowedPackageDependencies'); |
+ } |
+ } |
var srcSubpackage = subpackageForUri(src); |
if (srcSubpackage == null) return; |
var srcSubpackageRules = subpackageRules[srcSubpackage]; |
@@ -253,6 +283,12 @@ class _SubpackageRelationshipsTest { |
} |
} |
} |
+ for (var package in allowedPackageDependencies) { |
+ if (!actualPackageDependencies.contains(package)) { |
+ problem( |
+ '$package is listed in allowedPackageDependencies, but is not used'); |
Siggi Cherem (dart-lang)
2017/06/15 17:45:57
nit: maybe split line
Paul Berry
2017/06/15 17:58:27
Done.
|
+ } |
+ } |
subpackageRules.forEach((subpackage, rule) { |
if (!rule.actuallyContainsFiles) { |
problem("$subpackage contains no files"); |