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:analysis_server/src/source/optimizing_pub_package_map_provider.d
art'; | 10 import 'package:analysis_server/src/source/optimizing_pub_package_map_provider.d
art'; |
11 import 'package:analysis_server/uri/resolver_provider.dart'; | 11 import 'package:analysis_server/uri/resolver_provider.dart'; |
12 import 'package:analyzer/file_system/file_system.dart'; | 12 import 'package:analyzer/file_system/file_system.dart'; |
13 import 'package:analyzer/file_system/memory_file_system.dart'; | 13 import 'package:analyzer/file_system/memory_file_system.dart'; |
14 import 'package:analyzer/instrumentation/instrumentation.dart'; | 14 import 'package:analyzer/instrumentation/instrumentation.dart'; |
15 import 'package:analyzer/source/package_map_resolver.dart'; | 15 import 'package:analyzer/source/package_map_resolver.dart'; |
16 import 'package:analyzer/source/path_filter.dart'; | |
17 import 'package:analyzer/src/generated/engine.dart'; | 16 import 'package:analyzer/src/generated/engine.dart'; |
18 import 'package:analyzer/src/generated/source.dart'; | 17 import 'package:analyzer/src/generated/source.dart'; |
19 import 'package:analyzer/src/generated/source_io.dart'; | 18 import 'package:analyzer/src/generated/source_io.dart'; |
20 import 'package:path/path.dart'; | 19 import 'package:path/path.dart'; |
21 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 20 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
22 import 'package:unittest/unittest.dart'; | 21 import 'package:unittest/unittest.dart'; |
23 | 22 |
24 import 'mocks.dart'; | 23 import 'mocks.dart'; |
25 | 24 |
26 main() { | 25 main() { |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 // Pump event loop so new files are discovered and added to context. | 190 // Pump event loop so new files are discovered and added to context. |
192 await pumpEventQueue(); | 191 await pumpEventQueue(); |
193 // Verify that ignored files were ignored. | 192 // Verify that ignored files were ignored. |
194 Map<String, int> fileTimestamps = manager.currentContextFilePaths[projPath]; | 193 Map<String, int> fileTimestamps = manager.currentContextFilePaths[projPath]; |
195 expect(fileTimestamps, isNotEmpty); | 194 expect(fileTimestamps, isNotEmpty); |
196 List<String> files = fileTimestamps.keys.toList(); | 195 List<String> files = fileTimestamps.keys.toList(); |
197 expect(files.length, equals(1)); | 196 expect(files.length, equals(1)); |
198 expect(files[0], equals('/my/proj/lib/main.dart')); | 197 expect(files[0], equals('/my/proj/lib/main.dart')); |
199 } | 198 } |
200 | 199 |
| 200 test_path_filter_analysis_option() async { |
| 201 // Create files. |
| 202 String libPath = newFolder([projPath, LIB_NAME]); |
| 203 newFile([libPath, 'main.dart']); |
| 204 newFile([libPath, 'nope.dart']); |
| 205 String sdkExtPath = newFolder([projPath, 'sdk_ext']); |
| 206 newFile([sdkExtPath, 'entry.dart']); |
| 207 String sdkExtSrcPath = newFolder([projPath, 'sdk_ext', 'src']); |
| 208 newFile([sdkExtSrcPath, 'part.dart']); |
| 209 // Setup analysis options file with ignore list. |
| 210 newFile([projPath, '.analysis_options'], r''' |
| 211 analyzer: |
| 212 exclude: |
| 213 - lib/nope.dart |
| 214 - 'sdk_ext/**' |
| 215 '''); |
| 216 // Setup context. |
| 217 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); |
| 218 // Verify that analysis options was parsed and the ignore patterns applied. |
| 219 Map<String, int> fileTimestamps = manager.currentContextFilePaths[projPath]; |
| 220 expect(fileTimestamps, isNotEmpty); |
| 221 List<String> files = fileTimestamps.keys.toList(); |
| 222 expect(files.length, equals(1)); |
| 223 expect(files[0], equals('/my/proj/lib/main.dart')); |
| 224 } |
| 225 |
201 test_refresh_oneContext() { | 226 test_refresh_oneContext() { |
202 // create two contexts with pubspec.yaml files | 227 // create two contexts with pubspec.yaml files |
203 String pubspecPath = posix.join(projPath, 'pubspec.yaml'); | 228 String pubspecPath = posix.join(projPath, 'pubspec.yaml'); |
204 resourceProvider.newFile(pubspecPath, 'pubspec1'); | 229 resourceProvider.newFile(pubspecPath, 'pubspec1'); |
205 | 230 |
206 String proj2Path = '/my/proj2'; | 231 String proj2Path = '/my/proj2'; |
207 resourceProvider.newFolder(proj2Path); | 232 resourceProvider.newFolder(proj2Path); |
208 String pubspec2Path = posix.join(proj2Path, 'pubspec.yaml'); | 233 String pubspec2Path = posix.join(proj2Path, 'pubspec.yaml'); |
209 resourceProvider.newFile(pubspec2Path, 'pubspec2'); | 234 resourceProvider.newFile(pubspec2Path, 'pubspec2'); |
210 | 235 |
(...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1142 class TestUriResolver extends UriResolver { | 1167 class TestUriResolver extends UriResolver { |
1143 Map<Uri, Source> uriMap; | 1168 Map<Uri, Source> uriMap; |
1144 | 1169 |
1145 TestUriResolver(this.uriMap); | 1170 TestUriResolver(this.uriMap); |
1146 | 1171 |
1147 @override | 1172 @override |
1148 Source resolveAbsolute(Uri uri) { | 1173 Source resolveAbsolute(Uri uri) { |
1149 return uriMap[uri]; | 1174 return uriMap[uri]; |
1150 } | 1175 } |
1151 } | 1176 } |
OLD | NEW |