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

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

Issue 2996783002: Don't record dependencies in SummaryDataStore. (Closed)
Patch Set: Created 3 years, 4 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 146
147 test_compute_SOURCE_KIND_partSource() { 147 test_compute_SOURCE_KIND_partSource() {
148 bool success = provider.compute(entry2, SOURCE_KIND); 148 bool success = provider.compute(entry2, SOURCE_KIND);
149 expect(success, isTrue); 149 expect(success, isTrue);
150 expect(entry2.getValue(SOURCE_KIND), SourceKind.PART); 150 expect(entry2.getValue(SOURCE_KIND), SourceKind.PART);
151 } 151 }
152 } 152 }
153 153
154 @reflectiveTest 154 @reflectiveTest
155 class SummaryDataStoreTest { 155 class SummaryDataStoreTest {
156 SummaryDataStore dataStore = new SummaryDataStore(<String>[], 156 SummaryDataStore dataStore =
157 recordDependencyInfo: true, disallowOverlappingSummaries: true); 157 new SummaryDataStore(<String>[], disallowOverlappingSummaries: true);
158 158
159 PackageBundle bundle1 = new _PackageBundleMock(); 159 PackageBundle bundle1 = new _PackageBundleMock();
160 PackageBundle bundle2 = new _PackageBundleMock(); 160 PackageBundle bundle2 = new _PackageBundleMock();
161 UnlinkedUnit unlinkedUnit11 = new _UnlinkedUnitMock(); 161 UnlinkedUnit unlinkedUnit11 = new _UnlinkedUnitMock();
162 UnlinkedUnit unlinkedUnit12 = new _UnlinkedUnitMock(); 162 UnlinkedUnit unlinkedUnit12 = new _UnlinkedUnitMock();
163 UnlinkedUnit unlinkedUnit21 = new _UnlinkedUnitMock(); 163 UnlinkedUnit unlinkedUnit21 = new _UnlinkedUnitMock();
164 LinkedLibrary linkedLibrary1 = new _LinkedLibraryMock(); 164 LinkedLibrary linkedLibrary1 = new _LinkedLibraryMock();
165 LinkedLibrary linkedLibrary2 = new _LinkedLibraryMock(); 165 LinkedLibrary linkedLibrary2 = new _LinkedLibraryMock();
166 166
167 void setUp() { 167 void setUp() {
168 _setupDataStore(dataStore); 168 _setupDataStore(dataStore);
169 } 169 }
170 170
171 test_addBundle() { 171 test_addBundle() {
172 expect(dataStore.bundles, unorderedEquals([bundle1, bundle2])); 172 expect(dataStore.bundles, unorderedEquals([bundle1, bundle2]));
173 expect(dataStore.dependencies[0].summaryPath, '/p1.ds');
174 expect(dataStore.dependencies[0].apiSignature, 'signature1');
175 expect(dataStore.dependencies[0].includedPackageNames, ['p1']);
176 expect(dataStore.dependencies[0].includesFileUris, false);
177 expect(dataStore.dependencies[0].includesDartUris, false);
178 expect(dataStore.dependencies[1].summaryPath, '/p2.ds');
179 expect(dataStore.dependencies[1].apiSignature, 'signature2');
180 expect(dataStore.dependencies[1].includedPackageNames, ['p2']);
181 expect(dataStore.dependencies[1].includesFileUris, false);
182 expect(dataStore.dependencies[1].includesDartUris, false);
183 expect(dataStore.uriToSummaryPath, 173 expect(dataStore.uriToSummaryPath,
184 containsPair('package:p1/u1.dart', '/p1.ds')); 174 containsPair('package:p1/u1.dart', '/p1.ds'));
185 // unlinkedMap 175 // unlinkedMap
186 expect(dataStore.unlinkedMap, hasLength(3)); 176 expect(dataStore.unlinkedMap, hasLength(3));
187 expect(dataStore.unlinkedMap, 177 expect(dataStore.unlinkedMap,
188 containsPair('package:p1/u1.dart', unlinkedUnit11)); 178 containsPair('package:p1/u1.dart', unlinkedUnit11));
189 expect(dataStore.unlinkedMap, 179 expect(dataStore.unlinkedMap,
190 containsPair('package:p1/u2.dart', unlinkedUnit12)); 180 containsPair('package:p1/u2.dart', unlinkedUnit12));
191 expect(dataStore.unlinkedMap, 181 expect(dataStore.unlinkedMap,
192 containsPair('package:p2/u1.dart', unlinkedUnit21)); 182 containsPair('package:p2/u1.dart', unlinkedUnit21));
193 // linkedMap 183 // linkedMap
194 expect(dataStore.linkedMap, hasLength(2)); 184 expect(dataStore.linkedMap, hasLength(2));
195 expect(dataStore.linkedMap, 185 expect(dataStore.linkedMap,
196 containsPair('package:p1/u1.dart', linkedLibrary1)); 186 containsPair('package:p1/u1.dart', linkedLibrary1));
197 expect(dataStore.linkedMap, 187 expect(dataStore.linkedMap,
198 containsPair('package:p2/u1.dart', linkedLibrary2)); 188 containsPair('package:p2/u1.dart', linkedLibrary2));
199 } 189 }
200 190
201 test_addBundle_dartUris() { 191 test_addBundle_dartUris() {
202 PackageBundle bundle = new _PackageBundleMock(); 192 PackageBundle bundle = new _PackageBundleMock();
203 when(bundle.unlinkedUnitUris).thenReturn(<String>['dart:core']); 193 when(bundle.unlinkedUnitUris).thenReturn(<String>['dart:core']);
204 when(bundle.unlinkedUnits).thenReturn(<UnlinkedUnit>[unlinkedUnit11]); 194 when(bundle.unlinkedUnits).thenReturn(<UnlinkedUnit>[unlinkedUnit11]);
205 when(bundle.linkedLibraryUris).thenReturn(<String>['dart:core']); 195 when(bundle.linkedLibraryUris).thenReturn(<String>['dart:core']);
206 when(bundle.linkedLibraries).thenReturn(<LinkedLibrary>[linkedLibrary1]); 196 when(bundle.linkedLibraries).thenReturn(<LinkedLibrary>[linkedLibrary1]);
207 when(bundle.apiSignature).thenReturn('signature'); 197 when(bundle.apiSignature).thenReturn('signature');
208 dataStore.addBundle('/p3.ds', bundle); 198 dataStore.addBundle('/p3.ds', bundle);
209 expect(dataStore.dependencies.last.includedPackageNames, []);
210 expect(dataStore.dependencies.last.includesFileUris, false);
211 expect(dataStore.dependencies.last.includesDartUris, true);
212 } 199 }
213 200
214 test_addBundle_fileUris() { 201 test_addBundle_fileUris() {
215 PackageBundle bundle = new _PackageBundleMock(); 202 PackageBundle bundle = new _PackageBundleMock();
216 when(bundle.unlinkedUnitUris).thenReturn(<String>['file:/foo.dart']); 203 when(bundle.unlinkedUnitUris).thenReturn(<String>['file:/foo.dart']);
217 when(bundle.unlinkedUnits).thenReturn(<UnlinkedUnit>[unlinkedUnit11]); 204 when(bundle.unlinkedUnits).thenReturn(<UnlinkedUnit>[unlinkedUnit11]);
218 when(bundle.linkedLibraryUris).thenReturn(<String>['file:/foo.dart']); 205 when(bundle.linkedLibraryUris).thenReturn(<String>['file:/foo.dart']);
219 when(bundle.linkedLibraries).thenReturn(<LinkedLibrary>[linkedLibrary1]); 206 when(bundle.linkedLibraries).thenReturn(<LinkedLibrary>[linkedLibrary1]);
220 when(bundle.apiSignature).thenReturn('signature'); 207 when(bundle.apiSignature).thenReturn('signature');
221 dataStore.addBundle('/p3.ds', bundle); 208 dataStore.addBundle('/p3.ds', bundle);
222 expect(dataStore.dependencies.last.includedPackageNames, []);
223 expect(dataStore.dependencies.last.includesFileUris, true);
224 expect(dataStore.dependencies.last.includesDartUris, false);
225 } 209 }
226 210
227 test_addBundle_multiProject() { 211 test_addBundle_multiProject() {
228 PackageBundle bundle = new _PackageBundleMock(); 212 PackageBundle bundle = new _PackageBundleMock();
229 when(bundle.unlinkedUnitUris) 213 when(bundle.unlinkedUnitUris)
230 .thenReturn(<String>['package:p2/u1.dart', 'package:p1/u1.dart']); 214 .thenReturn(<String>['package:p2/u1.dart', 'package:p1/u1.dart']);
231 when(bundle.unlinkedUnits) 215 when(bundle.unlinkedUnits)
232 .thenReturn(<UnlinkedUnit>[unlinkedUnit21, unlinkedUnit11]); 216 .thenReturn(<UnlinkedUnit>[unlinkedUnit21, unlinkedUnit11]);
233 when(bundle.linkedLibraryUris) 217 when(bundle.linkedLibraryUris)
234 .thenReturn(<String>['package:p2/u1.dart', 'package:p1/u1.dart']); 218 .thenReturn(<String>['package:p2/u1.dart', 'package:p1/u1.dart']);
235 when(bundle.linkedLibraries) 219 when(bundle.linkedLibraries)
236 .thenReturn(<LinkedLibrary>[linkedLibrary2, linkedLibrary1]); 220 .thenReturn(<LinkedLibrary>[linkedLibrary2, linkedLibrary1]);
237 when(bundle.apiSignature).thenReturn('signature'); 221 when(bundle.apiSignature).thenReturn('signature');
238 // p3 conflicts (overlaps) with existing summaries. 222 // p3 conflicts (overlaps) with existing summaries.
239 expect(() => dataStore.addBundle('/p3.ds', bundle), 223 expect(() => dataStore.addBundle('/p3.ds', bundle),
240 throwsA(isConflictingSummaryException)); 224 throwsA(isConflictingSummaryException));
241 expect(dataStore.dependencies.last.includedPackageNames, ['p1', 'p2']);
242 } 225 }
243 226
244 test_addBundle_multiProjectOverlap() { 227 test_addBundle_multiProjectOverlap() {
245 SummaryDataStore dataStore2 = new SummaryDataStore(<String>[], 228 SummaryDataStore dataStore2 =
246 recordDependencyInfo: true, disallowOverlappingSummaries: false); 229 new SummaryDataStore(<String>[], disallowOverlappingSummaries: false);
247 _setupDataStore(dataStore2); 230 _setupDataStore(dataStore2);
248 231
249 PackageBundle bundle = new _PackageBundleMock(); 232 PackageBundle bundle = new _PackageBundleMock();
250 when(bundle.unlinkedUnitUris) 233 when(bundle.unlinkedUnitUris)
251 .thenReturn(<String>['package:p2/u1.dart', 'package:p1/u1.dart']); 234 .thenReturn(<String>['package:p2/u1.dart', 'package:p1/u1.dart']);
252 when(bundle.unlinkedUnits) 235 when(bundle.unlinkedUnits)
253 .thenReturn(<UnlinkedUnit>[unlinkedUnit21, unlinkedUnit11]); 236 .thenReturn(<UnlinkedUnit>[unlinkedUnit21, unlinkedUnit11]);
254 when(bundle.linkedLibraryUris) 237 when(bundle.linkedLibraryUris)
255 .thenReturn(<String>['package:p2/u1.dart', 'package:p1/u1.dart']); 238 .thenReturn(<String>['package:p2/u1.dart', 'package:p1/u1.dart']);
256 when(bundle.linkedLibraries) 239 when(bundle.linkedLibraries)
257 .thenReturn(<LinkedLibrary>[linkedLibrary2, linkedLibrary1]); 240 .thenReturn(<LinkedLibrary>[linkedLibrary2, linkedLibrary1]);
258 when(bundle.apiSignature).thenReturn('signature'); 241 when(bundle.apiSignature).thenReturn('signature');
259 // p3 conflicts (overlaps) with existing summaries, but now allowed. 242 // p3 conflicts (overlaps) with existing summaries, but now allowed.
260 dataStore2.addBundle('/p3.ds', bundle); 243 dataStore2.addBundle('/p3.ds', bundle);
261 expect(dataStore2.dependencies.last.includedPackageNames, ['p1', 'p2']);
262 } 244 }
263 245
264 test_getContainingLibraryUris_libraryUri() { 246 test_getContainingLibraryUris_libraryUri() {
265 String partUri = 'package:p1/u1.dart'; 247 String partUri = 'package:p1/u1.dart';
266 List<String> uris = dataStore.getContainingLibraryUris(partUri); 248 List<String> uris = dataStore.getContainingLibraryUris(partUri);
267 expect(uris, unorderedEquals([partUri])); 249 expect(uris, unorderedEquals([partUri]));
268 } 250 }
269 251
270 test_getContainingLibraryUris_partUri() { 252 test_getContainingLibraryUris_partUri() {
271 String partUri = 'package:p1/u2.dart'; 253 String partUri = 'package:p1/u2.dart';
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 @override 328 @override
347 bool hasResultsForSource(Source source) { 329 bool hasResultsForSource(Source source) {
348 return sourcesWithResults.contains(source); 330 return sourcesWithResults.contains(source);
349 } 331 }
350 } 332 }
351 333
352 class _UnlinkedPublicNamespaceMock extends Mock 334 class _UnlinkedPublicNamespaceMock extends Mock
353 implements UnlinkedPublicNamespace {} 335 implements UnlinkedPublicNamespace {}
354 336
355 class _UnlinkedUnitMock extends Mock implements UnlinkedUnit {} 337 class _UnlinkedUnitMock extends Mock implements UnlinkedUnit {}
OLDNEW
« no previous file with comments | « pkg/analyzer/test/src/summary/linker_test.dart ('k') | pkg/analyzer/test/src/summary/summarize_ast_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698