| 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'; |
| 11 | 11 |
| 12 import 'package:analysis_server/src/constants.dart'; | 12 import 'package:analysis_server/src/constants.dart'; |
| 13 import 'package:analysis_server/src/protocol.dart'; | 13 import 'package:analysis_server/src/protocol.dart'; |
| 14 import 'package:path/path.dart'; | 14 import 'package:path/path.dart'; |
| 15 import 'package:unittest/unittest.dart'; | 15 import 'package:unittest/unittest.dart'; |
| 16 | 16 |
| 17 import 'integration_test_methods.dart'; | 17 import 'integration_test_methods.dart'; |
| 18 import 'protocol_matchers.dart'; | 18 import 'protocol_matchers.dart'; |
| 19 import 'package:analysis_server/src/server/driver.dart' as analysisServer; |
| 19 | 20 |
| 20 const Matcher isBool = const isInstanceOf<bool>('bool'); | 21 const Matcher isBool = const isInstanceOf<bool>('bool'); |
| 21 | 22 |
| 22 const Matcher isInt = const isInstanceOf<int>('int'); | 23 const Matcher isInt = const isInstanceOf<int>('int'); |
| 23 | 24 |
| 24 const Matcher isNotification = const MatchesJsonObject( | 25 const Matcher isNotification = const MatchesJsonObject( |
| 25 'notification', const {'event': isString}, | 26 'notification', const {'event': isString}, |
| 26 optionalFields: const {'params': isMap}); | 27 optionalFields: const {'params': isMap}); |
| 27 | 28 |
| 28 const Matcher isObject = isMap; | 29 const Matcher isObject = isMap; |
| (...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 return completer.future; | 584 return completer.future; |
| 584 } | 585 } |
| 585 | 586 |
| 586 /** | 587 /** |
| 587 * Start the server. If [debugServer] is `true`, the server will be started | 588 * Start the server. If [debugServer] is `true`, the server will be started |
| 588 * with "--debug", allowing a debugger to be attached. If [profileServer] is | 589 * with "--debug", allowing a debugger to be attached. If [profileServer] is |
| 589 * `true`, the server will be started with "--observe" and | 590 * `true`, the server will be started with "--observe" and |
| 590 * "--pause-isolates-on-exit", allowing the observatory to be used. | 591 * "--pause-isolates-on-exit", allowing the observatory to be used. |
| 591 */ | 592 */ |
| 592 Future start({bool debugServer: false, int diagnosticPort, | 593 Future start({bool debugServer: false, int diagnosticPort, |
| 593 bool profileServer: false, bool useAnalysisHighlight2: false}) { | 594 bool profileServer: false, bool newTaskModel: false, |
| 595 bool useAnalysisHighlight2: false}) { |
| 594 if (_process != null) { | 596 if (_process != null) { |
| 595 throw new Exception('Process already started'); | 597 throw new Exception('Process already started'); |
| 596 } | 598 } |
| 597 _time.start(); | 599 _time.start(); |
| 598 String dartBinary = Platform.executable; | 600 String dartBinary = Platform.executable; |
| 599 String rootDir = | 601 String rootDir = |
| 600 findRoot(Platform.script.toFilePath(windows: Platform.isWindows)); | 602 findRoot(Platform.script.toFilePath(windows: Platform.isWindows)); |
| 601 String serverPath = normalize(join(rootDir, 'bin', 'server.dart')); | 603 String serverPath = normalize(join(rootDir, 'bin', 'server.dart')); |
| 602 List<String> arguments = []; | 604 List<String> arguments = []; |
| 603 if (debugServer) { | 605 if (debugServer) { |
| 604 arguments.add('--debug'); | 606 arguments.add('--debug'); |
| 605 } | 607 } |
| 606 if (profileServer) { | 608 if (profileServer) { |
| 607 arguments.add('--observe'); | 609 arguments.add('--observe'); |
| 608 arguments.add('--pause-isolates-on-exit'); | 610 arguments.add('--pause-isolates-on-exit'); |
| 609 } | 611 } |
| 610 if (Platform.packageRoot.isNotEmpty) { | 612 if (Platform.packageRoot.isNotEmpty) { |
| 611 arguments.add('--package-root=${Platform.packageRoot}'); | 613 arguments.add('--package-root=${Platform.packageRoot}'); |
| 612 } | 614 } |
| 613 arguments.add('--checked'); | 615 arguments.add('--checked'); |
| 614 arguments.add(serverPath); | 616 arguments.add(serverPath); |
| 615 if (diagnosticPort != null) { | 617 if (diagnosticPort != null) { |
| 616 arguments.add('--port'); | 618 arguments.add('--port'); |
| 617 arguments.add(diagnosticPort.toString()); | 619 arguments.add(diagnosticPort.toString()); |
| 618 } | 620 } |
| 619 if (useAnalysisHighlight2) { | 621 if (useAnalysisHighlight2) { |
| 620 arguments.add('--useAnalysisHighlight2'); | 622 arguments.add('--useAnalysisHighlight2'); |
| 621 } | 623 } |
| 624 if (newTaskModel) { |
| 625 arguments.add('--${analysisServer.Driver.ENABLE_NEW_TASK_MODEL}'); |
| 626 } |
| 622 return Process.start(dartBinary, arguments).then((Process process) { | 627 return Process.start(dartBinary, arguments).then((Process process) { |
| 623 _process = process; | 628 _process = process; |
| 624 process.exitCode.then((int code) { | 629 process.exitCode.then((int code) { |
| 625 _recordStdio('TERMINATED WITH EXIT CODE $code'); | 630 _recordStdio('TERMINATED WITH EXIT CODE $code'); |
| 626 if (code != 0) { | 631 if (code != 0) { |
| 627 _badDataFromServer(); | 632 _badDataFromServer(); |
| 628 } | 633 } |
| 629 }); | 634 }); |
| 630 }); | 635 }); |
| 631 } | 636 } |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 869 void populateMismatches(item, List<MismatchDescriber> mismatches); | 874 void populateMismatches(item, List<MismatchDescriber> mismatches); |
| 870 | 875 |
| 871 /** | 876 /** |
| 872 * Create a [MismatchDescriber] describing a mismatch with a simple string. | 877 * Create a [MismatchDescriber] describing a mismatch with a simple string. |
| 873 */ | 878 */ |
| 874 MismatchDescriber simpleDescription(String description) => | 879 MismatchDescriber simpleDescription(String description) => |
| 875 (Description mismatchDescription) { | 880 (Description mismatchDescription) { |
| 876 mismatchDescription.add(description); | 881 mismatchDescription.add(description); |
| 877 }; | 882 }; |
| 878 } | 883 } |
| OLD | NEW |