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

Unified Diff: pkg/analysis_server/test/context_manager_test.dart

Issue 1487903002: Issue 25048. Ignore inner analysis roots which are already managed by outer roots. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Additional test. Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analysis_server/lib/src/context_manager.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>[],
« no previous file with comments | « pkg/analysis_server/lib/src/context_manager.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698