OLD | NEW |
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 library analyzer.test.src.context.context_builder_test; | 5 library analyzer.test.src.context.context_builder_test; |
6 | 6 |
7 import 'dart:io' as io; | 7 import 'dart:io' as io; |
8 | 8 |
9 import 'package:analyzer/file_system/file_system.dart'; | 9 import 'package:analyzer/file_system/file_system.dart'; |
10 import 'package:analyzer/file_system/memory_file_system.dart'; | 10 import 'package:analyzer/file_system/memory_file_system.dart'; |
11 import 'package:analyzer/file_system/physical_file_system.dart'; | 11 import 'package:analyzer/file_system/physical_file_system.dart'; |
| 12 import 'package:analyzer/source/package_map_resolver.dart'; |
12 import 'package:analyzer/src/context/builder.dart'; | 13 import 'package:analyzer/src/context/builder.dart'; |
| 14 import 'package:analyzer/src/context/source.dart'; |
13 import 'package:analyzer/src/generated/engine.dart'; | 15 import 'package:analyzer/src/generated/engine.dart'; |
14 import 'package:analyzer/src/generated/sdk.dart'; | 16 import 'package:analyzer/src/generated/sdk.dart'; |
15 import 'package:analyzer/src/generated/source.dart'; | 17 import 'package:analyzer/src/generated/source.dart'; |
16 import 'package:package_config/packages.dart'; | 18 import 'package:package_config/packages.dart'; |
17 import 'package:package_config/src/packages_impl.dart'; | 19 import 'package:package_config/src/packages_impl.dart'; |
18 import 'package:path/path.dart' as path; | 20 import 'package:path/path.dart' as path; |
19 import 'package:unittest/unittest.dart'; | 21 import 'package:unittest/unittest.dart'; |
20 | 22 |
21 import '../../generated/test_support.dart'; | 23 import '../../generated/test_support.dart'; |
22 import '../../reflective_tests.dart'; | 24 import '../../reflective_tests.dart'; |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 }); | 221 }); |
220 } | 222 } |
221 | 223 |
222 void test_createPackageMap_none() { | 224 void test_createPackageMap_none() { |
223 withTempDir((io.Directory tempDir) { | 225 withTempDir((io.Directory tempDir) { |
224 Packages packages = builder.createPackageMap(tempDir.path); | 226 Packages packages = builder.createPackageMap(tempDir.path); |
225 expect(packages, same(Packages.noPackages)); | 227 expect(packages, same(Packages.noPackages)); |
226 }); | 228 }); |
227 } | 229 } |
228 | 230 |
| 231 void test_createSourceFactory_fileProvider() { |
| 232 withTempDir((io.Directory tempDir) { |
| 233 createDefaultSdk(tempDir); |
| 234 String rootPath = tempDir.path; |
| 235 String projectPath = pathContext.join(rootPath, 'project'); |
| 236 String packageFilePath = pathContext.join(projectPath, '.packages'); |
| 237 String packageA = pathContext.join(rootPath, 'pkgs', 'a'); |
| 238 String packageB = pathContext.join(rootPath, 'pkgs', 'b'); |
| 239 createFile( |
| 240 packageFilePath, |
| 241 ''' |
| 242 a:${pathContext.toUri(packageA)} |
| 243 b:${pathContext.toUri(packageB)} |
| 244 '''); |
| 245 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); |
| 246 UriResolver resolver = new ResourceUriResolver(resourceProvider); |
| 247 builder.fileResolverProvider = (folder) => resolver; |
| 248 SourceFactoryImpl factory = |
| 249 builder.createSourceFactory(projectPath, options); |
| 250 expect(factory.resolvers, contains(same(resolver))); |
| 251 }); |
| 252 } |
| 253 |
229 void test_createSourceFactory_noProvider_packages_embedder_extensions() { | 254 void test_createSourceFactory_noProvider_packages_embedder_extensions() { |
230 withTempDir((io.Directory tempDir) { | 255 withTempDir((io.Directory tempDir) { |
231 createDefaultSdk(tempDir); | 256 createDefaultSdk(tempDir); |
232 String rootPath = tempDir.path; | 257 String rootPath = tempDir.path; |
233 String projectPath = pathContext.join(rootPath, 'project'); | 258 String projectPath = pathContext.join(rootPath, 'project'); |
234 String packageFilePath = pathContext.join(projectPath, '.packages'); | 259 String packageFilePath = pathContext.join(projectPath, '.packages'); |
235 String packageA = pathContext.join(rootPath, 'pkgs', 'a'); | 260 String packageA = pathContext.join(rootPath, 'pkgs', 'a'); |
236 String embedderPath = pathContext.join(packageA, '_embedder.yaml'); | 261 String embedderPath = pathContext.join(packageA, '_embedder.yaml'); |
237 String packageB = pathContext.join(rootPath, 'pkgs', 'b'); | 262 String packageB = pathContext.join(rootPath, 'pkgs', 'b'); |
238 String extensionPath = pathContext.join(packageB, '_sdkext'); | 263 String extensionPath = pathContext.join(packageB, '_sdkext'); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 Source dartSource = factory.forUri('dart:core'); | 364 Source dartSource = factory.forUri('dart:core'); |
340 expect(dartSource, isNotNull); | 365 expect(dartSource, isNotNull); |
341 expect(dartSource.fullName, '$defaultSdkPath/lib/core/core.dart'); | 366 expect(dartSource.fullName, '$defaultSdkPath/lib/core/core.dart'); |
342 | 367 |
343 Source packageSource = factory.forUri('package:a/a.dart'); | 368 Source packageSource = factory.forUri('package:a/a.dart'); |
344 expect(packageSource, isNotNull); | 369 expect(packageSource, isNotNull); |
345 expect(packageSource.fullName, pathContext.join(packageA, 'a.dart')); | 370 expect(packageSource.fullName, pathContext.join(packageA, 'a.dart')); |
346 }); | 371 }); |
347 } | 372 } |
348 | 373 |
| 374 void test_createSourceFactory_packageProvider() { |
| 375 withTempDir((io.Directory tempDir) { |
| 376 createDefaultSdk(tempDir); |
| 377 String rootPath = tempDir.path; |
| 378 String projectPath = pathContext.join(rootPath, 'project'); |
| 379 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); |
| 380 UriResolver resolver = new PackageMapUriResolver(resourceProvider, {}); |
| 381 builder.packageResolverProvider = (folder) => resolver; |
| 382 SourceFactoryImpl factory = |
| 383 builder.createSourceFactory(projectPath, options); |
| 384 expect(factory.resolvers, contains(same(resolver))); |
| 385 }); |
| 386 } |
| 387 |
349 @failingTest | 388 @failingTest |
350 void test_createSourceFactory_provider() { | |
351 fail('Incomplete test'); | |
352 } | |
353 | |
354 @failingTest | |
355 void test_findSdk_embedder_extensions() { | 389 void test_findSdk_embedder_extensions() { |
356 // See test_createSourceFactory_noProvider_packages_embedder_extensions | 390 // See test_createSourceFactory_noProvider_packages_embedder_extensions |
357 fail('Incomplete test'); | 391 fail('Incomplete test'); |
358 } | 392 } |
359 | 393 |
360 @failingTest | 394 @failingTest |
361 void test_findSdk_embedder_noExtensions() { | 395 void test_findSdk_embedder_noExtensions() { |
362 // See test_createSourceFactory_noProvider_packages_embedder_noExtensions | 396 // See test_createSourceFactory_noProvider_packages_embedder_noExtensions |
363 fail('Incomplete test'); | 397 fail('Incomplete test'); |
364 } | 398 } |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 expect(actual.lint, expected.lint); | 689 expect(actual.lint, expected.lint); |
656 expect(actual.preserveComments, expected.preserveComments); | 690 expect(actual.preserveComments, expected.preserveComments); |
657 expect(actual.strongMode, expected.strongMode); | 691 expect(actual.strongMode, expected.strongMode); |
658 expect(actual.strongModeHints, expected.strongModeHints); | 692 expect(actual.strongModeHints, expected.strongModeHints); |
659 expect(actual.implicitCasts, expected.implicitCasts); | 693 expect(actual.implicitCasts, expected.implicitCasts); |
660 expect(actual.implicitDynamic, expected.implicitDynamic); | 694 expect(actual.implicitDynamic, expected.implicitDynamic); |
661 expect(actual.trackCacheDependencies, expected.trackCacheDependencies); | 695 expect(actual.trackCacheDependencies, expected.trackCacheDependencies); |
662 expect(actual.finerGrainedInvalidation, expected.finerGrainedInvalidation); | 696 expect(actual.finerGrainedInvalidation, expected.finerGrainedInvalidation); |
663 } | 697 } |
664 } | 698 } |
OLD | NEW |