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

Side by Side Diff: pkg/analysis_server/test/context_manager_test.dart

Issue 1372173004: Ignore added files in hidden directories. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 months 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 unified diff | Download patch
« no previous file with comments | « pkg/analysis_server/lib/src/context_manager.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 test.context.directory.manager; 5 library test.context.directory.manager;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analysis_server/src/context_manager.dart'; 9 import 'package:analysis_server/src/context_manager.dart';
10 import 'package:analyzer/file_system/file_system.dart'; 10 import 'package:analyzer/file_system/file_system.dart';
(...skipping 936 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 947
948 List<AnalysisContext> contextsInAnalysisRoot = 948 List<AnalysisContext> contextsInAnalysisRoot =
949 manager.contextsInAnalysisRoot(resourceProvider.newFolder(projPath)); 949 manager.contextsInAnalysisRoot(resourceProvider.newFolder(projPath));
950 expect(contextsInAnalysisRoot, hasLength(1)); 950 expect(contextsInAnalysisRoot, hasLength(1));
951 AnalysisContext context = contextsInAnalysisRoot[0]; 951 AnalysisContext context = contextsInAnalysisRoot[0];
952 expect(context, isNotNull); 952 expect(context, isNotNull);
953 Source result = context.sourceFactory.forUri2(uri); 953 Source result = context.sourceFactory.forUri2(uri);
954 expect(result, same(source)); 954 expect(result, same(source));
955 } 955 }
956 956
957 void test_setRoots_pathContainsDotFile() {
958 // If the path to a file (relative to the context root) contains a folder
959 // whose name begins with '.', then the file is ignored.
960 String project = '/project';
961 String fileA = '$project/foo.dart';
962 String fileB = '$project/.pub/bar.dart';
963 resourceProvider.newFile(fileA, '');
964 resourceProvider.newFile(fileB, '');
965 manager.setRoots(<String>[project], <String>[], <String, String>{});
966 callbacks.assertContextPaths([project]);
967 callbacks.assertContextFiles(project, [fileA]);
968 }
969
957 void test_setRoots_removeFolderWithoutPubspec() { 970 void test_setRoots_removeFolderWithoutPubspec() {
958 packageMapProvider.packageMap = null; 971 packageMapProvider.packageMap = null;
959 // add one root - there is a context 972 // add one root - there is a context
960 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); 973 manager.setRoots(<String>[projPath], <String>[], <String, String>{});
961 expect(callbacks.currentContextPaths, hasLength(1)); 974 expect(callbacks.currentContextPaths, hasLength(1));
962 // set empty roots - no contexts 975 // set empty roots - no contexts
963 manager.setRoots(<String>[], <String>[], <String, String>{}); 976 manager.setRoots(<String>[], <String>[], <String, String>{});
964 expect(callbacks.currentContextPaths, hasLength(0)); 977 expect(callbacks.currentContextPaths, hasLength(0));
965 expect(callbacks.currentContextFilePaths, hasLength(0)); 978 expect(callbacks.currentContextFilePaths, hasLength(0));
966 } 979 }
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1070 }; 1083 };
1071 List<String> includedPaths = <String>[projPath]; 1084 List<String> includedPaths = <String>[projPath];
1072 List<String> excludedPaths = <String>[]; 1085 List<String> excludedPaths = <String>[];
1073 manager.setRoots(includedPaths, excludedPaths, 1086 manager.setRoots(includedPaths, excludedPaths,
1074 <String, String>{projPath: packageRootPath}); 1087 <String, String>{projPath: packageRootPath});
1075 _checkPackageRoot(projPath, equals(packageRootPath)); 1088 _checkPackageRoot(projPath, equals(packageRootPath));
1076 manager.setRoots(includedPaths, excludedPaths, <String, String>{}); 1089 manager.setRoots(includedPaths, excludedPaths, <String, String>{});
1077 _checkPackageMap(projPath, equals(packageMapProvider.packageMap)); 1090 _checkPackageMap(projPath, equals(packageMapProvider.packageMap));
1078 } 1091 }
1079 1092
1093 void test_setRoots_rootPathContainsDotFile() {
1094 // If the path to the context root itself contains a folder whose name
1095 // begins with '.', then that is not sufficient to cause any files in the
1096 // context to be ignored.
1097 String project = '/.pub/project';
1098 String fileA = '$project/foo.dart';
1099 resourceProvider.newFile(fileA, '');
1100 manager.setRoots(<String>[project], <String>[], <String, String>{});
1101 callbacks.assertContextPaths([project]);
1102 callbacks.assertContextFiles(project, [fileA]);
1103 }
1104
1080 test_watch_addDummyLink() { 1105 test_watch_addDummyLink() {
1081 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); 1106 manager.setRoots(<String>[projPath], <String>[], <String, String>{});
1082 // empty folder initially 1107 // empty folder initially
1083 Map<String, int> filePaths = callbacks.currentContextFilePaths[projPath]; 1108 Map<String, int> filePaths = callbacks.currentContextFilePaths[projPath];
1084 expect(filePaths, isEmpty); 1109 expect(filePaths, isEmpty);
1085 // add link 1110 // add link
1086 String filePath = posix.join(projPath, 'foo.dart'); 1111 String filePath = posix.join(projPath, 'foo.dart');
1087 resourceProvider.newDummyLink(filePath); 1112 resourceProvider.newDummyLink(filePath);
1088 // the link was ignored 1113 // the link was ignored
1089 return pumpEventQueue().then((_) { 1114 return pumpEventQueue().then((_) {
(...skipping 30 matching lines...) Expand all
1120 callbacks.assertContextPaths([project]); 1145 callbacks.assertContextPaths([project]);
1121 callbacks.assertContextFiles(project, [fileA]); 1146 callbacks.assertContextFiles(project, [fileA]);
1122 // add a file, ignored as excluded 1147 // add a file, ignored as excluded
1123 resourceProvider.newFile(fileB, 'library b;'); 1148 resourceProvider.newFile(fileB, 'library b;');
1124 return pumpEventQueue().then((_) { 1149 return pumpEventQueue().then((_) {
1125 callbacks.assertContextPaths([project]); 1150 callbacks.assertContextPaths([project]);
1126 callbacks.assertContextFiles(project, [fileA]); 1151 callbacks.assertContextFiles(project, [fileA]);
1127 }); 1152 });
1128 } 1153 }
1129 1154
1155 test_watch_addFile_pathContainsDotFile() async {
1156 // If a file is added and the path to it (relative to the context root)
1157 // contains a folder whose name begins with '.', then the file is ignored.
1158 String project = '/project';
1159 String fileA = '$project/foo.dart';
1160 String fileB = '$project/.pub/bar.dart';
1161 resourceProvider.newFile(fileA, '');
1162 manager.setRoots(<String>[project], <String>[], <String, String>{});
1163 callbacks.assertContextPaths([project]);
1164 callbacks.assertContextFiles(project, [fileA]);
1165 resourceProvider.newFile(fileB, '');
1166 await pumpEventQueue();
1167 callbacks.assertContextPaths([project]);
1168 callbacks.assertContextFiles(project, [fileA]);
1169 }
1170
1171 test_watch_addFile_rootPathContainsDotFile() async {
1172 // If a file is added and the path to the context contains a folder whose
1173 // name begins with '.', then the file is not ignored.
1174 String project = '/.pub/project';
1175 String fileA = '$project/foo.dart';
1176 String fileB = '$project/bar/baz.dart';
1177 resourceProvider.newFile(fileA, '');
1178 manager.setRoots(<String>[project], <String>[], <String, String>{});
1179 callbacks.assertContextPaths([project]);
1180 callbacks.assertContextFiles(project, [fileA]);
1181 resourceProvider.newFile(fileB, '');
1182 await pumpEventQueue();
1183 callbacks.assertContextPaths([project]);
1184 callbacks.assertContextFiles(project, [fileA, fileB]);
1185 }
1186
1130 test_watch_addFileInSubfolder() { 1187 test_watch_addFileInSubfolder() {
1131 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); 1188 manager.setRoots(<String>[projPath], <String>[], <String, String>{});
1132 // empty folder initially 1189 // empty folder initially
1133 Map<String, int> filePaths = callbacks.currentContextFilePaths[projPath]; 1190 Map<String, int> filePaths = callbacks.currentContextFilePaths[projPath];
1134 expect(filePaths, hasLength(0)); 1191 expect(filePaths, hasLength(0));
1135 // add file in subfolder 1192 // add file in subfolder
1136 String filePath = posix.join(projPath, 'foo', 'bar.dart'); 1193 String filePath = posix.join(projPath, 'foo', 'bar.dart');
1137 resourceProvider.newFile(filePath, 'contents'); 1194 resourceProvider.newFile(filePath, 'contents');
1138 // the file was added 1195 // the file was added
1139 return pumpEventQueue().then((_) { 1196 return pumpEventQueue().then((_) {
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
1738 class TestUriResolver extends UriResolver { 1795 class TestUriResolver extends UriResolver {
1739 Map<Uri, Source> uriMap; 1796 Map<Uri, Source> uriMap;
1740 1797
1741 TestUriResolver(this.uriMap); 1798 TestUriResolver(this.uriMap);
1742 1799
1743 @override 1800 @override
1744 Source resolveAbsolute(Uri uri, [Uri actualUri]) { 1801 Source resolveAbsolute(Uri uri, [Uri actualUri]) {
1745 return uriMap[uri]; 1802 return uriMap[uri];
1746 } 1803 }
1747 } 1804 }
OLDNEW
« 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