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

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

Issue 1047733004: Support refresh of individual analysis roots (issue 22254) (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 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 | Annotate | Revision Log
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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 } 122 }
123 123
124 test_refresh_folder_with_pubspec() { 124 test_refresh_folder_with_pubspec() {
125 // create a context with a pubspec.yaml file 125 // create a context with a pubspec.yaml file
126 String pubspecPath = posix.join(projPath, 'pubspec.yaml'); 126 String pubspecPath = posix.join(projPath, 'pubspec.yaml');
127 resourceProvider.newFile(pubspecPath, 'pubspec'); 127 resourceProvider.newFile(pubspecPath, 'pubspec');
128 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); 128 manager.setRoots(<String>[projPath], <String>[], <String, String>{});
129 return pumpEventQueue().then((_) { 129 return pumpEventQueue().then((_) {
130 expect(manager.currentContextPaths.toList(), [projPath]); 130 expect(manager.currentContextPaths.toList(), [projPath]);
131 manager.now++; 131 manager.now++;
132 manager.refresh(); 132 manager.refresh(null);
133 return pumpEventQueue().then((_) { 133 return pumpEventQueue().then((_) {
134 expect(manager.currentContextPaths.toList(), [projPath]); 134 expect(manager.currentContextPaths.toList(), [projPath]);
135 expect(manager.currentContextTimestamps[projPath], manager.now); 135 expect(manager.currentContextTimestamps[projPath], manager.now);
136 }); 136 });
137 }); 137 });
138 } 138 }
139 139
140 test_refresh_oneContext() {
141 // create two contexts with pubspec.yaml files
142 String pubspecPath = posix.join(projPath, 'pubspec.yaml');
143 resourceProvider.newFile(pubspecPath, 'pubspec1');
144
145 String proj2Path = '/my/proj2';
146 resourceProvider.newFolder(proj2Path);
147 String pubspec2Path = posix.join(proj2Path, 'pubspec.yaml');
148 resourceProvider.newFile(pubspec2Path, 'pubspec2');
149
150 List<String> roots = <String>[projPath, proj2Path];
151 manager.setRoots(roots, <String>[], <String, String>{});
152 return pumpEventQueue().then((_) {
153 expect(manager.currentContextPaths.toList(), unorderedEquals(roots));
154 int then = manager.now;
155 manager.now++;
156 manager.refresh([resourceProvider.getResource(proj2Path)]);
157 return pumpEventQueue().then((_) {
158 expect(manager.currentContextPaths.toList(), unorderedEquals(roots));
159 expect(manager.currentContextTimestamps[projPath], then);
160 expect(manager.currentContextTimestamps[proj2Path], manager.now);
161 });
162 });
163 }
164
140 test_refresh_folder_with_pubspec_subfolders() { 165 test_refresh_folder_with_pubspec_subfolders() {
141 // Create a folder with no pubspec.yaml, containing two subfolders with 166 // Create a folder with no pubspec.yaml, containing two subfolders with
142 // pubspec.yaml files. 167 // pubspec.yaml files.
143 String subdir1Path = posix.join(projPath, 'subdir1'); 168 String subdir1Path = posix.join(projPath, 'subdir1');
144 String subdir2Path = posix.join(projPath, 'subdir2'); 169 String subdir2Path = posix.join(projPath, 'subdir2');
145 String pubspec1Path = posix.join(subdir1Path, 'pubspec.yaml'); 170 String pubspec1Path = posix.join(subdir1Path, 'pubspec.yaml');
146 String pubspec2Path = posix.join(subdir2Path, 'pubspec.yaml'); 171 String pubspec2Path = posix.join(subdir2Path, 'pubspec.yaml');
147 resourceProvider.newFile(pubspec1Path, 'pubspec'); 172 resourceProvider.newFile(pubspec1Path, 'pubspec');
148 resourceProvider.newFile(pubspec2Path, 'pubspec'); 173 resourceProvider.newFile(pubspec2Path, 'pubspec');
149 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); 174 manager.setRoots(<String>[projPath], <String>[], <String, String>{});
150 return pumpEventQueue().then((_) { 175 return pumpEventQueue().then((_) {
151 expect(manager.currentContextPaths.toSet(), 176 expect(manager.currentContextPaths.toSet(),
152 [subdir1Path, subdir2Path, projPath].toSet()); 177 [subdir1Path, subdir2Path, projPath].toSet());
153 manager.now++; 178 manager.now++;
154 manager.refresh(); 179 manager.refresh(null);
155 return pumpEventQueue().then((_) { 180 return pumpEventQueue().then((_) {
156 expect(manager.currentContextPaths.toSet(), 181 expect(manager.currentContextPaths.toSet(),
157 [subdir1Path, subdir2Path, projPath].toSet()); 182 [subdir1Path, subdir2Path, projPath].toSet());
158 expect(manager.currentContextTimestamps[projPath], manager.now); 183 expect(manager.currentContextTimestamps[projPath], manager.now);
159 expect(manager.currentContextTimestamps[subdir1Path], manager.now); 184 expect(manager.currentContextTimestamps[subdir1Path], manager.now);
160 expect(manager.currentContextTimestamps[subdir2Path], manager.now); 185 expect(manager.currentContextTimestamps[subdir2Path], manager.now);
161 }); 186 });
162 }); 187 });
163 } 188 }
164 189
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after
956 currentContextSources.remove(path); 981 currentContextSources.remove(path);
957 currentContextPackageUriResolvers.remove(path); 982 currentContextPackageUriResolvers.remove(path);
958 } 983 }
959 984
960 @override 985 @override
961 void updateContextPackageUriResolver( 986 void updateContextPackageUriResolver(
962 Folder contextFolder, UriResolver packageUriResolver) { 987 Folder contextFolder, UriResolver packageUriResolver) {
963 currentContextPackageUriResolvers[contextFolder.path] = packageUriResolver; 988 currentContextPackageUriResolvers[contextFolder.path] = packageUriResolver;
964 } 989 }
965 } 990 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698