| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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=--error_on_bad_type --error_on_bad_override | 4 // VMOptions=--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 'package:observatory/service_io.dart'; | 8 import 'package:observatory/service_io.dart'; |
| 9 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
| 10 import 'service_test_common.dart'; | 10 import 'service_test_common.dart'; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 debugger(); | 25 debugger(); |
| 26 port.send(null); | 26 port.send(null); |
| 27 debugger(); | 27 debugger(); |
| 28 port.send(null); | 28 port.send(null); |
| 29 debugger(); | 29 debugger(); |
| 30 }); | 30 }); |
| 31 dart.Isolate.spawn(isolate, receive.sendPort); | 31 dart.Isolate.spawn(isolate, receive.sendPort); |
| 32 } | 32 } |
| 33 | 33 |
| 34 var tests = [ | 34 var tests = [ |
| 35 (VM vm) async { | 35 hasPausedAtStart, |
| 36 await vm.load(); | 36 (Isolate isolate) async { |
| 37 bool started = false; | |
| 38 int step = 0; | 37 int step = 0; |
| 39 var completer = new Completer(); | 38 var completer = new Completer(); |
| 40 var sub; | 39 var sub; |
| 41 await hasPausedAtStart(vm.isolates[0]); | 40 final Isolate firstIsolate = isolate; |
| 42 sub = await vm.listenEventStream("Debug", (ServiceEvent c) { | 41 Isolate secondIsolate; |
| 42 sub = await isolate.vm.listenEventStream(VM.kDebugStream, (ServiceEvent c) { |
| 43 switch (step) { | 43 switch (step) { |
| 44 case 0: | 44 case 0: |
| 45 expect(c.kind, equals("Resume"), | 45 expect(c.kind, equals("Resume"), |
| 46 reason: "First isolate should resume"); | 46 reason: "First isolate should resume"); |
| 47 expect(c.isolate.id, equals(vm.isolates[0].id), | 47 expect(c.isolate.id, equals(firstIsolate.id), |
| 48 reason: "First isolate should resume"); | 48 reason: "First isolate should resume"); |
| 49 break; | 49 break; |
| 50 case 1: | 50 case 1: |
| 51 expect(c.kind, equals("PauseStart"), | 51 expect(c.kind, equals("PauseStart"), |
| 52 reason: "Second isolate should pause on start"); | 52 reason: "Second isolate should pause on start"); |
| 53 expect(c.isolate.id, equals(vm.isolates[1].id), | 53 expect(c.isolate.id, equals(isolate.vm.isolates[1].id), |
| 54 reason: "Second isolate should pause on start"); | 54 reason: "Second isolate should pause on start"); |
| 55 vm.isolates[1].resume(); | 55 secondIsolate = c.isolate; |
| 56 secondIsolate.resume(); |
| 56 break; | 57 break; |
| 57 case 2: | 58 case 2: |
| 58 expect(c.kind, equals("Resume"), | 59 expect(c.kind, equals("Resume"), |
| 59 reason: "Second isolate should resume"); | 60 reason: "Second isolate should resume"); |
| 60 expect(c.isolate.id, equals(vm.isolates[1].id), | 61 expect(c.isolate.id, equals(secondIsolate.id), |
| 61 reason: "Second isolate should resume"); | 62 reason: "Second isolate should resume"); |
| 62 break; | 63 break; |
| 63 case 3: | 64 case 3: |
| 64 expect(c.kind, equals("PauseBreakpoint"), | 65 expect(c.kind, equals("PauseBreakpoint"), |
| 65 reason: "First isolate should stop at debugger()"); | 66 reason: "First isolate should stop at debugger()"); |
| 66 expect(c.isolate.id, equals(vm.isolates[0].id), | 67 expect(c.isolate.id, equals(firstIsolate.id), |
| 67 reason: "First isolate should stop at debugger()"); | 68 reason: "First isolate should stop at debugger()"); |
| 68 vm.isolates[0].resume(); | 69 firstIsolate.resume(); |
| 69 break; | 70 break; |
| 70 case 4: | 71 case 4: |
| 71 expect(c.kind, equals("Resume"), | 72 expect(c.kind, equals("Resume"), |
| 72 reason: "First isolate should resume (1)"); | 73 reason: "First isolate should resume (1)"); |
| 73 expect(c.isolate.id, equals(vm.isolates[0].id), | 74 expect(c.isolate.id, equals(firstIsolate.id), |
| 74 reason: "First isolate should resume (1)"); | 75 reason: "First isolate should resume (1)"); |
| 75 break; | 76 break; |
| 76 case 5: | 77 case 5: |
| 77 expect(c.kind, equals("PauseBreakpoint"), | 78 expect(c.kind, equals("PauseBreakpoint"), |
| 78 reason: "First & Second isolate should stop at debugger()"); | 79 reason: "First & Second isolate should stop at debugger()"); |
| 79 break; | 80 break; |
| 80 case 6: | 81 case 6: |
| 81 expect(c.kind, equals("PauseBreakpoint"), | 82 expect(c.kind, equals("PauseBreakpoint"), |
| 82 reason: "First & Second isolate should stop at debugger()"); | 83 reason: "First & Second isolate should stop at debugger()"); |
| 83 vm.isolates[1].resume(); | 84 secondIsolate.resume(); |
| 84 break; | 85 break; |
| 85 case 7: | 86 case 7: |
| 86 expect(c.kind, equals("Resume"), | 87 expect(c.kind, equals("Resume"), |
| 87 reason: "Second isolate should resume before the exception"); | 88 reason: "Second isolate should resume before the exception"); |
| 88 expect(c.isolate.id, equals(vm.isolates[1].id), | 89 expect(c.isolate.id, equals(secondIsolate.id), |
| 89 reason: "Second isolate should resume before the exception"); | 90 reason: "Second isolate should resume before the exception"); |
| 90 break; | 91 break; |
| 91 case 8: | 92 case 8: |
| 92 expect(c.kind, equals("PauseExit"), | 93 expect(c.kind, equals("PauseExit"), |
| 93 reason: "Second isolate should exit at the exception"); | 94 reason: "Second isolate should exit at the exception"); |
| 94 expect(c.isolate.id, equals(vm.isolates[1].id), | 95 expect(c.isolate.id, equals(secondIsolate.id), |
| 95 reason: "Second isolate should exit at the exception"); | 96 reason: "Second isolate should exit at the exception"); |
| 96 vm.isolates[0].resume(); | 97 firstIsolate.resume(); |
| 97 break; | 98 break; |
| 98 case 9: | 99 case 9: |
| 99 expect(c.kind, equals("Resume"), | 100 expect(c.kind, equals("Resume"), |
| 100 reason: "First isolate should resume after the exception"); | 101 reason: "First isolate should resume after the exception"); |
| 101 expect(c.isolate.id, equals(vm.isolates[0].id), | 102 expect(c.isolate.id, equals(firstIsolate.id), |
| 102 reason: "First isolate should resume after the exception"); | 103 reason: "First isolate should resume after the exception"); |
| 103 break; | 104 break; |
| 104 case 10: | 105 case 10: |
| 105 expect(c.kind, equals("PauseBreakpoint"), | 106 expect(c.kind, equals("PauseBreakpoint"), |
| 106 reason: "First isolate " | 107 reason: "First isolate " |
| 107 "should stop at debugger() after exception.\n" | 108 "should stop at debugger() after exception.\n" |
| 108 "Probably the second resumed even though it was not expect " | 109 "Probably the second resumed even though it was not expect " |
| 109 "to do it."); | 110 "to do it."); |
| 110 expect(c.isolate.id, equals(vm.isolates[0].id), | 111 expect(c.isolate.id, equals(firstIsolate.id), |
| 111 reason: "First " | 112 reason: "First " |
| 112 "isolate should stop at debugger() after exception.\n" | 113 "isolate should stop at debugger() after exception.\n" |
| 113 "Probably the second resumed even though it was not expect " | 114 "Probably the second resumed even though it was not expect " |
| 114 "to do it."); | 115 "to do it."); |
| 115 completer.complete(); | 116 completer.complete(); |
| 116 break; | 117 break; |
| 117 default: | 118 default: |
| 118 expect(false, isTrue, | 119 fail("Shouldn't get here, the second isolate resumed even though it " |
| 119 reason: "Shouldn't get here, the second " | 120 "was not expect to do it"); |
| 120 "isolate resumed even though it was not expect to do it"); | |
| 121 break; | 121 break; |
| 122 } | 122 } |
| 123 step++; | 123 step++; |
| 124 }); | 124 }); |
| 125 vm.isolates[0].resume(); | 125 firstIsolate.resume(); |
| 126 await completer.future; | 126 await completer.future; |
| 127 // We wait 1 second to account for delays in the service protocol. | 127 // We wait 1 second to account for delays in the service protocol. |
| 128 // A late message can still arrive. | 128 // A late message can still arrive. |
| 129 await new Future.delayed(const Duration(seconds: 1)); | 129 await new Future.delayed(const Duration(seconds: 1)); |
| 130 // No fails, tear down the stream. | 130 // No fails, tear down the stream. |
| 131 sub.cancel(); | 131 sub.cancel(); |
| 132 } | 132 } |
| 133 ]; | 133 ]; |
| 134 | 134 |
| 135 main(args) async => runVMTests(args, tests, | 135 main(args) async => runIsolateTests(args, tests, |
| 136 pause_on_start: true, pause_on_exit: true, testeeConcurrent: test); | 136 pause_on_start: true, pause_on_exit: true, testeeConcurrent: test); |
| OLD | NEW |