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

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

Issue 2748073007: Tighten up subpackage_relationships_test.dart (Closed)
Patch Set: Created 3 years, 9 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 7cd60233db0b4fac4c1f6aaa7ba9b2b2405f1d38..53a6aa631cae3d2f3fda328b403225f2627bc580 100644
--- a/pkg/front_end/test/subpackage_relationships_test.dart
+++ b/pkg/front_end/test/subpackage_relationships_test.dart
@@ -73,14 +73,12 @@ final subpackageRules = {
'lib/src/fasta/source',
'lib/src/fasta/util',
]),
- 'lib/src/fasta/parser':
- new SubpackageRules(allowSubdirs: true, allowedDependencies: [
+ 'lib/src/fasta/parser': new SubpackageRules(allowedDependencies: [
'lib/src/fasta',
'lib/src/fasta/scanner',
'lib/src/fasta/util',
]),
- 'lib/src/fasta/scanner':
- new SubpackageRules(allowSubdirs: true, allowedDependencies: [
+ 'lib/src/fasta/scanner': new SubpackageRules(allowedDependencies: [
'lib/src/fasta',
'lib/src/fasta/parser',
// fasta scanner produces analyzer scanner tokens
@@ -128,6 +126,14 @@ class SubpackageRules {
/// on.
final List<String> allowedDependencies;
+ var actuallyContainsFiles = false;
+
+ var actuallyImportsAnalyzer = false;
+
+ var actuallyHasSubdirs = false;
+
+ var actualDependencies = new Set<String>();
+
SubpackageRules(
{this.mayImportAnalyzer: false,
this.allowSubdirs: false,
@@ -157,15 +163,21 @@ class _SubpackageRelationshipsTest {
'subpackageRules');
return;
}
- if (!srcSubpackageRules.mayImportAnalyzer &&
- dst.pathSegments[0] == 'analyzer') {
- problem('$src depends on $dst, but subpackage "$srcSubpackage" may not '
- 'import analyzer');
+ srcSubpackageRules.actuallyContainsFiles = true;
+ if (dst.pathSegments[0] == 'analyzer') {
+ if (srcSubpackageRules.mayImportAnalyzer) {
+ srcSubpackageRules.actuallyImportsAnalyzer = true;
+ } else {
+ problem('$src depends on $dst, but subpackage "$srcSubpackage" may not '
+ 'import analyzer');
+ }
}
var dstSubPackage = subpackageForUri(dst);
if (dstSubPackage == null) return;
if (dstSubPackage == srcSubpackage) return;
- if (!srcSubpackageRules.allowedDependencies.contains(dstSubPackage)) {
+ if (srcSubpackageRules.allowedDependencies.contains(dstSubPackage)) {
+ srcSubpackageRules.actualDependencies.add(dstSubPackage);
+ } else {
problem('$src depends on $dst, but subpackage "$srcSubpackage" is not '
'allowed to depend on subpackage "$dstSubPackage"');
}
@@ -210,6 +222,22 @@ class _SubpackageRelationshipsTest {
}
}
}
+ subpackageRules.forEach((subpackage, rule) {
+ if (!rule.actuallyContainsFiles) {
+ problem("$subpackage contains no files");
+ }
+ if (rule.mayImportAnalyzer && !rule.actuallyImportsAnalyzer) {
+ problem("$subpackage is allowed to import analyzer, but doesn't");
+ }
+ if (rule.allowSubdirs && !rule.actuallyHasSubdirs) {
+ problem("$subpackage is allowed to have subdirectories, but doesn't");
+ }
+ for (var dep in rule.allowedDependencies
+ .toSet()
+ .difference(rule.actualDependencies)) {
+ problem("$subpackage lists $dep as a dependency, but doesn't use it");
+ }
+ });
return problemsReported ? 1 : 0;
}
@@ -234,10 +262,13 @@ class _SubpackageRelationshipsTest {
if (subpackage == null) {
problem('Uri $src is inside package:front_end but is not in any known '
'subpackage');
- } else if (!subpackageRules[subpackage].allowSubdirs &&
- pathWithinSubpackage.contains('/')) {
- problem('Uri $src is in a subfolder of $subpackage, but that '
- 'subpackage does not allow dart files in subdirectories.');
+ } else if (pathWithinSubpackage.contains('/')) {
+ if (subpackageRules[subpackage].allowSubdirs) {
+ subpackageRules[subpackage].actuallyHasSubdirs = true;
+ } else {
+ problem('Uri $src is in a subfolder of $subpackage, but that '
+ 'subpackage does not allow dart files in subdirectories.');
+ }
}
return subpackage;
}
« 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