| Index: pkg/analysis_server/test/context_manager_test.dart
|
| diff --git a/pkg/analysis_server/test/context_manager_test.dart b/pkg/analysis_server/test/context_manager_test.dart
|
| index 44b0a1187fbe238841b67a724071aa43a11c954c..09f6ae03964bc87106bd064c606fc92306b1debc 100644
|
| --- a/pkg/analysis_server/test/context_manager_test.dart
|
| +++ b/pkg/analysis_server/test/context_manager_test.dart
|
| @@ -64,63 +64,6 @@ class AbstractContextManagerTest {
|
|
|
| String projPath = '/my/proj';
|
|
|
| - void fail_test_setRoots_addPackageRoot() {
|
| - // TODO(paulberry): failing due to dartbug.com/23909.
|
| - String packagePathFoo = '/package1/foo';
|
| - String packageRootPath = '/package2/foo';
|
| - Folder packageFolder = resourceProvider.newFolder(packagePathFoo);
|
| - packageMapProvider.packageMap = {'foo': [packageFolder]};
|
| - List<String> includedPaths = <String>[projPath];
|
| - List<String> excludedPaths = <String>[];
|
| - manager.setRoots(includedPaths, excludedPaths, <String, String>{});
|
| - _checkPackageMap(projPath, equals(packageMapProvider.packageMap));
|
| - manager.setRoots(includedPaths, excludedPaths, <String, String>{
|
| - projPath: packageRootPath
|
| - });
|
| - _checkPackageRoot(projPath, equals(packageRootPath));
|
| - }
|
| -
|
| - void fail_test_setRoots_changePackageRoot() {
|
| - // TODO(paulberry): failing due to dartbug.com/23909.
|
| - String packageRootPath1 = '/package1';
|
| - String packageRootPath2 = '/package2';
|
| - List<String> includedPaths = <String>[projPath];
|
| - List<String> excludedPaths = <String>[];
|
| - manager.setRoots(includedPaths, excludedPaths, <String, String>{
|
| - projPath: packageRootPath1
|
| - });
|
| - _checkPackageRoot(projPath, equals(packageRootPath1));
|
| - manager.setRoots(includedPaths, excludedPaths, <String, String>{
|
| - projPath: packageRootPath2
|
| - });
|
| - _checkPackageRoot(projPath, equals(packageRootPath2));
|
| - }
|
| -
|
| - void fail_test_setRoots_newFolderWithPackageRoot() {
|
| - // TODO(paulberry): failing due to dartbug.com/23909.
|
| - String packageRootPath = '/package';
|
| - manager.setRoots(<String>[projPath], <String>[], <String, String>{
|
| - projPath: packageRootPath
|
| - });
|
| - _checkPackageRoot(projPath, equals(packageRootPath));
|
| - }
|
| -
|
| - void fail_test_setRoots_removePackageRoot() {
|
| - // TODO(paulberry): failing due to dartbug.com/23909.
|
| - String packagePathFoo = '/package1/foo';
|
| - String packageRootPath = '/package2/foo';
|
| - Folder packageFolder = resourceProvider.newFolder(packagePathFoo);
|
| - packageMapProvider.packageMap = {'foo': [packageFolder]};
|
| - List<String> includedPaths = <String>[projPath];
|
| - List<String> excludedPaths = <String>[];
|
| - manager.setRoots(includedPaths, excludedPaths, <String, String>{
|
| - projPath: packageRootPath
|
| - });
|
| - _checkPackageRoot(projPath, equals(packageRootPath));
|
| - manager.setRoots(includedPaths, excludedPaths, <String, String>{});
|
| - _checkPackageMap(projPath, equals(packageMapProvider.packageMap));
|
| - }
|
| -
|
| String newFile(List<String> pathComponents, [String content = '']) {
|
| String filePath = posix.joinAll(pathComponents);
|
| resourceProvider.newFile(filePath, content);
|
| @@ -632,6 +575,36 @@ analyzer:
|
| subProjectB, equals(packageMapProvider.packageMaps[subProjectB]));
|
| }
|
|
|
| + void test_setRoots_addPackageRoot() {
|
| + String packagePathFoo = '/package1/foo';
|
| + String packageRootPath = '/package2/foo';
|
| + Folder packageFolder = resourceProvider.newFolder(packagePathFoo);
|
| + packageMapProvider.packageMap = {'foo': [packageFolder]};
|
| + List<String> includedPaths = <String>[projPath];
|
| + List<String> excludedPaths = <String>[];
|
| + manager.setRoots(includedPaths, excludedPaths, <String, String>{});
|
| + _checkPackageMap(projPath, equals(packageMapProvider.packageMap));
|
| + manager.setRoots(includedPaths, excludedPaths, <String, String>{
|
| + projPath: packageRootPath
|
| + });
|
| + _checkPackageRoot(projPath, equals(packageRootPath));
|
| + }
|
| +
|
| + void test_setRoots_changePackageRoot() {
|
| + String packageRootPath1 = '/package1';
|
| + String packageRootPath2 = '/package2';
|
| + List<String> includedPaths = <String>[projPath];
|
| + List<String> excludedPaths = <String>[];
|
| + manager.setRoots(includedPaths, excludedPaths, <String, String>{
|
| + projPath: packageRootPath1
|
| + });
|
| + _checkPackageRoot(projPath, equals(packageRootPath1));
|
| + manager.setRoots(includedPaths, excludedPaths, <String, String>{
|
| + projPath: packageRootPath2
|
| + });
|
| + _checkPackageRoot(projPath, equals(packageRootPath2));
|
| + }
|
| +
|
| void test_setRoots_exclude_newRoot_withExcludedFile() {
|
| // prepare paths
|
| String project = '/project';
|
| @@ -756,6 +729,14 @@ analyzer:
|
| callbacks.assertContextFiles(project, [fileA, fileB]);
|
| }
|
|
|
| + void test_setRoots_newFolderWithPackageRoot() {
|
| + String packageRootPath = '/package';
|
| + manager.setRoots(<String>[projPath], <String>[], <String, String>{
|
| + projPath: packageRootPath
|
| + });
|
| + _checkPackageRoot(projPath, equals(packageRootPath));
|
| + }
|
| +
|
| void test_setRoots_newlyAddedFoldersGetProperPackageMap() {
|
| String packagePath = '/package/foo';
|
| Folder packageFolder = resourceProvider.newFolder(packagePath);
|
| @@ -888,6 +869,21 @@ analyzer:
|
| callbacks.assertContextFiles(subProjectA, [subProjectA_file]);
|
| }
|
|
|
| + void test_setRoots_removePackageRoot() {
|
| + String packagePathFoo = '/package1/foo';
|
| + String packageRootPath = '/package2/foo';
|
| + Folder packageFolder = resourceProvider.newFolder(packagePathFoo);
|
| + packageMapProvider.packageMap = {'foo': [packageFolder]};
|
| + List<String> includedPaths = <String>[projPath];
|
| + List<String> excludedPaths = <String>[];
|
| + manager.setRoots(includedPaths, excludedPaths, <String, String>{
|
| + projPath: packageRootPath
|
| + });
|
| + _checkPackageRoot(projPath, equals(packageRootPath));
|
| + manager.setRoots(includedPaths, excludedPaths, <String, String>{});
|
| + _checkPackageMap(projPath, equals(packageMapProvider.packageMap));
|
| + }
|
| +
|
| test_watch_addDummyLink() {
|
| manager.setRoots(<String>[projPath], <String>[], <String, String>{});
|
| // empty folder initially
|
| @@ -1420,11 +1416,10 @@ analyzer:
|
| * using a package root maching [expectation].
|
| */
|
| void _checkPackageRoot(String path, expectation) {
|
| - // TODO(paulberry): this code needs to be reworked, since the context
|
| - // manager inspects the contents of the package root directory and converts
|
| - // it to a package map. The only reason this code used to work was due to
|
| - // dartbug.com/23909.
|
| - fail('Cannot verify package root');
|
| + FolderDisposition disposition = callbacks.currentContextDispositions[path];
|
| + expect(disposition.packageRoot, expectation);
|
| + // TODO(paulberry): we should also verify that the package map itself is
|
| + // correct. See dartbug.com/23909.
|
| }
|
| }
|
|
|
|
|