Chromium Code Reviews| 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 dd3961c80d15393840a0e2e3df3fc8afae24f337..a8f336b03e07c67a80043c86e17f60344841b981 100644 |
| --- a/pkg/analysis_server/test/context_manager_test.dart |
| +++ b/pkg/analysis_server/test/context_manager_test.dart |
| @@ -93,6 +93,51 @@ class AbstractContextManagerTest { |
| resourceProvider.newFolder(projPath); |
| } |
| + test_analysis_options_parse_failure() async { |
| + // Create files. |
| + String libPath = newFolder([projPath, LIB_NAME]); |
| + newFile([libPath, 'main.dart']); |
| + String sdkExtPath = newFolder([projPath, 'sdk_ext']); |
| + newFile([sdkExtPath, 'entry.dart']); |
| + String sdkExtSrcPath = newFolder([projPath, 'sdk_ext', 'src']); |
| + newFile([sdkExtSrcPath, 'part.dart']); |
| + // Setup analysis options file with ignore list. |
| + newFile( |
| + [projPath, '.analysis_options'], |
| + r''' |
| +; |
| +'''); |
| + // Setup context. |
| + manager.setRoots(<String>[projPath], <String>[], <String, String>{}); |
| + |
| + // No error means success. |
| + } |
| + |
| + void test_contextsInAnalysisRoot_nestedContext() { |
| + String subProjPath = posix.join(projPath, 'subproj'); |
| + Folder subProjFolder = resourceProvider.newFolder(subProjPath); |
| + resourceProvider.newFile( |
| + posix.join(subProjPath, 'pubspec.yaml'), 'contents'); |
| + String subProjFilePath = posix.join(subProjPath, 'file.dart'); |
| + resourceProvider.newFile(subProjFilePath, 'contents'); |
| + manager.setRoots(<String>[projPath], <String>[], <String, String>{}); |
| + // Make sure that there really are contexts for both the main project and |
| + // the subproject. |
| + Folder projFolder = resourceProvider.getFolder(projPath); |
| + ContextInfo projContextInfo = manager.getContextInfoFor(projFolder); |
| + expect(projContextInfo, isNotNull); |
| + expect(projContextInfo.folder, projFolder); |
| + ContextInfo subProjContextInfo = manager.getContextInfoFor(subProjFolder); |
| + expect(subProjContextInfo, isNotNull); |
| + expect(subProjContextInfo.folder, subProjFolder); |
| + expect(projContextInfo.context != subProjContextInfo.context, isTrue); |
| + // Check that contextsInAnalysisRoot() works. |
| + List<AnalysisContext> contexts = manager.contextsInAnalysisRoot(projFolder); |
| + expect(contexts, hasLength(2)); |
| + expect(contexts, contains(projContextInfo.context)); |
| + expect(contexts, contains(subProjContextInfo.context)); |
| + } |
| + |
| test_embedder_options() async { |
| // Create files. |
| String libPath = newFolder([projPath, LIB_NAME]); |
| @@ -167,51 +212,6 @@ analyzer: |
| expect(source.fullName, '/my/proj/sdk_ext/entry.dart'); |
| } |
| - test_analysis_options_parse_failure() async { |
| - // Create files. |
| - String libPath = newFolder([projPath, LIB_NAME]); |
| - newFile([libPath, 'main.dart']); |
| - String sdkExtPath = newFolder([projPath, 'sdk_ext']); |
| - newFile([sdkExtPath, 'entry.dart']); |
| - String sdkExtSrcPath = newFolder([projPath, 'sdk_ext', 'src']); |
| - newFile([sdkExtSrcPath, 'part.dart']); |
| - // Setup analysis options file with ignore list. |
| - newFile( |
| - [projPath, '.analysis_options'], |
| - r''' |
| -; |
| -'''); |
| - // Setup context. |
| - manager.setRoots(<String>[projPath], <String>[], <String, String>{}); |
| - |
| - // No error means success. |
| - } |
| - |
| - void test_contextsInAnalysisRoot_nestedContext() { |
| - String subProjPath = posix.join(projPath, 'subproj'); |
| - Folder subProjFolder = resourceProvider.newFolder(subProjPath); |
| - resourceProvider.newFile( |
| - posix.join(subProjPath, 'pubspec.yaml'), 'contents'); |
| - String subProjFilePath = posix.join(subProjPath, 'file.dart'); |
| - resourceProvider.newFile(subProjFilePath, 'contents'); |
| - manager.setRoots(<String>[projPath], <String>[], <String, String>{}); |
| - // Make sure that there really are contexts for both the main project and |
| - // the subproject. |
| - Folder projFolder = resourceProvider.getFolder(projPath); |
| - ContextInfo projContextInfo = manager.getContextInfoFor(projFolder); |
| - expect(projContextInfo, isNotNull); |
| - expect(projContextInfo.folder, projFolder); |
| - ContextInfo subProjContextInfo = manager.getContextInfoFor(subProjFolder); |
| - expect(subProjContextInfo, isNotNull); |
| - expect(subProjContextInfo.folder, subProjFolder); |
| - expect(projContextInfo.context != subProjContextInfo.context, isTrue); |
| - // Check that contextsInAnalysisRoot() works. |
| - List<AnalysisContext> contexts = manager.contextsInAnalysisRoot(projFolder); |
| - expect(contexts, hasLength(2)); |
| - expect(contexts, contains(projContextInfo.context)); |
| - expect(contexts, contains(subProjContextInfo.context)); |
| - } |
| - |
| test_embedder_packagespec() async { |
| // Create files. |
| String libPath = newFolder([projPath, LIB_NAME]); |
| @@ -1143,6 +1143,123 @@ test_pack:lib/'''); |
| callbacks.assertContextFiles(project, [fileA, fileB]); |
| } |
| + void test_setRoots_nested_excludedByOuter() { |
|
Brian Wilkerson
2015/11/30 22:52:22
Might be interesting to try a more deeply nested e
|
| + String project = '/project'; |
| + String projectPubspec = '$project/pubspec.yaml'; |
| + String example = '$project/example'; |
| + String examplePubspec = '$example/pubspec.yaml'; |
| + // create files |
| + resourceProvider.newFile(projectPubspec, 'name: project'); |
| + resourceProvider.newFile(examplePubspec, 'name: example'); |
| + newFile( |
| + [project, AnalysisEngine.ANALYSIS_OPTIONS_FILE], |
| + r''' |
| +analyzer: |
| + exclude: |
| + - 'example' |
| +'''); |
| + manager.setRoots( |
| + <String>[project, example], <String>[], <String, String>{}); |
| + // verify |
| + { |
| + ContextInfo rootInfo = manager.rootInfo; |
| + expect(rootInfo.children, hasLength(1)); |
| + { |
| + ContextInfo projectInfo = rootInfo.children[0]; |
| + expect(projectInfo.folder.path, project); |
| + expect(projectInfo.children, hasLength(1)); |
| + { |
| + ContextInfo exampleInfo = projectInfo.children[0]; |
| + expect(exampleInfo.folder.path, example); |
| + expect(exampleInfo.children, isEmpty); |
| + } |
| + } |
| + } |
| + expect(callbacks.currentContextPaths, hasLength(2)); |
| + expect(callbacks.currentContextPaths, unorderedEquals([project, example])); |
| + } |
| + |
| + void test_setRoots_nested_includedByOuter_innerFirst() { |
| + String project = '/project'; |
| + String projectPubspec = '$project/pubspec.yaml'; |
| + String example = '$project/example'; |
| + String examplePubspec = '$example/pubspec.yaml'; |
| + // create files |
| + resourceProvider.newFile(projectPubspec, 'name: project'); |
| + resourceProvider.newFile(examplePubspec, 'name: example'); |
| + manager.setRoots( |
| + <String>[example, project], <String>[], <String, String>{}); |
| + // verify |
| + { |
| + ContextInfo rootInfo = manager.rootInfo; |
| + expect(rootInfo.children, hasLength(1)); |
| + { |
| + ContextInfo projectInfo = rootInfo.children[0]; |
| + expect(projectInfo.folder.path, project); |
| + expect(projectInfo.children, hasLength(1)); |
| + { |
| + ContextInfo exampleInfo = projectInfo.children[0]; |
| + expect(exampleInfo.folder.path, example); |
| + expect(exampleInfo.children, isEmpty); |
| + } |
| + } |
| + } |
| + expect(callbacks.currentContextPaths, hasLength(2)); |
| + expect(callbacks.currentContextPaths, unorderedEquals([project, example])); |
| + } |
| + |
| + void test_setRoots_nested_includedByOuter_outerPubspec() { |
| + String project = '/project'; |
| + String projectPubspec = '$project/pubspec.yaml'; |
| + String example = '$project/example'; |
| + // create files |
| + resourceProvider.newFile(projectPubspec, 'name: project'); |
| + resourceProvider.newFolder(example); |
| + manager.setRoots( |
| + <String>[project, example], <String>[], <String, String>{}); |
| + // verify |
| + { |
| + ContextInfo rootInfo = manager.rootInfo; |
| + expect(rootInfo.children, hasLength(1)); |
| + { |
| + ContextInfo projectInfo = rootInfo.children[0]; |
| + expect(projectInfo.folder.path, project); |
| + expect(projectInfo.children, isEmpty); |
| + } |
| + } |
| + expect(callbacks.currentContextPaths, hasLength(1)); |
| + expect(callbacks.currentContextPaths, unorderedEquals([project])); |
| + } |
| + |
| + void test_setRoots_nested_includedByOuter_twoPubspecs() { |
| + String project = '/project'; |
| + String projectPubspec = '$project/pubspec.yaml'; |
| + String example = '$project/example'; |
| + String examplePubspec = '$example/pubspec.yaml'; |
| + // create files |
| + resourceProvider.newFile(projectPubspec, 'name: project'); |
| + resourceProvider.newFile(examplePubspec, 'name: example'); |
| + manager.setRoots( |
| + <String>[project, example], <String>[], <String, String>{}); |
| + // verify |
| + { |
| + ContextInfo rootInfo = manager.rootInfo; |
| + expect(rootInfo.children, hasLength(1)); |
| + { |
| + ContextInfo projectInfo = rootInfo.children[0]; |
| + expect(projectInfo.folder.path, project); |
| + expect(projectInfo.children, hasLength(1)); |
| + { |
| + ContextInfo exampleInfo = projectInfo.children[0]; |
| + expect(exampleInfo.folder.path, example); |
| + expect(exampleInfo.children, isEmpty); |
| + } |
| + } |
| + } |
| + expect(callbacks.currentContextPaths, hasLength(2)); |
| + expect(callbacks.currentContextPaths, unorderedEquals([project, example])); |
| + } |
| + |
| void test_setRoots_newFolderWithPackageRoot() { |
| String packageRootPath = '/package'; |
| manager.setRoots(<String>[projPath], <String>[], |