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

Side by Side Diff: pkg/analysis_server/test/source/caching_put_package_map_provider_test.dart

Issue 1855643002: More strong mode changes to analysis_server (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Backout changes to options file Created 4 years, 8 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
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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.source.caching_pub_package_map_provider; 5 library test.source.caching_pub_package_map_provider;
6 6
7 import 'dart:convert'; 7 import 'dart:convert';
8 import 'dart:core' hide Resource; 8 import 'dart:core' hide Resource;
9 import 'dart:io' as io; 9 import 'dart:io' as io;
10 10
(...skipping 27 matching lines...) Expand all
38 Map result2 = { 38 Map result2 = {
39 'packages': {'bar': '/tmp/proj2/packages/bar'}, 39 'packages': {'bar': '/tmp/proj2/packages/bar'},
40 'input_files': ['/tmp/proj2/pubspec.yaml'] 40 'input_files': ['/tmp/proj2/pubspec.yaml']
41 }; 41 };
42 42
43 Folder newProj(Map result) { 43 Folder newProj(Map result) {
44 Map packages = result['packages']; 44 Map packages = result['packages'];
45 packages.forEach((String name, String path) { 45 packages.forEach((String name, String path) {
46 resProvider.newFolder(path); 46 resProvider.newFolder(path);
47 }); 47 });
48 List<String> inputFiles = result['input_files']; 48 List<String> inputFiles = result['input_files'] as List<String>;
49 for (String path in inputFiles) { 49 for (String path in inputFiles) {
50 resProvider.newFile(path, ''); 50 resProvider.newFile(path, '');
51 } 51 }
52 Folder projectFolder = resProvider.getResource(inputFiles[0]).parent; 52 Folder projectFolder = resProvider.getResource(inputFiles[0]).parent;
53 resProvider.newFile(projectFolder.path + '/pubspec.lock', ''); 53 resProvider.newFile(projectFolder.path + '/pubspec.lock', '');
54 return projectFolder; 54 return projectFolder;
55 } 55 }
56 56
57 int mockWriteFile(File cacheFile, String content) { 57 int mockWriteFile(File cacheFile, String content) {
58 if (writeFileException) { 58 if (writeFileException) {
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 PackageMapInfo info = pkgProvider.computePackageMap(folder1); 275 PackageMapInfo info = pkgProvider.computePackageMap(folder1);
276 expect(mockRunner.runCount, 2); 276 expect(mockRunner.runCount, 2);
277 _assertInfo(info, result1); 277 _assertInfo(info, result1);
278 }); 278 });
279 }); 279 });
280 }); 280 });
281 } 281 }
282 282
283 _assertError(PackageMapInfo info, Map expected) { 283 _assertError(PackageMapInfo info, Map expected) {
284 expect(info.packageMap, isNull); 284 expect(info.packageMap, isNull);
285 List<String> expectedFiles = expected['input_files']; 285 List<String> expectedFiles = expected['input_files'] as List<String>;
286 expect(info.dependencies, hasLength(expectedFiles.length)); 286 expect(info.dependencies, hasLength(expectedFiles.length));
287 for (String path in expectedFiles) { 287 for (String path in expectedFiles) {
288 expect(info.dependencies, contains(path)); 288 expect(info.dependencies, contains(path));
289 } 289 }
290 } 290 }
291 291
292 _assertInfo(PackageMapInfo info, Map expected) { 292 _assertInfo(PackageMapInfo info, Map expected) {
293 Map<String, String> expectedPackages = expected['packages']; 293 Map<String, String> expectedPackages =
294 expected['packages'] as Map<String, String>;
294 expect(info.packageMap, hasLength(expectedPackages.length)); 295 expect(info.packageMap, hasLength(expectedPackages.length));
295 for (String key in expectedPackages.keys) { 296 for (String key in expectedPackages.keys) {
296 List<Folder> packageList = info.packageMap[key]; 297 List<Folder> packageList = info.packageMap[key];
297 expect(packageList, hasLength(1)); 298 expect(packageList, hasLength(1));
298 expect(packageList[0].path, expectedPackages[key]); 299 expect(packageList[0].path, expectedPackages[key]);
299 } 300 }
300 List<String> expectedFiles = expected['input_files']; 301 List<String> expectedFiles = expected['input_files'] as List<String>;
301 expect(info.dependencies, hasLength(expectedFiles.length)); 302 expect(info.dependencies, hasLength(expectedFiles.length));
302 for (String path in expectedFiles) { 303 for (String path in expectedFiles) {
303 expect(info.dependencies, contains(path)); 304 expect(info.dependencies, contains(path));
304 } 305 }
305 } 306 }
306 307
307 typedef String MockResultFunction(); 308 typedef String MockResultFunction();
308 309
309 /** 310 /**
310 * Mock for simulating and tracking execution of pub list 311 * Mock for simulating and tracking execution of pub list
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 provider.newFolder(path); 394 provider.newFolder(path);
394 } 395 }
395 int fileCount = _filePaths.length; 396 int fileCount = _filePaths.length;
396 for (int fileIndex = 0; fileIndex < fileCount; ++fileIndex) { 397 for (int fileIndex = 0; fileIndex < fileCount; ++fileIndex) {
397 String path = _filePaths[fileIndex]; 398 String path = _filePaths[fileIndex];
398 TimestampedData content = _fileContents[fileIndex]; 399 TimestampedData content = _fileContents[fileIndex];
399 provider.newFile(path, content.data, content.modificationTime); 400 provider.newFile(path, content.data, content.modificationTime);
400 } 401 }
401 } 402 }
402 } 403 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/services/linter/linter_test.dart ('k') | pkg/analyzer/lib/src/codegen/tools.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698