@@ -8,6 +8,7 @@ import 'dart:io';
88import 'package:analyzer/error/error.dart' ;
99import 'package:analyzer/source/error_processor.dart' ;
1010import 'package:analyzer/src/analysis_options/analysis_options_provider.dart' ;
11+ import 'package:analyzer/src/dart/analysis/driver.dart' ;
1112import 'package:analyzer/src/error/codes.dart' ;
1213import 'package:analyzer/src/generated/engine.dart' ;
1314import 'package:analyzer/src/generated/source.dart' ;
@@ -488,13 +489,27 @@ class BuildModeTest extends AbstractBuildModeTest {
488489 PackageBundle bundle =
489490 new PackageBundle .fromBuffer (await output.readAsBytes ());
490491 var testFileUri = 'file:///test_file.dart' ;
491- expect (bundle.unlinkedUnitUris, equals ([testFileUri]));
492- expect (bundle.linkedLibraryUris, equals ([testFileUri]));
492+ if (AnalysisDriver .useSummary2) {
493+ var bundle2 = bundle.bundle2;
494+ expect (_linkedLibraryUriList (bundle2), [testFileUri]);
495+ expect (
496+ _linkedLibraryUnitUriList (bundle2, testFileUri),
497+ [testFileUri],
498+ );
499+ } else {
500+ expect (bundle.unlinkedUnitUris, equals ([testFileUri]));
501+ expect (bundle.linkedLibraryUris, equals ([testFileUri]));
502+ }
493503 expect (exitCode, 0 );
494504 });
495505 }
496506
497507 test_buildLinked_buildSummaryOutputSemantic () async {
508+ // All informative data is stored separately when summary2.
509+ if (AnalysisDriver .useSummary2) {
510+ return ;
511+ }
512+
498513 await withTempDirAsync ((tempDir) async {
499514 var testDart = path.join (tempDir, 'test.dart' );
500515 var testSumFull = path.join (tempDir, 'test.sum.full' );
@@ -534,6 +549,11 @@ class BuildModeTest extends AbstractBuildModeTest {
534549 }
535550
536551 test_buildLinked_fromUnlinked () async {
552+ // We don't use unlinked units with summary2.
553+ if (AnalysisDriver .useSummary2) {
554+ return ;
555+ }
556+
537557 await withTempDirAsync ((tempDir) async {
538558 var aDart = path.join (tempDir, 'a.dart' );
539559 var bDart = path.join (tempDir, 'b.dart' );
@@ -598,6 +618,11 @@ var b = a;
598618 }
599619
600620 test_buildUnlinked () async {
621+ // We don't use unlinked units with summary2.
622+ if (AnalysisDriver .useSummary2) {
623+ return ;
624+ }
625+
601626 await withTempDirAsync ((tempDir) async {
602627 var outputPath = path.join (tempDir, 'test_file.dart.sum' );
603628 await _doDrive (path.join ('data' , 'test_file.dart' ), additionalArgs: [
@@ -649,8 +674,14 @@ var b = new B();
649674 expect (exitCode, 0 );
650675 var bytes = new File (aSum).readAsBytesSync ();
651676 var bundle = new PackageBundle .fromBuffer (bytes);
652- expect (bundle.unlinkedUnitUris, equals ([aUri]));
653- expect (bundle.linkedLibraryUris, equals ([aUri]));
677+ if (AnalysisDriver .useSummary2) {
678+ var bundle2 = bundle.bundle2;
679+ expect (_linkedLibraryUriList (bundle2), [aUri]);
680+ expect (_linkedLibraryUnitUriList (bundle2, aUri), [aUri]);
681+ } else {
682+ expect (bundle.unlinkedUnitUris, equals ([aUri]));
683+ expect (bundle.linkedLibraryUris, equals ([aUri]));
684+ }
654685 }
655686
656687 // Analyze package:bbb/b.dart and compute summary.
@@ -662,8 +693,14 @@ var b = new B();
662693 expect (exitCode, 0 );
663694 var bytes = new File (bSum).readAsBytesSync ();
664695 var bundle = new PackageBundle .fromBuffer (bytes);
665- expect (bundle.unlinkedUnitUris, equals ([bUri]));
666- expect (bundle.linkedLibraryUris, equals ([bUri]));
696+ if (AnalysisDriver .useSummary2) {
697+ var bundle2 = bundle.bundle2;
698+ expect (_linkedLibraryUriList (bundle2), [bUri]);
699+ expect (_linkedLibraryUnitUriList (bundle2, bUri), [bUri]);
700+ } else {
701+ expect (bundle.unlinkedUnitUris, equals ([bUri]));
702+ expect (bundle.linkedLibraryUris, equals ([bUri]));
703+ }
667704 }
668705
669706 // Analyze package:ccc/c.dart and compute summary.
@@ -675,8 +712,14 @@ var b = new B();
675712 expect (exitCode, 0 );
676713 var bytes = new File (cSum).readAsBytesSync ();
677714 var bundle = new PackageBundle .fromBuffer (bytes);
678- expect (bundle.unlinkedUnitUris, equals ([cUri]));
679- expect (bundle.linkedLibraryUris, equals ([cUri]));
715+ if (AnalysisDriver .useSummary2) {
716+ var bundle2 = bundle.bundle2;
717+ expect (_linkedLibraryUriList (bundle2), [cUri]);
718+ expect (_linkedLibraryUnitUriList (bundle2, cUri), [cUri]);
719+ } else {
720+ expect (bundle.unlinkedUnitUris, equals ([cUri]));
721+ expect (bundle.linkedLibraryUris, equals ([cUri]));
722+ }
680723 }
681724 });
682725 }
@@ -704,6 +747,11 @@ var b = new B();
704747 }
705748
706749 test_error_linkedAsUnlinked () async {
750+ // We don't use unlinked units with summary2.
751+ if (AnalysisDriver .useSummary2) {
752+ return ;
753+ }
754+
707755 await withTempDirAsync ((tempDir) async {
708756 var aDart = path.join (tempDir, 'a.dart' );
709757 var bDart = path.join (tempDir, 'b.dart' );
@@ -751,6 +799,11 @@ var b = new B();
751799 }
752800
753801 test_error_unlinkedAsLinked () async {
802+ // We don't use unlinked units with summary2.
803+ if (AnalysisDriver .useSummary2) {
804+ return ;
805+ }
806+
754807 await withTempDirAsync ((tempDir) async {
755808 var aDart = path.join (tempDir, 'a.dart' );
756809 var bDart = path.join (tempDir, 'b.dart' );
@@ -824,6 +877,20 @@ var b = new B();
824877 expect (errorSink, isEmpty);
825878 });
826879 }
880+
881+ Iterable <String > _linkedLibraryUnitUriList (
882+ LinkedNodeBundle bundle2,
883+ String libraryUriStr,
884+ ) {
885+ var libraries = bundle2.libraries;
886+ var library = libraries.singleWhere ((l) => l.uriStr == libraryUriStr);
887+ return library.units.map ((u) => u.uriStr).toList ();
888+ }
889+
890+ Iterable <String > _linkedLibraryUriList (LinkedNodeBundle bundle2) {
891+ var libraries = bundle2.libraries;
892+ return libraries.map ((l) => l.uriStr).toList ();
893+ }
827894}
828895
829896@reflectiveTest
0 commit comments