| 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..9f5136860a7b0049cbc7ea0484fd13099adc23df 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,158 @@ test_pack:lib/''');
|
| callbacks.assertContextFiles(project, [fileA, fileB]);
|
| }
|
|
|
| + void test_setRoots_nested_excludedByOuter() {
|
| + 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_excludedByOuter_deep() {
|
| + String a = '/a';
|
| + String c = '$a/b/c';
|
| + String aPubspec = '$a/pubspec.yaml';
|
| + String cPubspec = '$c/pubspec.yaml';
|
| + // create files
|
| + resourceProvider.newFile(aPubspec, 'name: aaa');
|
| + resourceProvider.newFile(cPubspec, 'name: ccc');
|
| + newFile(
|
| + [a, AnalysisEngine.ANALYSIS_OPTIONS_FILE],
|
| + r'''
|
| +analyzer:
|
| + exclude:
|
| + - 'b**'
|
| +''');
|
| + manager.setRoots(<String>[a, c], <String>[], <String, String>{});
|
| + // verify
|
| + {
|
| + ContextInfo rootInfo = manager.rootInfo;
|
| + expect(rootInfo.children, hasLength(1));
|
| + {
|
| + ContextInfo aInfo = rootInfo.children[0];
|
| + expect(aInfo.folder.path, a);
|
| + expect(aInfo.children, hasLength(1));
|
| + {
|
| + ContextInfo cInfo = aInfo.children[0];
|
| + expect(cInfo.folder.path, c);
|
| + expect(cInfo.children, isEmpty);
|
| + }
|
| + }
|
| + }
|
| + expect(callbacks.currentContextPaths, hasLength(2));
|
| + expect(callbacks.currentContextPaths, unorderedEquals([a, c]));
|
| + }
|
| +
|
| + 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>[],
|
|
|