| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 server.driver; | 5 library server.driver; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:math' show max, sqrt; | 8 import 'dart:math' show max, sqrt; |
| 9 | 9 |
| 10 import 'package:logging/logging.dart'; | 10 import 'package:logging/logging.dart'; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 */ | 38 */ |
| 39 class Driver extends IntegrationTestMixin { | 39 class Driver extends IntegrationTestMixin { |
| 40 /** | 40 /** |
| 41 * The amount of time to give the server to respond to a shutdown request | 41 * The amount of time to give the server to respond to a shutdown request |
| 42 * before forcibly terminating it. | 42 * before forcibly terminating it. |
| 43 */ | 43 */ |
| 44 static const Duration SHUTDOWN_TIMEOUT = const Duration(seconds: 5); | 44 static const Duration SHUTDOWN_TIMEOUT = const Duration(seconds: 5); |
| 45 | 45 |
| 46 final Logger logger = new Logger('Driver'); | 46 final Logger logger = new Logger('Driver'); |
| 47 | 47 |
| 48 final bool newTaskModel; | |
| 49 | |
| 50 /** | 48 /** |
| 51 * The diagnostic port for Analysis Server or `null` if none. | 49 * The diagnostic port for Analysis Server or `null` if none. |
| 52 */ | 50 */ |
| 53 final int diagnosticPort; | 51 final int diagnosticPort; |
| 54 | 52 |
| 55 /** | 53 /** |
| 56 * A flag indicating whether the server is running. | 54 * A flag indicating whether the server is running. |
| 57 */ | 55 */ |
| 58 bool running = false; | 56 bool running = false; |
| 59 | 57 |
| 60 @override | 58 @override |
| 61 Server server; | 59 Server server; |
| 62 | 60 |
| 63 /** | 61 /** |
| 64 * The results collected while running analysis server. | 62 * The results collected while running analysis server. |
| 65 */ | 63 */ |
| 66 final Results results = new Results(); | 64 final Results results = new Results(); |
| 67 | 65 |
| 68 /** | 66 /** |
| 69 * The [Completer] for [runComplete]. | 67 * The [Completer] for [runComplete]. |
| 70 */ | 68 */ |
| 71 Completer<Results> _runCompleter = new Completer<Results>(); | 69 Completer<Results> _runCompleter = new Completer<Results>(); |
| 72 | 70 |
| 73 Driver({this.newTaskModel, this.diagnosticPort}); | 71 Driver({this.diagnosticPort}); |
| 74 | 72 |
| 75 /** | 73 /** |
| 76 * Return a [Future] that completes with the [Results] of running | 74 * Return a [Future] that completes with the [Results] of running |
| 77 * the analysis server once all operations have been performed. | 75 * the analysis server once all operations have been performed. |
| 78 */ | 76 */ |
| 79 Future<Results> get runComplete => _runCompleter.future; | 77 Future<Results> get runComplete => _runCompleter.future; |
| 80 | 78 |
| 81 /** | 79 /** |
| 82 * Perform the given operation. | 80 * Perform the given operation. |
| 83 * Return a [Future] that completes when the next operation can be performed, | 81 * Return a [Future] that completes when the next operation can be performed, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 107 logger.log(Level.FINE, 'starting server'); | 105 logger.log(Level.FINE, 'starting server'); |
| 108 initializeInttestMixin(); | 106 initializeInttestMixin(); |
| 109 server = new Server(); | 107 server = new Server(); |
| 110 Completer serverConnected = new Completer(); | 108 Completer serverConnected = new Completer(); |
| 111 onServerConnected.listen((_) { | 109 onServerConnected.listen((_) { |
| 112 logger.log(Level.FINE, 'connected to server'); | 110 logger.log(Level.FINE, 'connected to server'); |
| 113 serverConnected.complete(); | 111 serverConnected.complete(); |
| 114 }); | 112 }); |
| 115 running = true; | 113 running = true; |
| 116 return server | 114 return server |
| 117 .start( | 115 .start(diagnosticPort: diagnosticPort /*profileServer: true*/) |
| 118 diagnosticPort: diagnosticPort, | |
| 119 newTaskModel: newTaskModel /*profileServer: true*/) | |
| 120 .then((params) { | 116 .then((params) { |
| 121 server.listenToOutput(dispatchNotification); | 117 server.listenToOutput(dispatchNotification); |
| 122 server.exitCode.then((_) { | 118 server.exitCode.then((_) { |
| 123 logger.log(Level.FINE, 'server stopped'); | 119 logger.log(Level.FINE, 'server stopped'); |
| 124 running = false; | 120 running = false; |
| 125 _resultsReady(); | 121 _resultsReady(); |
| 126 }); | 122 }); |
| 127 return serverConnected.future; | 123 return serverConnected.future; |
| 128 }); | 124 }); |
| 129 } | 125 } |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 int totalUnexpectedResultCount) { | 307 int totalUnexpectedResultCount) { |
| 312 StringBuffer sb = new StringBuffer(); | 308 StringBuffer sb = new StringBuffer(); |
| 313 _printColumn(sb, 'Totals', keyLen); | 309 _printColumn(sb, 'Totals', keyLen); |
| 314 _printColumn(sb, totalCount.toString(), 6, rightJustified: true); | 310 _printColumn(sb, totalCount.toString(), 6, rightJustified: true); |
| 315 _printColumn(sb, totalErrorCount.toString(), 6, rightJustified: true); | 311 _printColumn(sb, totalErrorCount.toString(), 6, rightJustified: true); |
| 316 _printColumn(sb, totalUnexpectedResultCount.toString(), 6, | 312 _printColumn(sb, totalUnexpectedResultCount.toString(), 6, |
| 317 rightJustified: true); | 313 rightJustified: true); |
| 318 print(sb.toString()); | 314 print(sb.toString()); |
| 319 } | 315 } |
| 320 } | 316 } |
| OLD | NEW |