Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2618)

Unified Diff: pkg/front_end/test/subpackage_relationships_test.dart

Issue 2940893004: Add checks to make sure new front_end package dependencies are not added. (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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");
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698