OLD | NEW |
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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); | 224 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); |
225 // Verify that analysis options was parsed and the ignore patterns applied. | 225 // Verify that analysis options was parsed and the ignore patterns applied. |
226 Map<String, int> fileTimestamps = | 226 Map<String, int> fileTimestamps = |
227 callbacks.currentContextFilePaths[projPath]; | 227 callbacks.currentContextFilePaths[projPath]; |
228 expect(fileTimestamps, isNotEmpty); | 228 expect(fileTimestamps, isNotEmpty); |
229 List<String> files = fileTimestamps.keys.toList(); | 229 List<String> files = fileTimestamps.keys.toList(); |
230 expect(files.length, equals(1)); | 230 expect(files.length, equals(1)); |
231 expect(files[0], equals('/my/proj/lib/main.dart')); | 231 expect(files[0], equals('/my/proj/lib/main.dart')); |
232 } | 232 } |
233 | 233 |
| 234 test_path_filter_child_contexts_option() async { |
| 235 // Create files. |
| 236 String libPath = newFolder([projPath, LIB_NAME]); |
| 237 newFile([libPath, 'main.dart']); |
| 238 newFile([libPath, 'pubspec.yaml'], r''' |
| 239 name: foobar |
| 240 '''); |
| 241 String otherLibPath = newFolder([projPath, 'other_lib']); |
| 242 newFile([otherLibPath, 'entry.dart']); |
| 243 newFile([otherLibPath, 'pubspec.yaml'], r''' |
| 244 name: other_lib |
| 245 '''); |
| 246 // Setup analysis options file with ignore list that ignores the 'other_lib' |
| 247 // directory by name. |
| 248 newFile([projPath, '.analysis_options'], r''' |
| 249 analyzer: |
| 250 exclude: |
| 251 - 'other_lib' |
| 252 '''); |
| 253 // Setup context. |
| 254 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); |
| 255 // Verify that the context in other_lib wasn't created and that the |
| 256 // context in lib was created. |
| 257 var contexts = manager.contextsInAnalysisRoot( |
| 258 resourceProvider.newFolder(projPath)); |
| 259 expect(contexts.length, 2); |
| 260 expect(contexts[0].name, equals('/my/proj')); |
| 261 expect(contexts[1].name, equals('/my/proj/lib')); |
| 262 } |
| 263 |
| 264 test_path_filter_wildcard_child_contexts_option() async { |
| 265 // Create files. |
| 266 String libPath = newFolder([projPath, LIB_NAME]); |
| 267 newFile([libPath, 'main.dart']); |
| 268 newFile([libPath, 'pubspec.yaml'], r''' |
| 269 name: foobar |
| 270 '''); |
| 271 String otherLibPath = newFolder([projPath, 'other_lib']); |
| 272 newFile([otherLibPath, 'entry.dart']); |
| 273 newFile([otherLibPath, 'pubspec.yaml'], r''' |
| 274 name: other_lib |
| 275 '''); |
| 276 // Setup analysis options file with ignore list that ignores 'other_lib' |
| 277 // and all immediate children. |
| 278 newFile([projPath, '.analysis_options'], r''' |
| 279 analyzer: |
| 280 exclude: |
| 281 - 'other_lib/*' |
| 282 '''); |
| 283 // Setup context. |
| 284 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); |
| 285 // Verify that the context in other_lib wasn't created and that the |
| 286 // context in lib was created. |
| 287 var contexts = manager.contextsInAnalysisRoot( |
| 288 resourceProvider.newFolder(projPath)); |
| 289 expect(contexts.length, 2); |
| 290 expect(contexts[0].name, equals('/my/proj')); |
| 291 expect(contexts[1].name, equals('/my/proj/lib')); |
| 292 } |
| 293 |
| 294 test_path_filter_recursive_wildcard_child_contexts_option() async { |
| 295 // Create files. |
| 296 String libPath = newFolder([projPath, LIB_NAME]); |
| 297 newFile([libPath, 'main.dart']); |
| 298 newFile([libPath, 'pubspec.yaml'], r''' |
| 299 name: foobar |
| 300 '''); |
| 301 String otherLibPath = newFolder([projPath, 'other_lib']); |
| 302 newFile([otherLibPath, 'entry.dart']); |
| 303 newFile([otherLibPath, 'pubspec.yaml'], r''' |
| 304 name: other_lib |
| 305 '''); |
| 306 // Setup analysis options file with ignore list that ignores 'other_lib' |
| 307 // and all descendants. |
| 308 newFile([projPath, '.analysis_options'], r''' |
| 309 analyzer: |
| 310 exclude: |
| 311 - 'other_lib/**' |
| 312 '''); |
| 313 // Setup context. |
| 314 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); |
| 315 // Verify that the context in other_lib wasn't created and that the |
| 316 // context in lib was created. |
| 317 var contexts = manager.contextsInAnalysisRoot( |
| 318 resourceProvider.newFolder(projPath)); |
| 319 expect(contexts.length, 2); |
| 320 expect(contexts[0].name, equals('/my/proj')); |
| 321 expect(contexts[1].name, equals('/my/proj/lib')); |
| 322 } |
| 323 |
234 test_refresh_folder_with_packagespec() { | 324 test_refresh_folder_with_packagespec() { |
235 // create a context with a .packages file | 325 // create a context with a .packages file |
236 String packagespecFile = posix.join(projPath, '.packages'); | 326 String packagespecFile = posix.join(projPath, '.packages'); |
237 resourceProvider.newFile(packagespecFile, ''); | 327 resourceProvider.newFile(packagespecFile, ''); |
238 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); | 328 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); |
239 return pumpEventQueue().then((_) { | 329 return pumpEventQueue().then((_) { |
240 expect(callbacks.currentContextPaths.toList(), [projPath]); | 330 expect(callbacks.currentContextPaths.toList(), [projPath]); |
241 callbacks.now++; | 331 callbacks.now++; |
242 manager.refresh(null); | 332 manager.refresh(null); |
243 return pumpEventQueue().then((_) { | 333 return pumpEventQueue().then((_) { |
(...skipping 1290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1534 class TestUriResolver extends UriResolver { | 1624 class TestUriResolver extends UriResolver { |
1535 Map<Uri, Source> uriMap; | 1625 Map<Uri, Source> uriMap; |
1536 | 1626 |
1537 TestUriResolver(this.uriMap); | 1627 TestUriResolver(this.uriMap); |
1538 | 1628 |
1539 @override | 1629 @override |
1540 Source resolveAbsolute(Uri uri, [Uri actualUri]) { | 1630 Source resolveAbsolute(Uri uri, [Uri actualUri]) { |
1541 return uriMap[uri]; | 1631 return uriMap[uri]; |
1542 } | 1632 } |
1543 } | 1633 } |
OLD | NEW |