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

Side by Side Diff: pkg/analysis_server/test/integration/integration_tests.dart

Issue 451483005: Code generate integration test methods for synchronous request/response pairs. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 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.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';
11 11
12 import 'package:analysis_server/src/constants.dart'; 12 import 'package:analysis_server/src/constants.dart';
13 import 'package:path/path.dart'; 13 import 'package:path/path.dart';
14 import 'package:unittest/unittest.dart'; 14 import 'package:unittest/unittest.dart';
15 15
16 import 'integration_test_methods.dart';
16 import 'protocol_matchers.dart'; 17 import 'protocol_matchers.dart';
17 18
18 /** 19 /**
19 * Base class for analysis server integration tests. 20 * Base class for analysis server integration tests.
20 */ 21 */
21 abstract class AbstractAnalysisServerIntegrationTest { 22 abstract class AbstractAnalysisServerIntegrationTest extends InttestMixin {
22 /** 23 /**
23 * Amount of time to give the server to respond to a shutdown request before 24 * Amount of time to give the server to respond to a shutdown request before
24 * forcibly terminating it. 25 * forcibly terminating it.
25 */ 26 */
26 static const Duration SHUTDOWN_TIMEOUT = const Duration(seconds: 5); 27 static const Duration SHUTDOWN_TIMEOUT = const Duration(seconds: 5);
27 28
28 /** 29 /**
29 * Connection to the analysis server. 30 * Connection to the analysis server.
30 */ 31 */
31 final Server server = new Server(); 32 final Server server = new Server();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 */ 75 */
75 String sourcePath(String relativePath) { 76 String sourcePath(String relativePath) {
76 return join(sourceDirectory.path, relativePath.replaceAll('/', separator)); 77 return join(sourceDirectory.path, relativePath.replaceAll('/', separator));
77 } 78 }
78 79
79 /** 80 /**
80 * Send the server an 'analysis.setAnalysisRoots' command directing it to 81 * Send the server an 'analysis.setAnalysisRoots' command directing it to
81 * analyze [sourceDirectory]. 82 * analyze [sourceDirectory].
82 */ 83 */
83 Future standardAnalysisRoot() { 84 Future standardAnalysisRoot() {
84 return server.send(ANALYSIS_SET_ANALYSIS_ROOTS, { 85 return sendAnalysisSetAnalysisRoots([sourceDirectory.path], []);
85 'included': [sourceDirectory.path],
86 'excluded': []
87 });
88 } 86 }
89 87
90 /** 88 /**
91 * Send the server a 'server.setSubscriptions' command.
92 */
93 Future server_setSubscriptions(List<String> subscriptions) {
94 return server.send(SERVER_SET_SUBSCRIPTIONS, {
95 'subscriptions': subscriptions
96 });
97 }
98
99 /**
100 * Return a future which will complete when a 'server.status' notification is 89 * Return a future which will complete when a 'server.status' notification is
101 * received from the server with 'analyzing' set to false. 90 * received from the server with 'analyzing' set to false.
102 * 91 *
103 * The future will only be completed by 'server.status' notifications that are 92 * The future will only be completed by 'server.status' notifications that are
104 * received after this function call. So it is safe to use this getter 93 * received after this function call. So it is safe to use this getter
105 * multiple times in one test; each time it is used it will wait afresh for 94 * multiple times in one test; each time it is used it will wait afresh for
106 * analysis to finish. 95 * analysis to finish.
107 */ 96 */
108 Future get analysisFinished { 97 Future get analysisFinished {
109 Completer completer = new Completer(); 98 Completer completer = new Completer();
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 /** 160 /**
172 * If [skipShutdown] is not set, shut down the server. 161 * If [skipShutdown] is not set, shut down the server.
173 */ 162 */
174 Future _shutdownIfNeeded() { 163 Future _shutdownIfNeeded() {
175 if (skipShutdown) { 164 if (skipShutdown) {
176 return new Future.value(); 165 return new Future.value();
177 } 166 }
178 // Give the server a short time to comply with the shutdown request; if it 167 // Give the server a short time to comply with the shutdown request; if it
179 // doesn't exit, then forcibly terminate it. 168 // doesn't exit, then forcibly terminate it.
180 Completer processExited = new Completer(); 169 Completer processExited = new Completer();
181 server.send(SERVER_SHUTDOWN, null); 170 sendServerShutdown();
182 return server.exitCode.timeout(SHUTDOWN_TIMEOUT, onTimeout: () { 171 return server.exitCode.timeout(SHUTDOWN_TIMEOUT, onTimeout: () {
183 return server.kill(); 172 return server.kill();
184 }); 173 });
185 } 174 }
186 } 175 }
187 176
188 final Matcher isResponse = new MatchesJsonObject('response', { 177 final Matcher isResponse = new MatchesJsonObject('response', {
189 'id': isString 178 'id': isString
190 }, optionalFields: { 179 }, optionalFields: {
191 'result': anything, 180 'result': anything,
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 */ 690 */
702 void _recordStdio(String line) { 691 void _recordStdio(String line) {
703 double elapsedTime = _time.elapsedTicks / _time.frequency; 692 double elapsedTime = _time.elapsedTicks / _time.frequency;
704 line = "$elapsedTime: $line"; 693 line = "$elapsedTime: $line";
705 if (_debuggingStdio) { 694 if (_debuggingStdio) {
706 print(line); 695 print(line);
707 } 696 }
708 _recordedStdio.add(line); 697 _recordedStdio.add(line);
709 } 698 }
710 } 699 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698