| 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 } | 139 } |
| 140 } | 140 } |
| 141 | 141 |
| 142 // Matchers for data types defined in the analysis server API | 142 // Matchers for data types defined in the analysis server API |
| 143 // ========================================================== | 143 // ========================================================== |
| 144 // TODO(paulberry): add more matchers. | 144 // TODO(paulberry): add more matchers. |
| 145 | 145 |
| 146 // Matchers common to all domains | 146 // Matchers common to all domains |
| 147 // ------------------------------ | 147 // ------------------------------ |
| 148 | 148 |
| 149 const Matcher isResponse = const MatchesJsonObject('response', | 149 const Matcher isResponse = const MatchesJsonObject('response', const { |
| 150 const { | |
| 151 'id': isString | 150 'id': isString |
| 152 }, optionalFields: const { | 151 }, optionalFields: const { |
| 153 'result': anything, | 152 'result': anything, |
| 154 'error': isError | 153 'error': isError |
| 155 }); | 154 }); |
| 156 | 155 |
| 157 const Matcher isError = const MatchesJsonObject('Error', const { | 156 const Matcher isError = const MatchesJsonObject('Error', const { |
| 158 // TODO(paulberry): once we decide what the set of permitted error codes are, | 157 // TODO(paulberry): once we decide what the set of permitted error codes are, |
| 159 // add validation for 'code'. | 158 // add validation for 'code'. |
| 160 'code': anything, | 159 'code': anything, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 181 'server.getVersion result', const { | 180 'server.getVersion result', const { |
| 182 'version': isString | 181 'version': isString |
| 183 }); | 182 }); |
| 184 | 183 |
| 185 // server.status | 184 // server.status |
| 186 const Matcher isServerStatusParams = const MatchesJsonObject( | 185 const Matcher isServerStatusParams = const MatchesJsonObject( |
| 187 'server.status params', null, optionalFields: const { | 186 'server.status params', null, optionalFields: const { |
| 188 'analysis': isAnalysisStatus | 187 'analysis': isAnalysisStatus |
| 189 }); | 188 }); |
| 190 | 189 |
| 190 // analysis.getErrors |
| 191 final Matcher isAnalysisGetErrorsResult = new MatchesJsonObject( |
| 192 'analysis.getErrors result', { |
| 193 'errors': isListOf(isAnalysisError) |
| 194 }); |
| 195 |
| 191 // analysis.getHover | 196 // analysis.getHover |
| 192 final Matcher isAnalysisGetHoverResult = new MatchesJsonObject( | 197 final Matcher isAnalysisGetHoverResult = new MatchesJsonObject( |
| 193 'analysis.getHover result', { | 198 'analysis.getHover result', { |
| 194 'hovers': isListOf(isHoverInformation) | 199 'hovers': isListOf(isHoverInformation) |
| 195 }); | 200 }); |
| 196 | 201 |
| 197 // Matchers for data types used in responses and notifications | 202 // Matchers for data types used in responses and notifications |
| 198 // ----------------------------------------------------------- | 203 // ----------------------------------------------------------- |
| 199 | 204 |
| 200 const Matcher isString = const isInstanceOf<String>('String'); | 205 const Matcher isString = const isInstanceOf<String>('String'); |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 | 502 |
| 498 /** | 503 /** |
| 499 * Start the server. If [debugServer] is true, the server will be started | 504 * Start the server. If [debugServer] is true, the server will be started |
| 500 * with "--debug", allowing a debugger to be attached. | 505 * with "--debug", allowing a debugger to be attached. |
| 501 */ | 506 */ |
| 502 static Future<Server> start({bool debugServer: false}) { | 507 static Future<Server> start({bool debugServer: false}) { |
| 503 // TODO(paulberry): move the logic for finding the script, the dart | 508 // TODO(paulberry): move the logic for finding the script, the dart |
| 504 // executable, and the package root into a shell script. | 509 // executable, and the package root into a shell script. |
| 505 String dartBinary = Platform.executable; | 510 String dartBinary = Platform.executable; |
| 506 String scriptDir = dirname(Platform.script.path); | 511 String scriptDir = dirname(Platform.script.path); |
| 507 String serverPath = normalize(join(scriptDir, '..', | 512 String serverPath = normalize(join(scriptDir, '..', '..', 'bin', |
| 508 '..', 'bin', 'server.dart')); | 513 'server.dart')); |
| 509 String repoPath = normalize(join(scriptDir, '..', '..', '..', '..')); | 514 String repoPath = normalize(join(scriptDir, '..', '..', '..', '..')); |
| 510 String buildDirName; | 515 String buildDirName; |
| 511 if (Platform.isWindows) { | 516 if (Platform.isWindows) { |
| 512 buildDirName = 'build'; | 517 buildDirName = 'build'; |
| 513 } else if (Platform.isMacOS){ | 518 } else if (Platform.isMacOS) { |
| 514 buildDirName = 'xcodebuild'; | 519 buildDirName = 'xcodebuild'; |
| 515 } else { | 520 } else { |
| 516 buildDirName = 'out'; | 521 buildDirName = 'out'; |
| 517 } | 522 } |
| 518 String dartConfiguration = 'ReleaseIA32'; // TODO(paulberry): this is a gues
s | 523 // TODO(paulberry): this is a guess |
| 524 String dartConfiguration = 'ReleaseIA32'; |
| 519 String buildPath = join(repoPath, buildDirName, dartConfiguration); | 525 String buildPath = join(repoPath, buildDirName, dartConfiguration); |
| 520 String packageRoot = join(buildPath, 'packages'); | 526 String packageRoot = join(buildPath, 'packages'); |
| 521 List<String> arguments = []; | 527 List<String> arguments = []; |
| 522 if (debugServer) { | 528 if (debugServer) { |
| 523 arguments.add('--debug'); | 529 arguments.add('--debug'); |
| 524 } | 530 } |
| 525 arguments.add('--package-root=$packageRoot'); | 531 arguments.add('--package-root=$packageRoot'); |
| 526 arguments.add(serverPath); | 532 arguments.add(serverPath); |
| 527 return Process.start(dartBinary, arguments).then((Process process) { | 533 return Process.start(dartBinary, arguments).then((Process process) { |
| 528 Server server = new Server._(process); | 534 Server server = new Server._(process); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 657 * Record a message that was exchanged with the server, and print it out if | 663 * Record a message that was exchanged with the server, and print it out if |
| 658 * [debugStdio] has been called. | 664 * [debugStdio] has been called. |
| 659 */ | 665 */ |
| 660 void _recordStdio(String line) { | 666 void _recordStdio(String line) { |
| 661 if (_debuggingStdio) { | 667 if (_debuggingStdio) { |
| 662 print(line); | 668 print(line); |
| 663 } | 669 } |
| 664 _recordedStdio.add(line); | 670 _recordedStdio.add(line); |
| 665 } | 671 } |
| 666 } | 672 } |
| OLD | NEW |