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 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
273 */ | 273 */ |
274 String writeFile(String pathname, String contents) { | 274 String writeFile(String pathname, String contents) { |
275 new Directory(dirname(pathname)).createSync(recursive: true); | 275 new Directory(dirname(pathname)).createSync(recursive: true); |
276 File file = new File(pathname); | 276 File file = new File(pathname); |
277 file.writeAsStringSync(contents); | 277 file.writeAsStringSync(contents); |
278 return file.resolveSymbolicLinksSync(); | 278 return file.resolveSymbolicLinksSync(); |
279 } | 279 } |
280 } | 280 } |
281 | 281 |
282 /** | 282 /** |
283 * An error result from a server call. | |
Brian Wilkerson
2017/02/12 18:47:09
nit: "call" --> "request"
devoncarew
2017/02/12 19:22:47
Done.
| |
284 */ | |
285 class ServerErrorMessage { | |
286 final Map message; | |
287 | |
288 ServerErrorMessage(this.message); | |
289 | |
290 dynamic get error => message['error']; | |
291 } | |
292 | |
293 /** | |
283 * Wrapper class for Matcher which doesn't create the underlying Matcher object | 294 * Wrapper class for Matcher which doesn't create the underlying Matcher object |
284 * until it is needed. This is necessary in order to create matchers that can | 295 * until it is needed. This is necessary in order to create matchers that can |
285 * refer to themselves (so that recursive data structures can be represented). | 296 * refer to themselves (so that recursive data structures can be represented). |
286 */ | 297 */ |
287 class LazyMatcher implements Matcher { | 298 class LazyMatcher implements Matcher { |
288 /** | 299 /** |
289 * Callback that will be used to create the matcher the first time it is | 300 * Callback that will be used to create the matcher the first time it is |
290 * needed. | 301 * needed. |
291 */ | 302 */ |
292 final MatcherCreator _creator; | 303 final MatcherCreator _creator; |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
570 if (messageAsMap.containsKey('id')) { | 581 if (messageAsMap.containsKey('id')) { |
571 outOfTestExpect(messageAsMap['id'], isString); | 582 outOfTestExpect(messageAsMap['id'], isString); |
572 String id = message['id']; | 583 String id = message['id']; |
573 Completer completer = _pendingCommands[id]; | 584 Completer completer = _pendingCommands[id]; |
574 if (completer == null) { | 585 if (completer == null) { |
575 fail('Unexpected response from server: id=$id'); | 586 fail('Unexpected response from server: id=$id'); |
576 } else { | 587 } else { |
577 _pendingCommands.remove(id); | 588 _pendingCommands.remove(id); |
578 } | 589 } |
579 if (messageAsMap.containsKey('error')) { | 590 if (messageAsMap.containsKey('error')) { |
580 // TODO(paulberry): propagate the error info to the completer. | 591 completer.completeError(new ServerErrorMessage(messageAsMap)); |
581 completer.completeError(new UnimplementedError( | |
582 'Server responded with an error: ${JSON.encode(message)}')); | |
583 } else { | 592 } else { |
584 completer.complete(messageAsMap['result']); | 593 completer.complete(messageAsMap['result']); |
585 } | 594 } |
586 // Check that the message is well-formed. We do this after calling | 595 // Check that the message is well-formed. We do this after calling |
587 // completer.complete() or completer.completeError() so that we don't | 596 // completer.complete() or completer.completeError() so that we don't |
588 // stall the test in the event of an error. | 597 // stall the test in the event of an error. |
589 outOfTestExpect(message, isResponse); | 598 outOfTestExpect(message, isResponse); |
590 } else { | 599 } else { |
591 // Message is a notification. It should have an event and possibly | 600 // Message is a notification. It should have an event and possibly |
592 // params. | 601 // params. |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
968 void populateMismatches(item, List<MismatchDescriber> mismatches); | 977 void populateMismatches(item, List<MismatchDescriber> mismatches); |
969 | 978 |
970 /** | 979 /** |
971 * Create a [MismatchDescriber] describing a mismatch with a simple string. | 980 * Create a [MismatchDescriber] describing a mismatch with a simple string. |
972 */ | 981 */ |
973 MismatchDescriber simpleDescription(String description) => | 982 MismatchDescriber simpleDescription(String description) => |
974 (Description mismatchDescription) { | 983 (Description mismatchDescription) { |
975 mismatchDescription.add(description); | 984 mismatchDescription.add(description); |
976 }; | 985 }; |
977 } | 986 } |
OLD | NEW |