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

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

Issue 1403983002: AS strong-mode .analysis_options awareness. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: check-fix Created 5 years, 2 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
« no previous file with comments | « pkg/analysis_server/lib/src/context_manager.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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';
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); 362 manager.setRoots(<String>[projPath], <String>[], <String, String>{});
363 // Verify that the context in other_lib wasn't created and that the 363 // Verify that the context in other_lib wasn't created and that the
364 // context in lib was created. 364 // context in lib was created.
365 var contexts = 365 var contexts =
366 manager.contextsInAnalysisRoot(resourceProvider.newFolder(projPath)); 366 manager.contextsInAnalysisRoot(resourceProvider.newFolder(projPath));
367 expect(contexts.length, 2); 367 expect(contexts.length, 2);
368 expect(contexts[0].name, equals('/my/proj')); 368 expect(contexts[0].name, equals('/my/proj'));
369 expect(contexts[1].name, equals('/my/proj/lib')); 369 expect(contexts[1].name, equals('/my/proj/lib'));
370 } 370 }
371 371
372 // TODO(paulberry): This test only tests PackagesFileDisposition.
373 // Once http://dartbug.com/23909 is fixed, add a test for sdk extensions
374 // and PackageMapDisposition.
375 test_refresh_folder_with_packagespec() { 372 test_refresh_folder_with_packagespec() {
376 // create a context with a .packages file 373 // create a context with a .packages file
377 String packagespecFile = posix.join(projPath, '.packages'); 374 String packagespecFile = posix.join(projPath, '.packages');
378 resourceProvider.newFile(packagespecFile, ''); 375 resourceProvider.newFile(packagespecFile, '');
379 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); 376 manager.setRoots(<String>[projPath], <String>[], <String, String>{});
380 return pumpEventQueue().then((_) { 377 return pumpEventQueue().then((_) {
381 expect(callbacks.currentContextPaths.toList(), [projPath]); 378 expect(callbacks.currentContextPaths.toList(), [projPath]);
382 callbacks.now++; 379 callbacks.now++;
383 manager.refresh(null); 380 manager.refresh(null);
384 return pumpEventQueue().then((_) { 381 return pumpEventQueue().then((_) {
385 expect(callbacks.currentContextPaths.toList(), [projPath]); 382 expect(callbacks.currentContextPaths.toList(), [projPath]);
386 expect(callbacks.currentContextTimestamps[projPath], callbacks.now); 383 expect(callbacks.currentContextTimestamps[projPath], callbacks.now);
387 }); 384 });
388 }); 385 });
389 } 386 }
390 387
388 // TODO(paulberry): This test only tests PackagesFileDisposition.
389 // Once http://dartbug.com/23909 is fixed, add a test for sdk extensions
390 // and PackageMapDisposition.
391 test_refresh_folder_with_packagespec_subfolders() { 391 test_refresh_folder_with_packagespec_subfolders() {
392 // Create a folder with no .packages file, containing two subfolders with 392 // Create a folder with no .packages file, containing two subfolders with
393 // .packages files. 393 // .packages files.
394 String subdir1Path = posix.join(projPath, 'subdir1'); 394 String subdir1Path = posix.join(projPath, 'subdir1');
395 String subdir2Path = posix.join(projPath, 'subdir2'); 395 String subdir2Path = posix.join(projPath, 'subdir2');
396 String packagespec1Path = posix.join(subdir1Path, '.packages'); 396 String packagespec1Path = posix.join(subdir1Path, '.packages');
397 String packagespec2Path = posix.join(subdir2Path, '.packages'); 397 String packagespec2Path = posix.join(subdir2Path, '.packages');
398 resourceProvider.newFile(packagespec1Path, ''); 398 resourceProvider.newFile(packagespec1Path, '');
399 resourceProvider.newFile(packagespec2Path, ''); 399 resourceProvider.newFile(packagespec2Path, '');
400 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); 400 manager.setRoots(<String>[projPath], <String>[], <String, String>{});
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
1100 // begins with '.', then that is not sufficient to cause any files in the 1100 // begins with '.', then that is not sufficient to cause any files in the
1101 // context to be ignored. 1101 // context to be ignored.
1102 String project = '/.pub/project'; 1102 String project = '/.pub/project';
1103 String fileA = '$project/foo.dart'; 1103 String fileA = '$project/foo.dart';
1104 resourceProvider.newFile(fileA, ''); 1104 resourceProvider.newFile(fileA, '');
1105 manager.setRoots(<String>[project], <String>[], <String, String>{}); 1105 manager.setRoots(<String>[project], <String>[], <String, String>{});
1106 callbacks.assertContextPaths([project]); 1106 callbacks.assertContextPaths([project]);
1107 callbacks.assertContextFiles(project, [fileA]); 1107 callbacks.assertContextFiles(project, [fileA]);
1108 } 1108 }
1109 1109
1110 test_strong_mode_analysis_option() async {
1111 // Create files.
1112 newFile(
1113 [projPath, '.analysis_options'],
1114 r'''
1115 analyzer:
1116 strong-mode: true
1117 ''');
1118 String libPath = newFolder([projPath, LIB_NAME]);
1119 newFile([libPath, 'main.dart']);
1120 // Setup context.
1121 manager.setRoots(<String>[projPath], <String>[], <String, String>{});
1122 // Verify that analysis options was parsed and strong-mode set.
1123 Map<String, int> fileTimestamps =
1124 callbacks.currentContextFilePaths[projPath];
1125 expect(fileTimestamps, isNotEmpty);
1126 expect(callbacks.currentContext.analysisOptions.strongMode, true);
1127 }
1128
1110 test_watch_addDummyLink() { 1129 test_watch_addDummyLink() {
1111 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); 1130 manager.setRoots(<String>[projPath], <String>[], <String, String>{});
1112 // empty folder initially 1131 // empty folder initially
1113 Map<String, int> filePaths = callbacks.currentContextFilePaths[projPath]; 1132 Map<String, int> filePaths = callbacks.currentContextFilePaths[projPath];
1114 expect(filePaths, isEmpty); 1133 expect(filePaths, isEmpty);
1115 // add link 1134 // add link
1116 String filePath = posix.join(projPath, 'foo.dart'); 1135 String filePath = posix.join(projPath, 'foo.dart');
1117 resourceProvider.newDummyLink(filePath); 1136 resourceProvider.newDummyLink(filePath);
1118 // the link was ignored 1137 // the link was ignored
1119 return pumpEventQueue().then((_) { 1138 return pumpEventQueue().then((_) {
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after
1800 class TestUriResolver extends UriResolver { 1819 class TestUriResolver extends UriResolver {
1801 Map<Uri, Source> uriMap; 1820 Map<Uri, Source> uriMap;
1802 1821
1803 TestUriResolver(this.uriMap); 1822 TestUriResolver(this.uriMap);
1804 1823
1805 @override 1824 @override
1806 Source resolveAbsolute(Uri uri, [Uri actualUri]) { 1825 Source resolveAbsolute(Uri uri, [Uri actualUri]) {
1807 return uriMap[uri]; 1826 return uriMap[uri];
1808 } 1827 }
1809 } 1828 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/context_manager.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698