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) => currentAnalysisErrors[pathna
me]; | 128 List<AnalysisError> getErrors(String pathname) => |
| 129 currentAnalysisErrors[pathname]; |
129 | 130 |
130 AbstractAnalysisServerIntegrationTest() { | 131 AbstractAnalysisServerIntegrationTest() { |
131 initializeInttestMixin(); | 132 initializeInttestMixin(); |
132 } | 133 } |
133 | 134 |
134 /** | 135 /** |
135 * Return a future which will complete when a 'server.status' notification is | 136 * Return a future which will complete when a 'server.status' notification is |
136 * received from the server with 'analyzing' set to false. | 137 * received from the server with 'analyzing' set to false. |
137 * | 138 * |
138 * The future will only be completed by 'server.status' notifications that are | 139 * The future will only be completed by 'server.status' notifications that are |
(...skipping 10 matching lines...) Expand all Loading... |
149 subscription = onServerStatus.listen((ServerStatusParams params) { | 150 subscription = onServerStatus.listen((ServerStatusParams params) { |
150 if (params.analysis != null && !params.analysis.isAnalyzing) { | 151 if (params.analysis != null && !params.analysis.isAnalyzing) { |
151 completer.complete(params); | 152 completer.complete(params); |
152 subscription.cancel(); | 153 subscription.cancel(); |
153 } | 154 } |
154 }); | 155 }); |
155 return completer.future; | 156 return completer.future; |
156 } | 157 } |
157 | 158 |
158 /** | 159 /** |
159 * Return `true` if the new analysis driver should be used by these tests. | |
160 */ | |
161 bool get enableNewAnalysisDriver => false; | |
162 | |
163 /** | |
164 * Print out any messages exchanged with the server. If some messages have | 160 * Print out any messages exchanged with the server. If some messages have |
165 * already been exchanged with the server, they are printed out immediately. | 161 * already been exchanged with the server, they are printed out immediately. |
166 */ | 162 */ |
167 void debugStdio() { | 163 void debugStdio() { |
168 server.debugStdio(); | 164 server.debugStdio(); |
169 } | 165 } |
170 | 166 |
171 @override | 167 @override |
172 Future sendServerSetSubscriptions(List<ServerService> subscriptions) { | 168 Future sendServerSetSubscriptions(List<ServerService> subscriptions) { |
173 _subscribedToServerStatus = subscriptions.contains(ServerService.STATUS); | 169 _subscribedToServerStatus = subscriptions.contains(ServerService.STATUS); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 } | 239 } |
244 | 240 |
245 /** | 241 /** |
246 * Start [server]. | 242 * Start [server]. |
247 */ | 243 */ |
248 Future startServer( | 244 Future startServer( |
249 {bool checked: true, int diagnosticPort, int servicesPort}) => | 245 {bool checked: true, int diagnosticPort, int servicesPort}) => |
250 server.start( | 246 server.start( |
251 checked: checked, | 247 checked: checked, |
252 diagnosticPort: diagnosticPort, | 248 diagnosticPort: diagnosticPort, |
253 enableNewAnalysisDriver: enableNewAnalysisDriver, | |
254 servicesPort: servicesPort); | 249 servicesPort: servicesPort); |
255 | 250 |
256 /** | 251 /** |
257 * After every test, the server is stopped and [sourceDirectory] is deleted. | 252 * After every test, the server is stopped and [sourceDirectory] is deleted. |
258 */ | 253 */ |
259 Future tearDown() { | 254 Future tearDown() { |
260 return shutdownIfNeeded().then((_) { | 255 return shutdownIfNeeded().then((_) { |
261 sourceDirectory.deleteSync(recursive: true); | 256 sourceDirectory.deleteSync(recursive: true); |
262 }); | 257 }); |
263 } | 258 } |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 } | 647 } |
653 | 648 |
654 /** | 649 /** |
655 * Start the server. If [profileServer] is `true`, the server will be started | 650 * Start the server. If [profileServer] is `true`, the server will be started |
656 * with "--observe" and "--pause-isolates-on-exit", allowing the observatory | 651 * with "--observe" and "--pause-isolates-on-exit", allowing the observatory |
657 * to be used. | 652 * to be used. |
658 */ | 653 */ |
659 Future start( | 654 Future start( |
660 {bool checked: true, | 655 {bool checked: true, |
661 int diagnosticPort, | 656 int diagnosticPort, |
662 bool enableNewAnalysisDriver: false, | |
663 bool noErrorNotification: false, | 657 bool noErrorNotification: false, |
664 bool profileServer: false, | 658 bool profileServer: false, |
665 String sdkPath, | 659 String sdkPath, |
666 int servicesPort, | 660 int servicesPort, |
667 bool useAnalysisHighlight2: false}) { | 661 bool useAnalysisHighlight2: false}) { |
668 if (_process != null) { | 662 if (_process != null) { |
669 throw new Exception('Process already started'); | 663 throw new Exception('Process already started'); |
670 } | 664 } |
671 _time.start(); | 665 _time.start(); |
672 String dartBinary = Platform.executable; | 666 String dartBinary = Platform.executable; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 if (diagnosticPort != null) { | 700 if (diagnosticPort != null) { |
707 arguments.add('--port'); | 701 arguments.add('--port'); |
708 arguments.add(diagnosticPort.toString()); | 702 arguments.add(diagnosticPort.toString()); |
709 } | 703 } |
710 if (sdkPath != null) { | 704 if (sdkPath != null) { |
711 arguments.add('--sdk=$sdkPath'); | 705 arguments.add('--sdk=$sdkPath'); |
712 } | 706 } |
713 if (useAnalysisHighlight2) { | 707 if (useAnalysisHighlight2) { |
714 arguments.add('--useAnalysisHighlight2'); | 708 arguments.add('--useAnalysisHighlight2'); |
715 } | 709 } |
716 if (!enableNewAnalysisDriver) { | |
717 arguments.add('--disable-new-analysis-driver'); | |
718 } | |
719 if (noErrorNotification) { | 710 if (noErrorNotification) { |
720 arguments.add('--no-error-notification'); | 711 arguments.add('--no-error-notification'); |
721 } | 712 } |
722 // print('Launching $serverPath'); | 713 // print('Launching $serverPath'); |
723 // print('$dartBinary ${arguments.join(' ')}'); | 714 // print('$dartBinary ${arguments.join(' ')}'); |
724 // TODO(devoncarew): We could experiment with instead launching the analysis | 715 // TODO(devoncarew): We could experiment with instead launching the analysis |
725 // server in a separate isolate. This would make it easier to debug the | 716 // server in a separate isolate. This would make it easier to debug the |
726 // integration tests, and would like speed the tests up as well. | 717 // integration tests, and would like speed the tests up as well. |
727 return Process.start(dartBinary, arguments).then((Process process) { | 718 return Process.start(dartBinary, arguments).then((Process process) { |
728 _process = process; | 719 _process = process; |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
983 void populateMismatches(item, List<MismatchDescriber> mismatches); | 974 void populateMismatches(item, List<MismatchDescriber> mismatches); |
984 | 975 |
985 /** | 976 /** |
986 * Create a [MismatchDescriber] describing a mismatch with a simple string. | 977 * Create a [MismatchDescriber] describing a mismatch with a simple string. |
987 */ | 978 */ |
988 MismatchDescriber simpleDescription(String description) => | 979 MismatchDescriber simpleDescription(String description) => |
989 (Description mismatchDescription) { | 980 (Description mismatchDescription) { |
990 mismatchDescription.add(description); | 981 mismatchDescription.add(description); |
991 }; | 982 }; |
992 } | 983 } |
OLD | NEW |