OLD | NEW |
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.integration.analysis; | 5 library test.integration.analysis; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:collection'; | 8 import 'dart:collection'; |
9 import 'dart:convert'; | 9 import 'dart:convert'; |
10 import 'dart:io'; | 10 import 'dart:io'; |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 * True if the teardown process should skip sending a "server.shutdown" | 118 * True if the teardown process should skip sending a "server.shutdown" |
119 * request (e.g. because the server is known to have already shutdown). | 119 * request (e.g. because the server is known to have already shutdown). |
120 */ | 120 */ |
121 bool skipShutdown = false; | 121 bool skipShutdown = false; |
122 | 122 |
123 /** | 123 /** |
124 * True if we are currently subscribed to [SERVER_STATUS] updates. | 124 * True if we are currently subscribed to [SERVER_STATUS] updates. |
125 */ | 125 */ |
126 bool _subscribedToServerStatus = false; | 126 bool _subscribedToServerStatus = false; |
127 | 127 |
128 List<AnalysisError> getErrors(String pathname) => | |
129 currentAnalysisErrors[pathname]; | |
130 | |
131 AbstractAnalysisServerIntegrationTest() { | 128 AbstractAnalysisServerIntegrationTest() { |
132 initializeInttestMixin(); | 129 initializeInttestMixin(); |
133 } | 130 } |
134 | 131 |
135 /** | 132 /** |
136 * Return a future which will complete when a 'server.status' notification is | 133 * Return a future which will complete when a 'server.status' notification is |
137 * received from the server with 'analyzing' set to false. | 134 * received from the server with 'analyzing' set to false. |
138 * | 135 * |
139 * The future will only be completed by 'server.status' notifications that are | 136 * The future will only be completed by 'server.status' notifications that are |
140 * received after this function call. So it is safe to use this getter | 137 * received after this function call. So it is safe to use this getter |
(...skipping 21 matching lines...) Expand all Loading... |
162 bool get enableNewAnalysisDriver => false; | 159 bool get enableNewAnalysisDriver => false; |
163 | 160 |
164 /** | 161 /** |
165 * Print out any messages exchanged with the server. If some messages have | 162 * Print out any messages exchanged with the server. If some messages have |
166 * already been exchanged with the server, they are printed out immediately. | 163 * already been exchanged with the server, they are printed out immediately. |
167 */ | 164 */ |
168 void debugStdio() { | 165 void debugStdio() { |
169 server.debugStdio(); | 166 server.debugStdio(); |
170 } | 167 } |
171 | 168 |
| 169 List<AnalysisError> getErrors(String pathname) => |
| 170 currentAnalysisErrors[pathname]; |
| 171 |
| 172 /** |
| 173 * Read a source file with the given absolute [pathname]. |
| 174 */ |
| 175 String readFile(String pathname) => new File(pathname).readAsStringSync(); |
| 176 |
172 @override | 177 @override |
173 Future sendServerSetSubscriptions(List<ServerService> subscriptions) { | 178 Future sendServerSetSubscriptions(List<ServerService> subscriptions) { |
174 _subscribedToServerStatus = subscriptions.contains(ServerService.STATUS); | 179 _subscribedToServerStatus = subscriptions.contains(ServerService.STATUS); |
175 return super.sendServerSetSubscriptions(subscriptions); | 180 return super.sendServerSetSubscriptions(subscriptions); |
176 } | 181 } |
177 | 182 |
178 /** | 183 /** |
179 * The server is automatically started before every test, and a temporary | 184 * The server is automatically started before every test, and a temporary |
180 * [sourceDirectory] is created. | 185 * [sourceDirectory] is created. |
181 */ | 186 */ |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 * Parent directories are created as necessary. | 279 * Parent directories are created as necessary. |
275 * | 280 * |
276 * Return a normalized path to the file (with symbolic links resolved). | 281 * Return a normalized path to the file (with symbolic links resolved). |
277 */ | 282 */ |
278 String writeFile(String pathname, String contents) { | 283 String writeFile(String pathname, String contents) { |
279 new Directory(dirname(pathname)).createSync(recursive: true); | 284 new Directory(dirname(pathname)).createSync(recursive: true); |
280 File file = new File(pathname); | 285 File file = new File(pathname); |
281 file.writeAsStringSync(contents); | 286 file.writeAsStringSync(contents); |
282 return file.resolveSymbolicLinksSync(); | 287 return file.resolveSymbolicLinksSync(); |
283 } | 288 } |
284 | |
285 /** | |
286 * Read a source file with the given absolute [pathname]. | |
287 */ | |
288 String readFile(String pathname) => new File(pathname).readAsStringSync(); | |
289 } | 289 } |
290 | 290 |
291 /** | 291 /** |
292 * An error result from a server request. | |
293 */ | |
294 class ServerErrorMessage { | |
295 final Map message; | |
296 | |
297 ServerErrorMessage(this.message); | |
298 | |
299 dynamic get error => message['error']; | |
300 | |
301 String toString() => message.toString(); | |
302 } | |
303 | |
304 /** | |
305 * Wrapper class for Matcher which doesn't create the underlying Matcher object | 292 * Wrapper class for Matcher which doesn't create the underlying Matcher object |
306 * until it is needed. This is necessary in order to create matchers that can | 293 * until it is needed. This is necessary in order to create matchers that can |
307 * refer to themselves (so that recursive data structures can be represented). | 294 * refer to themselves (so that recursive data structures can be represented). |
308 */ | 295 */ |
309 class LazyMatcher implements Matcher { | 296 class LazyMatcher implements Matcher { |
310 /** | 297 /** |
311 * Callback that will be used to create the matcher the first time it is | 298 * Callback that will be used to create the matcher the first time it is |
312 * needed. | 299 * needed. |
313 */ | 300 */ |
314 final MatcherCreator _creator; | 301 final MatcherCreator _creator; |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 * Return a future that will complete when all commands that have been sent | 538 * Return a future that will complete when all commands that have been sent |
552 * to the server so far have been flushed to the OS buffer. | 539 * to the server so far have been flushed to the OS buffer. |
553 */ | 540 */ |
554 Future flushCommands() { | 541 Future flushCommands() { |
555 return _process.stdin.flush(); | 542 return _process.stdin.flush(); |
556 } | 543 } |
557 | 544 |
558 /** | 545 /** |
559 * Stop the server. | 546 * Stop the server. |
560 */ | 547 */ |
561 Future kill(String reason) { | 548 Future<int> kill(String reason) { |
562 debugStdio(); | 549 debugStdio(); |
563 _recordStdio('FORCIBLY TERMINATING PROCESS: $reason'); | 550 _recordStdio('FORCIBLY TERMINATING PROCESS: $reason'); |
564 _process.kill(); | 551 _process.kill(); |
565 return _process.exitCode; | 552 return _process.exitCode; |
566 } | 553 } |
567 | 554 |
568 /** | 555 /** |
569 * Start listening to output from the server, and deliver notifications to | 556 * Start listening to output from the server, and deliver notifications to |
570 * [notificationProcessor]. | 557 * [notificationProcessor]. |
571 */ | 558 */ |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 double elapsedTime = currentElapseTime; | 751 double elapsedTime = currentElapseTime; |
765 line = "$elapsedTime: $line"; | 752 line = "$elapsedTime: $line"; |
766 if (_debuggingStdio) { | 753 if (_debuggingStdio) { |
767 print(line); | 754 print(line); |
768 } | 755 } |
769 _recordedStdio.add(line); | 756 _recordedStdio.add(line); |
770 } | 757 } |
771 } | 758 } |
772 | 759 |
773 /** | 760 /** |
| 761 * An error result from a server request. |
| 762 */ |
| 763 class ServerErrorMessage { |
| 764 final Map message; |
| 765 |
| 766 ServerErrorMessage(this.message); |
| 767 |
| 768 dynamic get error => message['error']; |
| 769 |
| 770 String toString() => message.toString(); |
| 771 } |
| 772 |
| 773 /** |
774 * Matcher that matches a list of objects, each of which satisfies the given | 774 * Matcher that matches a list of objects, each of which satisfies the given |
775 * matcher. | 775 * matcher. |
776 */ | 776 */ |
777 class _ListOf extends Matcher { | 777 class _ListOf extends Matcher { |
778 /** | 778 /** |
779 * Matcher which every element of the list must satisfy. | 779 * Matcher which every element of the list must satisfy. |
780 */ | 780 */ |
781 final Matcher elementMatcher; | 781 final Matcher elementMatcher; |
782 | 782 |
783 /** | 783 /** |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
982 void populateMismatches(item, List<MismatchDescriber> mismatches); | 982 void populateMismatches(item, List<MismatchDescriber> mismatches); |
983 | 983 |
984 /** | 984 /** |
985 * Create a [MismatchDescriber] describing a mismatch with a simple string. | 985 * Create a [MismatchDescriber] describing a mismatch with a simple string. |
986 */ | 986 */ |
987 MismatchDescriber simpleDescription(String description) => | 987 MismatchDescriber simpleDescription(String description) => |
988 (Description mismatchDescription) { | 988 (Description mismatchDescription) { |
989 mismatchDescription.add(description); | 989 mismatchDescription.add(description); |
990 }; | 990 }; |
991 } | 991 } |
OLD | NEW |