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

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

Issue 2674463002: Add fasta subdirectories to subpackage_relationships_test. (Closed)
Patch Set: Created 3 years, 11 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 4e11cf4f7b0525c2ec21ae456e6defc5e62a9f4d..0ad8fb1177374d0000a9cf3f01321a2d9d856443 100644
--- a/pkg/front_end/test/subpackage_relationships_test.dart
+++ b/pkg/front_end/test/subpackage_relationships_test.dart
@@ -16,10 +16,8 @@ main() async {
/// Map from subpackage name to the rules for what the subpackage is allowed to
/// depend directly on.
///
-/// Each subdirectory of `lib/src` is considered a subpackage. Files in
-/// `lib/src` but not in a subdirectory are considered to be in the `lib/src`
-/// subpackage. Files outside of `lib/src` (but still in `lib`) are considered
-/// to be in the `lib` subpackage.
+/// Each listed directory is considered a subpackage. Each package contains all
+/// of its descendant files that are not in a more deeply nested subpackage.
///
/// TODO(paulberry): stuff in lib/src shouldn't depend on lib; lib should just
/// re-export stuff in lib/src.
@@ -33,8 +31,76 @@ final subpackageRules = {
allowedDependencies: ['lib', 'lib/src/base', 'lib/src/scanner']),
'lib/src/base': new SubpackageRules(
mayImportAnalyzer: true, allowedDependencies: ['lib']),
- 'lib/src/scanner': new SubpackageRules(allowedDependencies: ['lib/src/base']),
- 'lib/src/fasta': new SubpackageRules(mayImportAnalyzer: true),
+ 'lib/src/fasta':
+ new SubpackageRules(mayImportAnalyzer: true, allowedDependencies: [
+ 'lib/src/fasta/builder',
+ 'lib/src/fasta/dill',
+ 'lib/src/fasta/kernel',
+ 'lib/src/fasta/parser',
+ 'lib/src/fasta/scanner',
+ 'lib/src/fasta/testing',
+ ]),
+ 'lib/src/fasta/analyzer':
+ new SubpackageRules(mayImportAnalyzer: true, allowedDependencies: [
+ 'lib/src/fasta',
+ 'lib/src/fasta/builder',
+ 'lib/src/fasta/dill',
+ 'lib/src/fasta/kernel',
+ 'lib/src/fasta/scanner',
+ 'lib/src/fasta/source',
+ ]),
+ 'lib/src/fasta/bin': new SubpackageRules(allowedDependencies: [
+ 'lib/src/fasta',
+ ]),
+ 'lib/src/fasta/builder': new SubpackageRules(allowedDependencies: [
+ 'lib/src/fasta',
+ 'lib/src/fasta/dill',
+ 'lib/src/fasta/parser',
+ 'lib/src/fasta/source',
+ ]),
+ 'lib/src/fasta/dill': new SubpackageRules(allowedDependencies: [
+ 'lib/src/fasta',
+ 'lib/src/fasta/kernel',
+ ]),
+ 'lib/src/fasta/kernel': new SubpackageRules(allowedDependencies: [
+ 'lib/src/fasta',
+ 'lib/src/fasta/builder',
+ 'lib/src/fasta/dill',
+ 'lib/src/fasta/parser',
+ 'lib/src/fasta/scanner',
+ 'lib/src/fasta/source',
+ ]),
+ 'lib/src/fasta/parser':
+ new SubpackageRules(allowSubdirs: true, allowedDependencies: [
+ 'lib/src/fasta',
+ 'lib/src/fasta/scanner',
+ 'lib/src/fasta/util',
+ ]),
+ 'lib/src/fasta/scanner':
+ new SubpackageRules(allowSubdirs: true, allowedDependencies: [
+ 'lib/src/fasta',
+ 'lib/src/fasta/parser',
+ 'lib/src/fasta/util',
+ ]),
+ 'lib/src/fasta/source': new SubpackageRules(allowedDependencies: [
+ 'lib/src/fasta',
+ 'lib/src/fasta/analyzer',
+ 'lib/src/fasta/builder',
+ 'lib/src/fasta/dill',
+ 'lib/src/fasta/kernel',
+ 'lib/src/fasta/parser',
+ 'lib/src/fasta/scanner',
+ ]),
+ 'lib/src/fasta/testing':
+ new SubpackageRules(mayImportAnalyzer: true, allowedDependencies: [
+ 'lib/src/fasta',
+ 'lib/src/fasta/dill',
+ 'lib/src/fasta/kernel',
+ ]),
+ 'lib/src/fasta/util': new SubpackageRules(),
+ 'lib/src/scanner': new SubpackageRules(allowedDependencies: [
+ 'lib/src/base',
+ ]),
};
/// Rules for what a subpackage may depend directly on.
@@ -42,12 +108,21 @@ class SubpackageRules {
/// Indicates whether the subpackage may directly depend on analyzer.
final bool mayImportAnalyzer;
+ /// Indicates whether dart files may exist in subdirectories of this
+ /// subpackage.
+ ///
+ /// If `false`, any subdirectory of this subpackage must be a separate
+ /// subpackage.
+ final bool allowSubdirs;
+
/// Indicates which other subpackages a given subpackage may directly depend
/// on.
final List<String> allowedDependencies;
SubpackageRules(
- {this.mayImportAnalyzer: false, this.allowedDependencies: const []});
+ {this.mayImportAnalyzer: false,
+ this.allowSubdirs: false,
+ this.allowedDependencies: const []});
}
class _SubpackageRelationshipsTest {
@@ -135,8 +210,26 @@ class _SubpackageRelationshipsTest {
String subpackageForUri(Uri src) {
if (src.scheme != 'package') return null;
if (src.pathSegments[0] != 'front_end') return null;
- if (src.pathSegments[1] != 'src') return 'lib';
- if (src.pathSegments.length == 3) return 'lib/src';
- return 'lib/src/${src.pathSegments[2]}';
+ var pathWithLib = 'lib/${src.pathSegments.skip(1).join('/')}';
+ String subpackage;
+ String pathWithinSubpackage;
+ for (var subpackagePath in subpackageRules.keys) {
+ var subpackagePathWithSlash = '$subpackagePath/';
+ if (pathWithLib.startsWith(subpackagePathWithSlash) &&
+ (subpackage == null || subpackage.length < subpackagePath.length)) {
+ subpackage = subpackagePath;
+ pathWithinSubpackage =
+ pathWithLib.substring(subpackagePathWithSlash.length);
+ }
+ }
+ 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.');
+ }
+ 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