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 // VMOptions=--compile_all --error_on_bad_type --error_on_bad_override | 4 // VMOptions=--compile_all --error_on_bad_type --error_on_bad_override |
5 | 5 |
6 import 'dart:async'; | 6 import 'dart:async'; |
7 import 'dart:developer'; | 7 import 'dart:developer'; |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 import 'package:observatory/service_io.dart'; | 9 import 'package:observatory/service_io.dart'; |
10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
11 import 'service_test_common.dart'; | 11 import 'service_test_common.dart'; |
12 import 'test_helper.dart'; | 12 import 'test_helper.dart'; |
13 | 13 |
14 void test() { | 14 void test() { |
15 debugger(); | 15 debugger(); |
16 stdout.write('stdout'); | 16 stdout.write('stdout'); |
17 | 17 |
18 debugger(); | 18 debugger(); |
19 print('print'); | 19 print('print'); |
20 | 20 |
21 debugger(); | 21 debugger(); |
22 stderr.write('stderr'); | 22 stderr.write('stderr'); |
23 } | 23 } |
24 | 24 |
25 var tests = [ | 25 var tests = [ |
26 hasStoppedAtBreakpoint, | 26 hasStoppedAtBreakpoint, |
| 27 |
27 (Isolate isolate) async { | 28 (Isolate isolate) async { |
28 Completer completer = new Completer(); | 29 Completer completer = new Completer(); |
29 var stdoutSub; | 30 var stdoutSub; |
30 stdoutSub = await isolate.vm.listenEventStream(VM.kStdoutStream, | 31 stdoutSub = await isolate.vm.listenEventStream( |
31 (ServiceEvent event) { | 32 VM.kStdoutStream, |
32 expect(event.kind, equals('WriteEvent')); | 33 (ServiceEvent event) { |
33 expect(event.bytesAsString, equals('stdout')); | 34 expect(event.kind, equals('WriteEvent')); |
34 stdoutSub.cancel().then((_) { | 35 expect(event.bytesAsString, equals('stdout')); |
35 completer.complete(); | 36 stdoutSub.cancel().then((_) { |
| 37 completer.complete(); |
| 38 }); |
36 }); | 39 }); |
37 }); | |
38 await isolate.resume(); | 40 await isolate.resume(); |
39 await completer.future; | 41 await completer.future; |
40 }, | 42 }, |
| 43 |
41 hasStoppedAtBreakpoint, | 44 hasStoppedAtBreakpoint, |
| 45 |
42 (Isolate isolate) async { | 46 (Isolate isolate) async { |
43 Completer completer = new Completer(); | 47 Completer completer = new Completer(); |
44 var stdoutSub; | 48 var stdoutSub; |
45 int eventNumber = 1; | 49 int eventNumber = 1; |
46 stdoutSub = await isolate.vm.listenEventStream(VM.kStdoutStream, | 50 stdoutSub = await isolate.vm.listenEventStream( |
47 (ServiceEvent event) { | 51 VM.kStdoutStream, |
48 expect(event.kind, equals('WriteEvent')); | 52 (ServiceEvent event) { |
49 if (eventNumber == 1) { | 53 expect(event.kind, equals('WriteEvent')); |
50 expect(event.bytesAsString, equals('print')); | 54 if (eventNumber == 1) { |
51 } else if (eventNumber == 2) { | 55 expect(event.bytesAsString, equals('print')); |
52 expect(event.bytesAsString, equals('\n')); | 56 } else if (eventNumber == 2) { |
53 stdoutSub.cancel().then((_) { | 57 expect(event.bytesAsString, equals('\n')); |
54 completer.complete(); | 58 stdoutSub.cancel().then((_) { |
55 }); | 59 completer.complete(); |
56 } else { | 60 }); |
57 expect(true, false); | 61 } else { |
58 } | 62 expect(true, false); |
59 eventNumber++; | 63 } |
60 }); | 64 eventNumber++; |
| 65 }); |
61 await isolate.resume(); | 66 await isolate.resume(); |
62 await completer.future; | 67 await completer.future; |
63 }, | 68 }, |
| 69 |
64 hasStoppedAtBreakpoint, | 70 hasStoppedAtBreakpoint, |
| 71 |
65 (Isolate isolate) async { | 72 (Isolate isolate) async { |
66 Completer completer = new Completer(); | 73 Completer completer = new Completer(); |
67 var stderrSub; | 74 var stderrSub; |
68 stderrSub = await isolate.vm.listenEventStream(VM.kStderrStream, | 75 stderrSub = await isolate.vm.listenEventStream( |
69 (ServiceEvent event) { | 76 VM.kStderrStream, |
70 expect(event.kind, equals('WriteEvent')); | 77 (ServiceEvent event) { |
71 expect(event.bytesAsString, equals('stderr')); | 78 expect(event.kind, equals('WriteEvent')); |
72 stderrSub.cancel().then((_) { | 79 expect(event.bytesAsString, equals('stderr')); |
73 completer.complete(); | 80 stderrSub.cancel().then((_) { |
| 81 completer.complete(); |
| 82 }); |
74 }); | 83 }); |
75 }); | |
76 await isolate.resume(); | 84 await isolate.resume(); |
77 await completer.future; | 85 await completer.future; |
78 }, | 86 }, |
79 ]; | 87 ]; |
80 | 88 |
| 89 |
81 main(args) => runIsolateTests(args, tests, testeeConcurrent: test); | 90 main(args) => runIsolateTests(args, tests, testeeConcurrent: test); |
OLD | NEW |