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

Side by Side Diff: pkg/analysis_server/test/context_manager_test.dart

Issue 1653733002: Support for embedder dependency changes (#25606). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: master_merge Created 4 years, 10 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/analysis_server/lib/src/context_manager.dart ('k') | pkg/analyzer/lib/source/embedder.dart » ('j') | 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library test.context.directory.manager; 5 library test.context.directory.manager;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analysis_server/src/context_manager.dart'; 9 import 'package:analysis_server/src/context_manager.dart';
10 import 'package:analyzer/file_system/file_system.dart'; 10 import 'package:analyzer/file_system/file_system.dart';
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 expect(subProjContextInfo, isNotNull); 279 expect(subProjContextInfo, isNotNull);
280 expect(subProjContextInfo.folder, subProjFolder); 280 expect(subProjContextInfo.folder, subProjFolder);
281 expect(projContextInfo.context != subProjContextInfo.context, isTrue); 281 expect(projContextInfo.context != subProjContextInfo.context, isTrue);
282 // Check that contextsInAnalysisRoot() works. 282 // Check that contextsInAnalysisRoot() works.
283 List<AnalysisContext> contexts = manager.contextsInAnalysisRoot(projFolder); 283 List<AnalysisContext> contexts = manager.contextsInAnalysisRoot(projFolder);
284 expect(contexts, hasLength(2)); 284 expect(contexts, hasLength(2));
285 expect(contexts, contains(projContextInfo.context)); 285 expect(contexts, contains(projContextInfo.context));
286 expect(contexts, contains(subProjContextInfo.context)); 286 expect(contexts, contains(subProjContextInfo.context));
287 } 287 }
288 288
289 test_embedder_added() async {
290 // Create files.
291 String libPath = newFolder([projPath, LIB_NAME]);
292 newFile([libPath, 'main.dart']);
293 newFile([libPath, 'nope.dart']);
294 String embedderPath = newFolder([projPath, 'embedder']);
295 newFile([embedderPath, 'entry.dart']);
296 String embedderSrcPath = newFolder([projPath, 'embedder', 'src']);
297 newFile([embedderSrcPath, 'part.dart']);
298
299 // Setup _embedder.yaml.
300 newFile(
301 [libPath, '_embedder.yaml'],
302 r'''
303 embedded_libs:
304 "dart:foobar": "../embedder/entry.dart"
305 "dart:typed_data": "../embedder/src/part"
306 ''');
307
308 Folder projectFolder = resourceProvider.newFolder(projPath);
309
310 // NOTE that this is Not in our package path yet.
311
312 // Setup context.
313 manager.setRoots(<String>[projPath], <String>[], <String, String>{});
314 await pumpEventQueue();
315 // Confirm that one context was created.
316 List<AnalysisContext> contexts =
317 manager.contextsInAnalysisRoot(projectFolder);
318 expect(contexts, isNotNull);
319 expect(contexts, hasLength(1));
320
321 // No embedded libs yet.
322 expect(contexts.first.sourceFactory.forUri('dart:typed_data'), isNull);
323
324 // Add .packages file that introduces a dependency with embedded libs.
325 newFile(
326 [projPath, '.packages'],
327 r'''
328 test_pack:lib/''');
329
330 await pumpEventQueue();
331
332 contexts = manager.contextsInAnalysisRoot(projectFolder);
333
334 // Confirm that we still have just one context.
335 expect(contexts, isNotNull);
336 expect(contexts, hasLength(1));
337
338 // Embedded lib should be defined now.
339 expect(contexts.first.sourceFactory.forUri('dart:typed_data'), isNotNull);
340 }
341
289 test_embedder_options() async { 342 test_embedder_options() async {
290 // Create files. 343 // Create files.
291 String libPath = newFolder([projPath, LIB_NAME]); 344 String libPath = newFolder([projPath, LIB_NAME]);
292 String sdkExtPath = newFolder([projPath, 'sdk_ext']); 345 String sdkExtPath = newFolder([projPath, 'sdk_ext']);
293 newFile([projPath, 'test', 'test.dart']); 346 newFile([projPath, 'test', 'test.dart']);
294 newFile([sdkExtPath, 'entry.dart']); 347 newFile([sdkExtPath, 'entry.dart']);
295 // Setup _embedder.yaml. 348 // Setup _embedder.yaml.
296 newFile( 349 newFile(
297 [libPath, '_embedder.yaml'], 350 [libPath, '_embedder.yaml'],
298 r''' 351 r'''
(...skipping 2128 matching lines...) Expand 10 before | Expand all | Expand 10 after
2427 class TestUriResolver extends UriResolver { 2480 class TestUriResolver extends UriResolver {
2428 Map<Uri, Source> uriMap; 2481 Map<Uri, Source> uriMap;
2429 2482
2430 TestUriResolver(this.uriMap); 2483 TestUriResolver(this.uriMap);
2431 2484
2432 @override 2485 @override
2433 Source resolveAbsolute(Uri uri, [Uri actualUri]) { 2486 Source resolveAbsolute(Uri uri, [Uri actualUri]) {
2434 return uriMap[uri]; 2487 return uriMap[uri];
2435 } 2488 }
2436 } 2489 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/context_manager.dart ('k') | pkg/analyzer/lib/source/embedder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698