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

Side by Side Diff: pkg/analyzer/test/src/summary/package_bundle_reader_test.dart

Issue 2829493002: Make conflicting summary check configurable (Closed)
Patch Set: Created 3 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'package:analyzer/src/context/cache.dart'; 5 import 'package:analyzer/src/context/cache.dart';
6 import 'package:analyzer/src/generated/engine.dart'; 6 import 'package:analyzer/src/generated/engine.dart';
7 import 'package:analyzer/src/generated/source.dart'; 7 import 'package:analyzer/src/generated/source.dart';
8 import 'package:analyzer/src/summary/idl.dart'; 8 import 'package:analyzer/src/summary/idl.dart';
9 import 'package:analyzer/src/summary/package_bundle_reader.dart'; 9 import 'package:analyzer/src/summary/package_bundle_reader.dart';
10 import 'package:analyzer/src/task/dart.dart'; 10 import 'package:analyzer/src/task/dart.dart';
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 141
142 test_compute_SOURCE_KIND_partSource() { 142 test_compute_SOURCE_KIND_partSource() {
143 bool success = provider.compute(entry2, SOURCE_KIND); 143 bool success = provider.compute(entry2, SOURCE_KIND);
144 expect(success, isTrue); 144 expect(success, isTrue);
145 expect(entry2.getValue(SOURCE_KIND), SourceKind.PART); 145 expect(entry2.getValue(SOURCE_KIND), SourceKind.PART);
146 } 146 }
147 } 147 }
148 148
149 @reflectiveTest 149 @reflectiveTest
150 class SummaryDataStoreTest { 150 class SummaryDataStoreTest {
151 SummaryDataStore dataStore = 151 SummaryDataStore dataStore = new SummaryDataStore(<String>[],
152 new SummaryDataStore(<String>[], recordDependencyInfo: true); 152 recordDependencyInfo: true, disallowOverlappingSummaries: true);
153 153
154 PackageBundle bundle1 = new _PackageBundleMock(); 154 PackageBundle bundle1 = new _PackageBundleMock();
155 PackageBundle bundle2 = new _PackageBundleMock(); 155 PackageBundle bundle2 = new _PackageBundleMock();
156 UnlinkedUnit unlinkedUnit11 = new _UnlinkedUnitMock(); 156 UnlinkedUnit unlinkedUnit11 = new _UnlinkedUnitMock();
157 UnlinkedUnit unlinkedUnit12 = new _UnlinkedUnitMock(); 157 UnlinkedUnit unlinkedUnit12 = new _UnlinkedUnitMock();
158 UnlinkedUnit unlinkedUnit21 = new _UnlinkedUnitMock(); 158 UnlinkedUnit unlinkedUnit21 = new _UnlinkedUnitMock();
159 LinkedLibrary linkedLibrary1 = new _LinkedLibraryMock(); 159 LinkedLibrary linkedLibrary1 = new _LinkedLibraryMock();
160 LinkedLibrary linkedLibrary2 = new _LinkedLibraryMock(); 160 LinkedLibrary linkedLibrary2 = new _LinkedLibraryMock();
161 161
162 void setUp() { 162 void _setupDataStore(SummaryDataStore store) {
163 // bundle1 163 // bundle1
164 when(unlinkedUnit11.publicNamespace) 164 when(unlinkedUnit11.publicNamespace)
165 .thenReturn(_namespaceWithParts(['package:p1/u2.dart'])); 165 .thenReturn(_namespaceWithParts(['package:p1/u2.dart']));
166 when(unlinkedUnit12.publicNamespace).thenReturn(_namespaceWithParts([])); 166 when(unlinkedUnit12.publicNamespace).thenReturn(_namespaceWithParts([]));
167 when(bundle1.unlinkedUnitUris) 167 when(bundle1.unlinkedUnitUris)
168 .thenReturn(<String>['package:p1/u1.dart', 'package:p1/u2.dart']); 168 .thenReturn(<String>['package:p1/u1.dart', 'package:p1/u2.dart']);
169 when(bundle1.unlinkedUnits) 169 when(bundle1.unlinkedUnits)
170 .thenReturn(<UnlinkedUnit>[unlinkedUnit11, unlinkedUnit12]); 170 .thenReturn(<UnlinkedUnit>[unlinkedUnit11, unlinkedUnit12]);
171 when(bundle1.linkedLibraryUris).thenReturn(<String>['package:p1/u1.dart']); 171 when(bundle1.linkedLibraryUris).thenReturn(<String>['package:p1/u1.dart']);
172 when(bundle1.linkedLibraries).thenReturn(<LinkedLibrary>[linkedLibrary1]); 172 when(bundle1.linkedLibraries).thenReturn(<LinkedLibrary>[linkedLibrary1]);
173 when(bundle1.apiSignature).thenReturn('signature1'); 173 when(bundle1.apiSignature).thenReturn('signature1');
174 dataStore.addBundle('/p1.ds', bundle1); 174 store.addBundle('/p1.ds', bundle1);
175 // bundle2 175 // bundle2
176 when(unlinkedUnit21.publicNamespace).thenReturn(_namespaceWithParts([])); 176 when(unlinkedUnit21.publicNamespace).thenReturn(_namespaceWithParts([]));
177 when(bundle2.unlinkedUnitUris).thenReturn(<String>['package:p2/u1.dart']); 177 when(bundle2.unlinkedUnitUris).thenReturn(<String>['package:p2/u1.dart']);
178 when(bundle2.unlinkedUnits).thenReturn(<UnlinkedUnit>[unlinkedUnit21]); 178 when(bundle2.unlinkedUnits).thenReturn(<UnlinkedUnit>[unlinkedUnit21]);
179 when(bundle2.linkedLibraryUris).thenReturn(<String>['package:p2/u1.dart']); 179 when(bundle2.linkedLibraryUris).thenReturn(<String>['package:p2/u1.dart']);
180 when(bundle2.linkedLibraries).thenReturn(<LinkedLibrary>[linkedLibrary2]); 180 when(bundle2.linkedLibraries).thenReturn(<LinkedLibrary>[linkedLibrary2]);
181 when(bundle2.apiSignature).thenReturn('signature2'); 181 when(bundle2.apiSignature).thenReturn('signature2');
182 dataStore.addBundle('/p2.ds', bundle2); 182 store.addBundle('/p2.ds', bundle2);
183 }
184
185 void setUp() {
186 _setupDataStore(dataStore);
183 } 187 }
184 188
185 test_addBundle() { 189 test_addBundle() {
186 expect(dataStore.bundles, unorderedEquals([bundle1, bundle2])); 190 expect(dataStore.bundles, unorderedEquals([bundle1, bundle2]));
187 expect(dataStore.dependencies[0].summaryPath, '/p1.ds'); 191 expect(dataStore.dependencies[0].summaryPath, '/p1.ds');
188 expect(dataStore.dependencies[0].apiSignature, 'signature1'); 192 expect(dataStore.dependencies[0].apiSignature, 'signature1');
189 expect(dataStore.dependencies[0].includedPackageNames, ['p1']); 193 expect(dataStore.dependencies[0].includedPackageNames, ['p1']);
190 expect(dataStore.dependencies[0].includesFileUris, false); 194 expect(dataStore.dependencies[0].includesFileUris, false);
191 expect(dataStore.dependencies[0].includesDartUris, false); 195 expect(dataStore.dependencies[0].includesDartUris, false);
192 expect(dataStore.dependencies[1].summaryPath, '/p2.ds'); 196 expect(dataStore.dependencies[1].summaryPath, '/p2.ds');
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 .thenReturn(<String>['package:p2/u1.dart', 'package:p1/u1.dart']); 252 .thenReturn(<String>['package:p2/u1.dart', 'package:p1/u1.dart']);
249 when(bundle.linkedLibraries) 253 when(bundle.linkedLibraries)
250 .thenReturn(<LinkedLibrary>[linkedLibrary2, linkedLibrary1]); 254 .thenReturn(<LinkedLibrary>[linkedLibrary2, linkedLibrary1]);
251 when(bundle.apiSignature).thenReturn('signature'); 255 when(bundle.apiSignature).thenReturn('signature');
252 // p3 conflicts (overlaps) with existing summaries. 256 // p3 conflicts (overlaps) with existing summaries.
253 expect(() => dataStore.addBundle('/p3.ds', bundle), 257 expect(() => dataStore.addBundle('/p3.ds', bundle),
254 throwsA(isConflictingSummaryException)); 258 throwsA(isConflictingSummaryException));
255 expect(dataStore.dependencies.last.includedPackageNames, ['p1', 'p2']); 259 expect(dataStore.dependencies.last.includedPackageNames, ['p1', 'p2']);
256 } 260 }
257 261
262 test_addBundle_multiProjectOverlap() {
263 SummaryDataStore dataStore2 = new SummaryDataStore(<String>[],
264 recordDependencyInfo: true, disallowOverlappingSummaries: false);
265 _setupDataStore(dataStore2);
266
267 PackageBundle bundle = new _PackageBundleMock();
268 when(bundle.unlinkedUnitUris)
269 .thenReturn(<String>['package:p2/u1.dart', 'package:p1/u1.dart']);
270 when(bundle.unlinkedUnits)
271 .thenReturn(<UnlinkedUnit>[unlinkedUnit21, unlinkedUnit11]);
272 when(bundle.linkedLibraryUris)
273 .thenReturn(<String>['package:p2/u1.dart', 'package:p1/u1.dart']);
274 when(bundle.linkedLibraries)
275 .thenReturn(<LinkedLibrary>[linkedLibrary2, linkedLibrary1]);
276 when(bundle.apiSignature).thenReturn('signature');
277 // p3 conflicts (overlaps) with existing summaries, but now allowed.
278 dataStore2.addBundle('/p3.ds', bundle);
279 expect(dataStore2.dependencies.last.includedPackageNames, ['p1', 'p2']);
280 }
281
258 test_getContainingLibraryUris_libraryUri() { 282 test_getContainingLibraryUris_libraryUri() {
259 String partUri = 'package:p1/u1.dart'; 283 String partUri = 'package:p1/u1.dart';
260 List<String> uris = dataStore.getContainingLibraryUris(partUri); 284 List<String> uris = dataStore.getContainingLibraryUris(partUri);
261 expect(uris, unorderedEquals([partUri])); 285 expect(uris, unorderedEquals([partUri]));
262 } 286 }
263 287
264 test_getContainingLibraryUris_partUri() { 288 test_getContainingLibraryUris_partUri() {
265 String partUri = 'package:p1/u2.dart'; 289 String partUri = 'package:p1/u2.dart';
266 List<String> uris = dataStore.getContainingLibraryUris(partUri); 290 List<String> uris = dataStore.getContainingLibraryUris(partUri);
267 expect(uris, unorderedEquals(['package:p1/u1.dart'])); 291 expect(uris, unorderedEquals(['package:p1/u1.dart']));
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 class _UnlinkedUnitMock extends TypedMock implements UnlinkedUnit {} 344 class _UnlinkedUnitMock extends TypedMock implements UnlinkedUnit {}
321 345
322 /// A matcher for ConflictingSummaryException. 346 /// A matcher for ConflictingSummaryException.
323 const Matcher isConflictingSummaryException = 347 const Matcher isConflictingSummaryException =
324 const _ConflictingSummaryException(); 348 const _ConflictingSummaryException();
325 349
326 class _ConflictingSummaryException extends TypeMatcher { 350 class _ConflictingSummaryException extends TypeMatcher {
327 const _ConflictingSummaryException() : super("ConflictingSummaryException"); 351 const _ConflictingSummaryException() : super("ConflictingSummaryException");
328 bool matches(item, Map matchState) => item is ConflictingSummaryException; 352 bool matches(item, Map matchState) => item is ConflictingSummaryException;
329 } 353 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/package_bundle_reader.dart ('k') | pkg/dev_compiler/lib/sdk/ddc_sdk.sum » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698