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

Unified Diff: pkg/analyzer/test/src/summary/bazel_summary_test.dart

Issue 2382473005: Implement package linking for Bazel. (Closed)
Patch Set: Created 4 years, 3 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 | « pkg/analyzer/lib/src/summary/bazel_summary.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/src/summary/bazel_summary_test.dart
diff --git a/pkg/analyzer/test/src/summary/bazel_summary_test.dart b/pkg/analyzer/test/src/summary/bazel_summary_test.dart
index 1f078052ad91e2a107649e3cf6b40d7f33ef9cff..6aee81202d4b3a565eefa85c8daac8ea25c9e999 100644
--- a/pkg/analyzer/test/src/summary/bazel_summary_test.dart
+++ b/pkg/analyzer/test/src/summary/bazel_summary_test.dart
@@ -49,6 +49,143 @@ class SummaryProviderTest extends AbstractContextTest {
manager = new SummaryProvider(resourceProvider, _getOutputFolder, context);
}
+ test_getLinkedPackages_null_missingBundle() {
+ _setComponentFile('aaa', 'a.dart', 'class A {}');
+ // We don't write 'aaa', so we cannot get its package.
+ // Ask the package for the URI.
+ Source source = _resolveUri('package:components.aaa/a.dart');
+ List<Package> packages = manager.getLinkedPackages(source);
+ expect(packages, isNull);
+ }
+
+ test_getLinkedPackages_null_missingDirectDependency() {
+ _setComponentFile('aaa', 'a.dart', 'class A {}');
+ _setComponentFile(
+ 'bbb',
+ 'b.dart',
+ r'''
+import 'package:components.aaa/a.dart';
+class B extends A {}
+''');
+ _writeUnlinkedBundle('components.bbb');
+ // We cannot find 'aaa' bundle, so 'bbb' linking fails.
+ Source source = _resolveUri('package:components.bbb/b.dart');
+ List<Package> packages = manager.getLinkedPackages(source);
+ expect(packages, isNull);
+ }
+
+ test_getLinkedPackages_null_missingIndirectDependency() {
+ _setComponentFile('aaa', 'a.dart', 'class A {}');
+ _setComponentFile(
+ 'bbb',
+ 'b.dart',
+ r'''
+import 'package:components.aaa/a.dart';
+class B extends A {}
+''');
+ _setComponentFile(
+ 'ccc',
+ 'c.dart',
+ r'''
+import 'package:components.bbb/b.dart';
+class C extends B {}
+''');
+ _writeUnlinkedBundle('components.bbb');
+ _writeUnlinkedBundle('components.ccc');
+ // We cannot find 'aaa' bundle, so 'ccc' linking fails.
+ Source source = _resolveUri('package:components.ccc/c.dart');
+ List<Package> packages = manager.getLinkedPackages(source);
+ expect(packages, isNull);
+ }
+
+ test_getLinkedPackages_withDependency_export() {
+ _setComponentFile('aaa', 'a.dart', 'class A {}');
+ _setComponentFile(
+ 'bbb',
+ 'b.dart',
+ r'''
+export 'package:components.aaa/a.dart';
+''');
+ _writeUnlinkedBundle('components.aaa');
+ _writeUnlinkedBundle('components.bbb');
+ Source source = _resolveUri('package:components.bbb/b.dart');
+ List<Package> packages = manager.getLinkedPackages(source);
+ expect(packages, hasLength(2));
+ }
+
+ test_getLinkedPackages_withDependency_import() {
+ _setComponentFile('aaa', 'a.dart', 'class A {}');
+ _setComponentFile(
+ 'bbb',
+ 'b.dart',
+ r'''
+import 'package:components.aaa/a.dart';
+class B extends A {}
+''');
+ _writeUnlinkedBundle('components.aaa');
+ _writeUnlinkedBundle('components.bbb');
+ Source source = _resolveUri('package:components.bbb/b.dart');
+ List<Package> packages = manager.getLinkedPackages(source);
+ expect(packages, hasLength(2));
+ }
+
+ test_getLinkedPackages_withDependency_import_cycle() {
+ _setComponentFile(
+ 'aaa',
+ 'a.dart',
+ r'''
+import 'package:components.bbb/b.dart';
+class A {}
+class A2 extends B {}
+''');
+ _setComponentFile(
+ 'bbb',
+ 'b.dart',
+ r'''
+import 'package:components.aaa/a.dart';
+class B extends A {}
+class B2 extends A2 {}
+''');
+ _writeUnlinkedBundle('components.aaa');
+ _writeUnlinkedBundle('components.bbb');
+ Source source = _resolveUri('package:components.bbb/b.dart');
+ List<Package> packages = manager.getLinkedPackages(source);
+ expect(packages, hasLength(2));
+ }
+
+ test_getLinkedPackages_withDependency_import_indirect() {
+ _setComponentFile('aaa', 'a.dart', 'class A {}');
+ _setComponentFile(
+ 'bbb',
+ 'b.dart',
+ r'''
+import 'package:components.aaa/a.dart';
+class B extends A {}
+''');
+ _setComponentFile(
+ 'ccc',
+ 'c.dart',
+ r'''
+import 'package:components.bbb/b.dart';
+class C extends B {}
+''');
+ _writeUnlinkedBundle('components.aaa');
+ _writeUnlinkedBundle('components.bbb');
+ _writeUnlinkedBundle('components.ccc');
+ Source source = _resolveUri('package:components.ccc/c.dart');
+ List<Package> packages = manager.getLinkedPackages(source);
+ expect(packages, hasLength(3));
+ }
+
+ test_getLinkedPackages_withoutDependencies() {
+ _setComponentFile('aaa', 'a.dart', 'class A {}');
+ _writeUnlinkedBundle('components.aaa');
+ // Ask the package for the URI.
+ Source source = _resolveUri('package:components.aaa/a.dart');
+ List<Package> packages = manager.getLinkedPackages(source);
+ expect(packages, hasLength(1));
+ }
+
test_getUnlinkedForUri() {
_setComponentFile('aaa', 'a1.dart', 'class A1 {}');
_setComponentFile('aaa', 'a2.dart', 'class A2 {}');
« no previous file with comments | « pkg/analyzer/lib/src/summary/bazel_summary.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698