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

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

Issue 1256793006: Stop optimizing uses of "pub list". (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 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) 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';
11 import 'package:analyzer/file_system/memory_file_system.dart'; 11 import 'package:analyzer/file_system/memory_file_system.dart';
12 import 'package:analyzer/instrumentation/instrumentation.dart'; 12 import 'package:analyzer/instrumentation/instrumentation.dart';
13 import 'package:analyzer/source/package_map_resolver.dart';
14 import 'package:analyzer/src/generated/engine.dart'; 13 import 'package:analyzer/src/generated/engine.dart';
15 import 'package:analyzer/src/generated/source.dart'; 14 import 'package:analyzer/src/generated/source.dart';
16 import 'package:analyzer/src/generated/source_io.dart'; 15 import 'package:analyzer/src/generated/source_io.dart';
17 import 'package:package_config/packages.dart'; 16 import 'package:package_config/packages.dart';
18 import 'package:path/path.dart'; 17 import 'package:path/path.dart';
19 import 'package:test_reflective_loader/test_reflective_loader.dart'; 18 import 'package:test_reflective_loader/test_reflective_loader.dart';
20 import 'package:unittest/unittest.dart'; 19 import 'package:unittest/unittest.dart';
21 20
22 import 'mocks.dart'; 21 import 'mocks.dart';
23 22
(...skipping 1349 matching lines...) Expand 10 before | Expand all | Expand 10 after
1373 return pumpEventQueue().then((_) { 1372 return pumpEventQueue().then((_) {
1374 _checkPackageMap(projPath, isEmpty); 1373 _checkPackageMap(projPath, isEmpty);
1375 // However, changing the package map dependency should. 1374 // However, changing the package map dependency should.
1376 resourceProvider.modifyFile(dependencyPath, 'new contents'); 1375 resourceProvider.modifyFile(dependencyPath, 'new contents');
1377 return pumpEventQueue().then((_) { 1376 return pumpEventQueue().then((_) {
1378 _checkPackageMap(projPath, equals(packageMapProvider.packageMap)); 1377 _checkPackageMap(projPath, equals(packageMapProvider.packageMap));
1379 }); 1378 });
1380 }); 1379 });
1381 } 1380 }
1382 1381
1383 test_watch_modifyPackageMapDependency_redundantly() async {
1384 // Create two dependency files
1385 String dependencyPath1 = posix.join(projPath, 'dep1');
1386 String dependencyPath2 = posix.join(projPath, 'dep2');
1387 resourceProvider.newFile(dependencyPath1, 'contents');
1388 resourceProvider.newFile(dependencyPath2, 'contents');
1389 packageMapProvider.dependencies.add(dependencyPath1);
1390 packageMapProvider.dependencies.add(dependencyPath2);
1391 // Create a dart file
1392 String dartFilePath = posix.join(projPath, 'main.dart');
1393 resourceProvider.newFile(dartFilePath, 'contents');
1394 // Verify that the created context has the expected empty package map.
1395 manager.setRoots(<String>[projPath], <String>[], <String, String>{});
1396 _checkPackageMap(projPath, isEmpty);
1397 expect(packageMapProvider.computeCount, 1);
1398 // Set up a different package map
1399 String packagePath = '/package/foo';
1400 resourceProvider.newFolder(packagePath);
1401 packageMapProvider.packageMap = {'foo': projPath};
1402 // Change both dependencies.
1403 resourceProvider.modifyFile(dependencyPath1, 'new contents');
1404 resourceProvider.modifyFile(dependencyPath2, 'new contents');
1405 // Arrange for the next call to computePackageMap to return the correct
1406 // timestamps for the dependencies.
1407 packageMapProvider.modificationTimes = <String, int>{};
1408 for (String path in [dependencyPath1, dependencyPath2]) {
1409 File resource = resourceProvider.getResource(path);
1410 packageMapProvider.modificationTimes[path] = resource.modificationStamp;
1411 }
1412 // This should cause the new package map to be picked up, by executing
1413 // computePackageMap just one additional time.
1414 await pumpEventQueue();
1415 _checkPackageMap(projPath, equals(packageMapProvider.packageMap));
1416 expect(packageMapProvider.computeCount, 2);
1417 }
1418
1419 test_watch_modifyPackagespec() { 1382 test_watch_modifyPackagespec() {
1420 String packagesPath = '$projPath/.packages'; 1383 String packagesPath = '$projPath/.packages';
1421 String filePath = '$projPath/bin/main.dart'; 1384 String filePath = '$projPath/bin/main.dart';
1422 1385
1423 resourceProvider.newFile(packagesPath, ''); 1386 resourceProvider.newFile(packagesPath, '');
1424 resourceProvider.newFile(filePath, 'library main;'); 1387 resourceProvider.newFile(filePath, 'library main;');
1425 1388
1426 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); 1389 manager.setRoots(<String>[projPath], <String>[], <String, String>{});
1427 1390
1428 Map<String, int> filePaths = callbacks.currentContextFilePaths[projPath]; 1391 Map<String, int> filePaths = callbacks.currentContextFilePaths[projPath];
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
1604 class TestUriResolver extends UriResolver { 1567 class TestUriResolver extends UriResolver {
1605 Map<Uri, Source> uriMap; 1568 Map<Uri, Source> uriMap;
1606 1569
1607 TestUriResolver(this.uriMap); 1570 TestUriResolver(this.uriMap);
1608 1571
1609 @override 1572 @override
1610 Source resolveAbsolute(Uri uri, [Uri actualUri]) { 1573 Source resolveAbsolute(Uri uri, [Uri actualUri]) {
1611 return uriMap[uri]; 1574 return uriMap[uri];
1612 } 1575 }
1613 } 1576 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698