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

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

Issue 2233083002: Compute both strong and spec mode unlinked bundles. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Link in strong or spec mode. Created 4 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
« no previous file with comments | « pkg/analyzer/lib/src/summary/pub_summary.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/dart/element/element.dart'; 5 import 'package:analyzer/dart/element/element.dart';
6 import 'package:analyzer/file_system/file_system.dart'; 6 import 'package:analyzer/file_system/file_system.dart';
7 import 'package:analyzer/source/package_map_resolver.dart'; 7 import 'package:analyzer/source/package_map_resolver.dart';
8 import 'package:analyzer/src/generated/sdk.dart'; 8 import 'package:analyzer/src/generated/sdk.dart';
9 import 'package:analyzer/src/generated/source.dart'; 9 import 'package:analyzer/src/generated/source.dart';
10 import 'package:analyzer/src/summary/idl.dart'; 10 import 'package:analyzer/src/summary/idl.dart';
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 { 173 {
174 PackageBundle bundle = _getBundleByPackageName(bundles, 'bbb'); 174 PackageBundle bundle = _getBundleByPackageName(bundles, 'bbb');
175 expect(bundle.linkedLibraryUris, isEmpty); 175 expect(bundle.linkedLibraryUris, isEmpty);
176 expect(bundle.unlinkedUnitUris, ['package:bbb/b.dart']); 176 expect(bundle.unlinkedUnitUris, ['package:bbb/b.dart']);
177 expect(bundle.unlinkedUnits, hasLength(1)); 177 expect(bundle.unlinkedUnits, hasLength(1));
178 expect(bundle.unlinkedUnits[0].classes.map((c) => c.name), ['B']); 178 expect(bundle.unlinkedUnits[0].classes.map((c) => c.name), ['B']);
179 } 179 }
180 } 180 }
181 181
182 // The files must be created. 182 // The files must be created.
183 File fileA = libFolderA.parent.getChildAssumingFile('unlinked.ds'); 183 _assertFileExists(libFolderA.parent, PubSummaryManager.UNLINKED_NAME);
184 File fileB = libFolderB.parent.getChildAssumingFile('unlinked.ds'); 184 _assertFileExists(libFolderA.parent, PubSummaryManager.UNLINKED_SPEC_NAME);
185 expect(fileA.exists, isTrue); 185 _assertFileExists(libFolderB.parent, PubSummaryManager.UNLINKED_NAME);
186 expect(fileB.exists, isTrue); 186 _assertFileExists(libFolderB.parent, PubSummaryManager.UNLINKED_SPEC_NAME);
187 } 187 }
188 188
189 test_getUnlinkedBundles_nullPackageMap() async { 189 test_getUnlinkedBundles_nullPackageMap() async {
190 context.sourceFactory = 190 context.sourceFactory =
191 new SourceFactory(<UriResolver>[sdkResolver, resourceResolver]); 191 new SourceFactory(<UriResolver>[sdkResolver, resourceResolver]);
192 Map<PubPackage, PackageBundle> bundles = 192 Map<PubPackage, PackageBundle> bundles =
193 manager.getUnlinkedBundles(context); 193 manager.getUnlinkedBundles(context);
194 expect(bundles, isEmpty); 194 expect(bundles, isEmpty);
195 } 195 }
196 196
(...skipping 16 matching lines...) Expand all
213 expect( 213 expect(
214 PubSummaryManager.isPathInPubCache(pathos.windows, 214 PubSummaryManager.isPathInPubCache(pathos.windows,
215 r'C:\Users\user\Setters\Pub\Cache\hosted\foo\lib\bar.dart'), 215 r'C:\Users\user\Setters\Pub\Cache\hosted\foo\lib\bar.dart'),
216 isTrue); 216 isTrue);
217 expect( 217 expect(
218 PubSummaryManager.isPathInPubCache( 218 PubSummaryManager.isPathInPubCache(
219 pathos.windows, r'C:\Users\user\Sources\Dart\foo\lib\bar.dart'), 219 pathos.windows, r'C:\Users\user\Sources\Dart\foo\lib\bar.dart'),
220 isFalse); 220 isFalse);
221 } 221 }
222 222
223 void _assertFileExists(Folder folder, String fileName) {
224 expect(folder.getChildAssumingFile(fileName).exists, isTrue);
225 }
226
223 void _assertLinkedNameReference( 227 void _assertLinkedNameReference(
224 UnlinkedUnit unlinkedUnit, 228 UnlinkedUnit unlinkedUnit,
225 LinkedLibrary linkedLibrary, 229 LinkedLibrary linkedLibrary,
226 LinkedUnit linkedUnit, 230 LinkedUnit linkedUnit,
227 int typeNameReference, 231 int typeNameReference,
228 String expectedName, 232 String expectedName,
229 String expectedDependencyUri) { 233 String expectedDependencyUri) {
230 expect(unlinkedUnit.references[typeNameReference].name, expectedName); 234 expect(unlinkedUnit.references[typeNameReference].name, expectedName);
231 int typeNameDependency = 235 int typeNameDependency =
232 linkedUnit.references[typeNameReference].dependency; 236 linkedUnit.references[typeNameReference].dependency;
(...skipping 19 matching lines...) Expand all
252 }); 256 });
253 } 257 }
254 258
255 static PackageBundle _getBundleByPackageName( 259 static PackageBundle _getBundleByPackageName(
256 Map<PubPackage, PackageBundle> bundles, String name) { 260 Map<PubPackage, PackageBundle> bundles, String name) {
257 PubPackage package = 261 PubPackage package =
258 bundles.keys.singleWhere((package) => package.name == name); 262 bundles.keys.singleWhere((package) => package.name == name);
259 return bundles[package]; 263 return bundles[package];
260 } 264 }
261 } 265 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/pub_summary.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698