OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 analyzer.test.src.context.context_builder_test; | 5 library analyzer.test.src.context.context_builder_test; |
6 | 6 |
7 import 'dart:io' as io; | 7 import 'dart:io' as io; |
8 | 8 |
9 import 'package:analyzer/file_system/file_system.dart'; | 9 import 'package:analyzer/file_system/file_system.dart'; |
10 import 'package:analyzer/file_system/memory_file_system.dart'; | 10 import 'package:analyzer/file_system/memory_file_system.dart'; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 /** | 44 /** |
45 * The SDK manager used by the tests; | 45 * The SDK manager used by the tests; |
46 */ | 46 */ |
47 DartSdkManager sdkManager; | 47 DartSdkManager sdkManager; |
48 | 48 |
49 /** | 49 /** |
50 * The content cache used by the tests. | 50 * The content cache used by the tests. |
51 */ | 51 */ |
52 ContentCache contentCache; | 52 ContentCache contentCache; |
53 | 53 |
| 54 /** |
| 55 * The context builder to be used in the test. |
| 56 */ |
| 57 ContextBuilder builder; |
| 58 |
| 59 /** |
| 60 * The path to the default SDK, or `null` if the test has not explicitly |
| 61 * invoked [createDefaultSdk]. |
| 62 */ |
| 63 String defaultSdkPath = null; |
| 64 |
| 65 void createDefaultSdk(io.Directory tempDir) { |
| 66 defaultSdkPath = pathContext.join(tempDir.path, 'default', 'sdk'); |
| 67 String librariesFilePath = pathContext.join(defaultSdkPath, 'lib', |
| 68 '_internal', 'sdk_library_metadata', 'lib', 'libraries.dart'); |
| 69 createFile( |
| 70 librariesFilePath, |
| 71 r''' |
| 72 const Map<String, LibraryInfo> libraries = const { |
| 73 "async": const LibraryInfo("async/async.dart"), |
| 74 "core": const LibraryInfo("core/core.dart"), |
| 75 }; |
| 76 '''); |
| 77 sdkManager = |
| 78 new DartSdkManager(defaultSdkPath, false, (_) => new MockSdk()); |
| 79 builder = new ContextBuilder(resourceProvider, sdkManager, contentCache); |
| 80 } |
| 81 |
| 82 void createDirectory(String path) { |
| 83 new io.Directory(path).createSync(recursive: true); |
| 84 } |
| 85 |
| 86 void createFile(String path, String content) { |
| 87 new io.File(path) |
| 88 ..createSync(recursive: true) |
| 89 ..writeAsStringSync(content); |
| 90 } |
| 91 |
54 @override | 92 @override |
55 void setUp() { | 93 void setUp() { |
56 resourceProvider = PhysicalResourceProvider.INSTANCE; | 94 resourceProvider = PhysicalResourceProvider.INSTANCE; |
57 pathContext = resourceProvider.pathContext; | 95 pathContext = resourceProvider.pathContext; |
58 sdkManager = new DartSdkManager('', false, (_) => new MockSdk()); | 96 sdkManager = new DartSdkManager('', false, (_) => new MockSdk()); |
59 contentCache = new ContentCache(); | 97 contentCache = new ContentCache(); |
| 98 builder = new ContextBuilder(resourceProvider, sdkManager, contentCache); |
60 } | 99 } |
61 | 100 |
62 void test_createPackageMap_fromPackageDirectory_explicit() { | 101 void test_createPackageMap_fromPackageDirectory_explicit() { |
63 withTempDir((io.Directory tempDir) { | 102 withTempDir((io.Directory tempDir) { |
64 // Use a package directory that is outside the project directory. | 103 // Use a package directory that is outside the project directory. |
65 String rootPath = tempDir.path; | 104 String rootPath = tempDir.path; |
66 String projectPath = pathContext.join(rootPath, 'project'); | 105 String projectPath = pathContext.join(rootPath, 'project'); |
67 String packageDirPath = pathContext.join(rootPath, 'packages'); | 106 String packageDirPath = pathContext.join(rootPath, 'packages'); |
68 String fooName = 'foo'; | 107 String fooName = 'foo'; |
69 String fooPath = pathContext.join(packageDirPath, fooName); | 108 String fooPath = pathContext.join(packageDirPath, fooName); |
70 String barName = 'bar'; | 109 String barName = 'bar'; |
71 String barPath = pathContext.join(packageDirPath, barName); | 110 String barPath = pathContext.join(packageDirPath, barName); |
72 new io.Directory(projectPath).createSync(recursive: true); | 111 createDirectory(projectPath); |
73 new io.Directory(fooPath).createSync(recursive: true); | 112 createDirectory(fooPath); |
74 new io.Directory(barPath).createSync(recursive: true); | 113 createDirectory(barPath); |
75 | 114 |
76 ContextBuilder builder = | |
77 new ContextBuilder(resourceProvider, sdkManager, contentCache); | |
78 builder.defaultPackagesDirectoryPath = packageDirPath; | 115 builder.defaultPackagesDirectoryPath = packageDirPath; |
79 | 116 |
80 Packages packages = builder.createPackageMap(projectPath); | 117 Packages packages = builder.createPackageMap(projectPath); |
81 expect(packages, isNotNull); | 118 expect(packages, isNotNull); |
82 Map<String, Uri> map = packages.asMap(); | 119 Map<String, Uri> map = packages.asMap(); |
83 expect(map, hasLength(2)); | 120 expect(map, hasLength(2)); |
84 expect(map[fooName], new Uri.directory(fooPath)); | 121 expect(map[fooName], new Uri.directory(fooPath)); |
85 expect(map[barName], new Uri.directory(barPath)); | 122 expect(map[barName], new Uri.directory(barPath)); |
86 }); | 123 }); |
87 } | 124 } |
88 | 125 |
89 void test_createPackageMap_fromPackageDirectory_inRoot() { | 126 void test_createPackageMap_fromPackageDirectory_inRoot() { |
90 withTempDir((io.Directory tempDir) { | 127 withTempDir((io.Directory tempDir) { |
91 // Use a package directory that is inside the project directory. | 128 // Use a package directory that is inside the project directory. |
92 String projectPath = tempDir.path; | 129 String projectPath = tempDir.path; |
93 String packageDirPath = pathContext.join(projectPath, 'packages'); | 130 String packageDirPath = pathContext.join(projectPath, 'packages'); |
94 String fooName = 'foo'; | 131 String fooName = 'foo'; |
95 String fooPath = pathContext.join(packageDirPath, fooName); | 132 String fooPath = pathContext.join(packageDirPath, fooName); |
96 String barName = 'bar'; | 133 String barName = 'bar'; |
97 String barPath = pathContext.join(packageDirPath, barName); | 134 String barPath = pathContext.join(packageDirPath, barName); |
98 new io.Directory(fooPath).createSync(recursive: true); | 135 createDirectory(fooPath); |
99 new io.Directory(barPath).createSync(recursive: true); | 136 createDirectory(barPath); |
100 | 137 |
101 ContextBuilder builder = | |
102 new ContextBuilder(resourceProvider, sdkManager, contentCache); | |
103 Packages packages = builder.createPackageMap(projectPath); | 138 Packages packages = builder.createPackageMap(projectPath); |
104 expect(packages, isNotNull); | 139 expect(packages, isNotNull); |
105 Map<String, Uri> map = packages.asMap(); | 140 Map<String, Uri> map = packages.asMap(); |
106 expect(map, hasLength(2)); | 141 expect(map, hasLength(2)); |
107 expect(map[fooName], new Uri.directory(fooPath)); | 142 expect(map[fooName], new Uri.directory(fooPath)); |
108 expect(map[barName], new Uri.directory(barPath)); | 143 expect(map[barName], new Uri.directory(barPath)); |
109 }); | 144 }); |
110 } | 145 } |
111 | 146 |
112 void test_createPackageMap_fromPackageFile_explicit() { | 147 void test_createPackageMap_fromPackageFile_explicit() { |
113 withTempDir((io.Directory tempDir) { | 148 withTempDir((io.Directory tempDir) { |
114 // Use a package file that is outside the project directory's hierarchy. | 149 // Use a package file that is outside the project directory's hierarchy. |
115 String rootPath = tempDir.path; | 150 String rootPath = tempDir.path; |
116 String projectPath = pathContext.join(rootPath, 'project'); | 151 String projectPath = pathContext.join(rootPath, 'project'); |
117 String packageFilePath = pathContext.join(rootPath, 'child', '.packages'); | 152 String packageFilePath = pathContext.join(rootPath, 'child', '.packages'); |
118 new io.Directory(projectPath).createSync(recursive: true); | 153 createDirectory(projectPath); |
119 new io.File(packageFilePath) | 154 createFile( |
120 ..createSync(recursive: true) | 155 packageFilePath, |
121 ..writeAsStringSync(r''' | 156 r''' |
122 foo:/pkg/foo | 157 foo:/pkg/foo |
123 bar:/pkg/bar | 158 bar:/pkg/bar |
124 '''); | 159 '''); |
125 | 160 |
126 ContextBuilder builder = | |
127 new ContextBuilder(resourceProvider, sdkManager, contentCache); | |
128 builder.defaultPackageFilePath = packageFilePath; | 161 builder.defaultPackageFilePath = packageFilePath; |
129 Packages packages = builder.createPackageMap(projectPath); | 162 Packages packages = builder.createPackageMap(projectPath); |
130 expect(packages, isNotNull); | 163 expect(packages, isNotNull); |
131 Map<String, Uri> map = packages.asMap(); | 164 Map<String, Uri> map = packages.asMap(); |
132 expect(map, hasLength(2)); | 165 expect(map, hasLength(2)); |
133 expect(map['foo'], new Uri.directory('/pkg/foo')); | 166 expect(map['foo'], new Uri.directory('/pkg/foo')); |
134 expect(map['bar'], new Uri.directory('/pkg/bar')); | 167 expect(map['bar'], new Uri.directory('/pkg/bar')); |
135 }); | 168 }); |
136 } | 169 } |
137 | 170 |
138 void test_createPackageMap_fromPackageFile_inParentOfRoot() { | 171 void test_createPackageMap_fromPackageFile_inParentOfRoot() { |
139 withTempDir((io.Directory tempDir) { | 172 withTempDir((io.Directory tempDir) { |
140 // Use a package file that is inside the parent of the project directory. | 173 // Use a package file that is inside the parent of the project directory. |
141 String rootPath = tempDir.path; | 174 String rootPath = tempDir.path; |
142 String projectPath = pathContext.join(rootPath, 'project'); | 175 String projectPath = pathContext.join(rootPath, 'project'); |
143 String packageFilePath = pathContext.join(rootPath, '.packages'); | 176 String packageFilePath = pathContext.join(rootPath, '.packages'); |
144 new io.Directory(projectPath).createSync(recursive: true); | 177 createDirectory(projectPath); |
145 new io.File(packageFilePath) | 178 createFile( |
146 ..createSync(recursive: true) | 179 packageFilePath, |
147 ..writeAsStringSync(r''' | 180 r''' |
148 foo:/pkg/foo | 181 foo:/pkg/foo |
149 bar:/pkg/bar | 182 bar:/pkg/bar |
150 '''); | 183 '''); |
151 | 184 |
152 ContextBuilder builder = | |
153 new ContextBuilder(resourceProvider, sdkManager, contentCache); | |
154 Packages packages = builder.createPackageMap(projectPath); | 185 Packages packages = builder.createPackageMap(projectPath); |
155 expect(packages, isNotNull); | 186 expect(packages, isNotNull); |
156 Map<String, Uri> map = packages.asMap(); | 187 Map<String, Uri> map = packages.asMap(); |
157 expect(map, hasLength(2)); | 188 expect(map, hasLength(2)); |
158 expect(map['foo'], new Uri.directory('/pkg/foo')); | 189 expect(map['foo'], new Uri.directory('/pkg/foo')); |
159 expect(map['bar'], new Uri.directory('/pkg/bar')); | 190 expect(map['bar'], new Uri.directory('/pkg/bar')); |
160 }); | 191 }); |
161 } | 192 } |
162 | 193 |
163 void test_createPackageMap_fromPackageFile_inRoot() { | 194 void test_createPackageMap_fromPackageFile_inRoot() { |
164 withTempDir((io.Directory tempDir) { | 195 withTempDir((io.Directory tempDir) { |
165 // Use a package file that is inside the project directory. | 196 // Use a package file that is inside the project directory. |
166 String rootPath = tempDir.path; | 197 String rootPath = tempDir.path; |
167 String projectPath = pathContext.join(rootPath, 'project'); | 198 String projectPath = pathContext.join(rootPath, 'project'); |
168 String packageFilePath = pathContext.join(projectPath, '.packages'); | 199 String packageFilePath = pathContext.join(projectPath, '.packages'); |
169 new io.Directory(projectPath).createSync(recursive: true); | 200 createDirectory(projectPath); |
170 new io.File(packageFilePath) | 201 createFile( |
171 ..createSync(recursive: true) | 202 packageFilePath, |
172 ..writeAsStringSync(r''' | 203 r''' |
173 foo:/pkg/foo | 204 foo:/pkg/foo |
174 bar:/pkg/bar | 205 bar:/pkg/bar |
175 '''); | 206 '''); |
176 | 207 |
177 ContextBuilder builder = | |
178 new ContextBuilder(resourceProvider, sdkManager, contentCache); | |
179 Packages packages = builder.createPackageMap(projectPath); | 208 Packages packages = builder.createPackageMap(projectPath); |
180 expect(packages, isNotNull); | 209 expect(packages, isNotNull); |
181 Map<String, Uri> map = packages.asMap(); | 210 Map<String, Uri> map = packages.asMap(); |
182 expect(map, hasLength(2)); | 211 expect(map, hasLength(2)); |
183 expect(map['foo'], new Uri.directory('/pkg/foo')); | 212 expect(map['foo'], new Uri.directory('/pkg/foo')); |
184 expect(map['bar'], new Uri.directory('/pkg/bar')); | 213 expect(map['bar'], new Uri.directory('/pkg/bar')); |
185 }); | 214 }); |
186 } | 215 } |
187 | 216 |
188 void test_createPackageMap_none() { | 217 void test_createPackageMap_none() { |
189 withTempDir((io.Directory tempDir) { | 218 withTempDir((io.Directory tempDir) { |
190 ContextBuilder builder = | |
191 new ContextBuilder(resourceProvider, sdkManager, contentCache); | |
192 Packages packages = builder.createPackageMap(tempDir.path); | 219 Packages packages = builder.createPackageMap(tempDir.path); |
193 expect(packages, same(Packages.noPackages)); | 220 expect(packages, same(Packages.noPackages)); |
194 }); | 221 }); |
195 } | 222 } |
196 | 223 |
| 224 void test_createSourceFactory_noProvider_packages_embedder_extensions() { |
| 225 withTempDir((io.Directory tempDir) { |
| 226 createDefaultSdk(tempDir); |
| 227 String rootPath = tempDir.path; |
| 228 String projectPath = pathContext.join(rootPath, 'project'); |
| 229 String packageFilePath = pathContext.join(projectPath, '.packages'); |
| 230 String packageA = pathContext.join(rootPath, 'pkgs', 'a'); |
| 231 String embedderPath = pathContext.join(packageA, '_embedder.yaml'); |
| 232 String packageB = pathContext.join(rootPath, 'pkgs', 'b'); |
| 233 String extensionPath = pathContext.join(packageB, '_sdkext'); |
| 234 createFile( |
| 235 packageFilePath, |
| 236 ''' |
| 237 a:$packageA |
| 238 b:$packageB |
| 239 '''); |
| 240 String asyncPath = pathContext.join(packageA, 'sdk', 'async.dart'); |
| 241 String corePath = pathContext.join(packageA, 'sdk', 'core.dart'); |
| 242 createFile( |
| 243 embedderPath, |
| 244 ''' |
| 245 embedded_libs: |
| 246 "dart:async": ${pathContext.relative(asyncPath, from: packageA)} |
| 247 "dart:core": ${pathContext.relative(corePath, from: packageA)} |
| 248 '''); |
| 249 String fooPath = pathContext.join(packageB, 'ext', 'foo.dart'); |
| 250 createFile( |
| 251 extensionPath, |
| 252 '''{ |
| 253 "dart:foo": "${pathContext.relative(fooPath, from: packageB)}" |
| 254 }'''); |
| 255 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); |
| 256 |
| 257 SourceFactory factory = builder.createSourceFactory(projectPath, options); |
| 258 |
| 259 Source asyncSource = factory.forUri('dart:async'); |
| 260 expect(asyncSource, isNotNull); |
| 261 expect(asyncSource.fullName, asyncPath); |
| 262 |
| 263 Source fooSource = factory.forUri('dart:foo'); |
| 264 expect(fooSource, isNotNull); |
| 265 expect(fooSource.fullName, fooPath); |
| 266 |
| 267 Source packageSource = factory.forUri('package:b/b.dart'); |
| 268 expect(packageSource, isNotNull); |
| 269 expect(packageSource.fullName, '$packageB/b.dart'); |
| 270 }); |
| 271 } |
| 272 |
| 273 void test_createSourceFactory_noProvider_packages_embedder_noExtensions() { |
| 274 withTempDir((io.Directory tempDir) { |
| 275 createDefaultSdk(tempDir); |
| 276 String rootPath = tempDir.path; |
| 277 String projectPath = pathContext.join(rootPath, 'project'); |
| 278 String packageFilePath = pathContext.join(projectPath, '.packages'); |
| 279 String packageA = pathContext.join(rootPath, 'pkgs', 'a'); |
| 280 String embedderPath = pathContext.join(packageA, '_embedder.yaml'); |
| 281 String packageB = pathContext.join(rootPath, 'pkgs', 'b'); |
| 282 createFile( |
| 283 packageFilePath, |
| 284 ''' |
| 285 a:$packageA |
| 286 b:$packageB |
| 287 '''); |
| 288 String asyncPath = pathContext.join(packageA, 'sdk', 'async.dart'); |
| 289 String corePath = pathContext.join(packageA, 'sdk', 'core.dart'); |
| 290 createFile( |
| 291 embedderPath, |
| 292 ''' |
| 293 embedded_libs: |
| 294 "dart:async": ${pathContext.relative(asyncPath, from: packageA)} |
| 295 "dart:core": ${pathContext.relative(corePath, from: packageA)} |
| 296 '''); |
| 297 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); |
| 298 |
| 299 SourceFactory factory = builder.createSourceFactory(projectPath, options); |
| 300 |
| 301 Source dartSource = factory.forUri('dart:async'); |
| 302 expect(dartSource, isNotNull); |
| 303 expect(dartSource.fullName, asyncPath); |
| 304 |
| 305 Source packageSource = factory.forUri('package:b/b.dart'); |
| 306 expect(packageSource, isNotNull); |
| 307 expect(packageSource.fullName, '$packageB/b.dart'); |
| 308 }); |
| 309 } |
| 310 |
| 311 @failingTest |
| 312 void test_createSourceFactory_noProvider_packages_noEmbedder_extensions() { |
| 313 fail('Incomplete test'); |
| 314 } |
| 315 |
| 316 void test_createSourceFactory_noProvider_packages_noEmbedder_noExtensions() { |
| 317 withTempDir((io.Directory tempDir) { |
| 318 createDefaultSdk(tempDir); |
| 319 String rootPath = tempDir.path; |
| 320 String projectPath = pathContext.join(rootPath, 'project'); |
| 321 String packageFilePath = pathContext.join(projectPath, '.packages'); |
| 322 createFile( |
| 323 packageFilePath, |
| 324 r''' |
| 325 a:file:///pkgs/a |
| 326 b:file:///pkgs/b |
| 327 '''); |
| 328 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); |
| 329 |
| 330 SourceFactory factory = builder.createSourceFactory(projectPath, options); |
| 331 |
| 332 Source dartSource = factory.forUri('dart:core'); |
| 333 expect(dartSource, isNotNull); |
| 334 expect(dartSource.fullName, '$defaultSdkPath/lib/core/core.dart'); |
| 335 |
| 336 Source packageSource = factory.forUri('package:a/a.dart'); |
| 337 expect(packageSource, isNotNull); |
| 338 expect(packageSource.fullName, '/pkgs/a/a.dart'); |
| 339 }); |
| 340 } |
| 341 |
| 342 @failingTest |
| 343 void test_createSourceFactory_provider() { |
| 344 fail('Incomplete test'); |
| 345 } |
| 346 |
197 /** | 347 /** |
198 * Execute the [test] function with a temporary [directory]. The test function | 348 * Execute the [test] function with a temporary [directory]. The test function |
199 * can perform any disk operations within the directory and the directory (and | 349 * can perform any disk operations within the directory and the directory (and |
200 * its content) will be removed after the function returns. | 350 * its content) will be removed after the function returns. |
201 */ | 351 */ |
202 void withTempDir(test(io.Directory directory)) { | 352 void withTempDir(test(io.Directory directory)) { |
203 io.Directory directory = | 353 io.Directory directory = |
204 io.Directory.systemTemp.createTempSync('analyzer_'); | 354 io.Directory.systemTemp.createTempSync('analyzer_'); |
205 try { | 355 try { |
206 test(directory); | 356 test(directory); |
(...skipping 13 matching lines...) Expand all Loading... |
220 /** | 370 /** |
221 * The SDK manager used by the tests; | 371 * The SDK manager used by the tests; |
222 */ | 372 */ |
223 DartSdkManager sdkManager; | 373 DartSdkManager sdkManager; |
224 | 374 |
225 /** | 375 /** |
226 * The content cache used by the tests. | 376 * The content cache used by the tests. |
227 */ | 377 */ |
228 ContentCache contentCache; | 378 ContentCache contentCache; |
229 | 379 |
230 void fail_createSourceFactory() { | 380 /** |
231 fail('Incomplete test'); | 381 * The context builder to be used in the test. |
232 } | 382 */ |
233 | 383 ContextBuilder builder; |
234 void fail_findSdkResolver() { | |
235 fail('Incomplete test'); | |
236 } | |
237 | 384 |
238 @override | 385 @override |
239 void setUp() { | 386 void setUp() { |
240 resourceProvider = new MemoryResourceProvider(); | 387 resourceProvider = new MemoryResourceProvider(); |
241 sdkManager = new DartSdkManager('', false, (_) => new MockSdk()); | 388 sdkManager = new DartSdkManager('', false, (_) => new MockSdk()); |
242 contentCache = new ContentCache(); | 389 contentCache = new ContentCache(); |
| 390 builder = new ContextBuilder(resourceProvider, sdkManager, contentCache); |
243 } | 391 } |
244 | 392 |
245 void test_convertPackagesToMap_noPackages() { | 393 void test_convertPackagesToMap_noPackages() { |
246 ContextBuilder builder = | |
247 new ContextBuilder(resourceProvider, sdkManager, contentCache); | |
248 expect(builder.convertPackagesToMap(Packages.noPackages), isNull); | 394 expect(builder.convertPackagesToMap(Packages.noPackages), isNull); |
249 } | 395 } |
250 | 396 |
251 void test_convertPackagesToMap_null() { | 397 void test_convertPackagesToMap_null() { |
252 ContextBuilder builder = | |
253 new ContextBuilder(resourceProvider, sdkManager, contentCache); | |
254 expect(builder.convertPackagesToMap(null), isNull); | 398 expect(builder.convertPackagesToMap(null), isNull); |
255 } | 399 } |
256 | 400 |
257 void test_convertPackagesToMap_packages() { | 401 void test_convertPackagesToMap_packages() { |
258 String fooName = 'foo'; | 402 String fooName = 'foo'; |
259 String fooPath = '/pkg/foo'; | 403 String fooPath = '/pkg/foo'; |
260 Uri fooUri = new Uri.directory(fooPath); | 404 Uri fooUri = new Uri.directory(fooPath); |
261 String barName = 'bar'; | 405 String barName = 'bar'; |
262 String barPath = '/pkg/bar'; | 406 String barPath = '/pkg/bar'; |
263 Uri barUri = new Uri.directory(barPath); | 407 Uri barUri = new Uri.directory(barPath); |
264 | 408 |
265 ContextBuilder builder = | |
266 new ContextBuilder(resourceProvider, sdkManager, contentCache); | |
267 MapPackages packages = new MapPackages({fooName: fooUri, barName: barUri}); | 409 MapPackages packages = new MapPackages({fooName: fooUri, barName: barUri}); |
268 Map<String, List<Folder>> result = builder.convertPackagesToMap(packages); | 410 Map<String, List<Folder>> result = builder.convertPackagesToMap(packages); |
269 expect(result, isNotNull); | 411 expect(result, isNotNull); |
270 expect(result, hasLength(2)); | 412 expect(result, hasLength(2)); |
271 expect(result[fooName], hasLength(1)); | 413 expect(result[fooName], hasLength(1)); |
272 expect(result[fooName][0].path, fooPath); | 414 expect(result[fooName][0].path, fooPath); |
273 expect(result[barName], hasLength(1)); | 415 expect(result[barName], hasLength(1)); |
274 expect(result[barName][0].path, barPath); | 416 expect(result[barName][0].path, barPath); |
275 } | 417 } |
276 | 418 |
| 419 @failingTest |
| 420 void test_findSdkResolver() { |
| 421 fail('Incomplete test'); |
| 422 } |
| 423 |
277 void test_getOptionsFile_explicit() { | 424 void test_getOptionsFile_explicit() { |
278 String path = '/some/directory/path'; | 425 String path = '/some/directory/path'; |
279 String filePath = '/options/analysis.yaml'; | 426 String filePath = '/options/analysis.yaml'; |
280 resourceProvider.newFile(filePath, ''); | 427 resourceProvider.newFile(filePath, ''); |
281 | 428 |
282 ContextBuilder builder = | |
283 new ContextBuilder(resourceProvider, sdkManager, contentCache); | |
284 builder.defaultAnalysisOptionsFilePath = filePath; | 429 builder.defaultAnalysisOptionsFilePath = filePath; |
285 File result = builder.getOptionsFile(path); | 430 File result = builder.getOptionsFile(path); |
286 expect(result, isNotNull); | 431 expect(result, isNotNull); |
287 expect(result.path, filePath); | 432 expect(result.path, filePath); |
288 } | 433 } |
289 | 434 |
290 void test_getOptionsFile_inParentOfRoot_new() { | 435 void test_getOptionsFile_inParentOfRoot_new() { |
291 String parentPath = '/some/directory'; | 436 String parentPath = '/some/directory'; |
292 String path = '$parentPath/path'; | 437 String path = '$parentPath/path'; |
293 String filePath = | 438 String filePath = |
294 '$parentPath/${AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE}'; | 439 '$parentPath/${AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE}'; |
295 resourceProvider.newFile(filePath, ''); | 440 resourceProvider.newFile(filePath, ''); |
296 | 441 |
297 ContextBuilder builder = | |
298 new ContextBuilder(resourceProvider, sdkManager, contentCache); | |
299 File result = builder.getOptionsFile(path); | 442 File result = builder.getOptionsFile(path); |
300 expect(result, isNotNull); | 443 expect(result, isNotNull); |
301 expect(result.path, filePath); | 444 expect(result.path, filePath); |
302 } | 445 } |
303 | 446 |
304 void test_getOptionsFile_inParentOfRoot_old() { | 447 void test_getOptionsFile_inParentOfRoot_old() { |
305 String parentPath = '/some/directory'; | 448 String parentPath = '/some/directory'; |
306 String path = '$parentPath/path'; | 449 String path = '$parentPath/path'; |
307 String filePath = '$parentPath/${AnalysisEngine.ANALYSIS_OPTIONS_FILE}'; | 450 String filePath = '$parentPath/${AnalysisEngine.ANALYSIS_OPTIONS_FILE}'; |
308 resourceProvider.newFile(filePath, ''); | 451 resourceProvider.newFile(filePath, ''); |
309 | 452 |
310 ContextBuilder builder = | |
311 new ContextBuilder(resourceProvider, sdkManager, contentCache); | |
312 File result = builder.getOptionsFile(path); | 453 File result = builder.getOptionsFile(path); |
313 expect(result, isNotNull); | 454 expect(result, isNotNull); |
314 expect(result.path, filePath); | 455 expect(result.path, filePath); |
315 } | 456 } |
316 | 457 |
317 void test_getOptionsFile_inRoot_new() { | 458 void test_getOptionsFile_inRoot_new() { |
318 String path = '/some/directory/path'; | 459 String path = '/some/directory/path'; |
319 String filePath = '$path/${AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE}'; | 460 String filePath = '$path/${AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE}'; |
320 resourceProvider.newFile(filePath, ''); | 461 resourceProvider.newFile(filePath, ''); |
321 | 462 |
322 ContextBuilder builder = | |
323 new ContextBuilder(resourceProvider, sdkManager, contentCache); | |
324 File result = builder.getOptionsFile(path); | 463 File result = builder.getOptionsFile(path); |
325 expect(result, isNotNull); | 464 expect(result, isNotNull); |
326 expect(result.path, filePath); | 465 expect(result.path, filePath); |
327 } | 466 } |
328 | 467 |
329 void test_getOptionsFile_inRoot_old() { | 468 void test_getOptionsFile_inRoot_old() { |
330 String path = '/some/directory/path'; | 469 String path = '/some/directory/path'; |
331 String filePath = '$path/${AnalysisEngine.ANALYSIS_OPTIONS_FILE}'; | 470 String filePath = '$path/${AnalysisEngine.ANALYSIS_OPTIONS_FILE}'; |
332 resourceProvider.newFile(filePath, ''); | 471 resourceProvider.newFile(filePath, ''); |
333 | 472 |
334 ContextBuilder builder = | |
335 new ContextBuilder(resourceProvider, sdkManager, contentCache); | |
336 File result = builder.getOptionsFile(path); | 473 File result = builder.getOptionsFile(path); |
337 expect(result, isNotNull); | 474 expect(result, isNotNull); |
338 expect(result.path, filePath); | 475 expect(result.path, filePath); |
339 } | 476 } |
340 } | 477 } |
OLD | NEW |