@@ -10,6 +10,8 @@ import 'package:devtools/src/vm_service_wrapper.dart';
10
10
import 'package:vm_service_lib/vm_service_lib.dart' ;
11
11
import 'package:vm_service_lib/vm_service_lib_io.dart' ;
12
12
13
+ import '../integration_tests/integration.dart' ;
14
+
13
15
class AppFixture {
14
16
AppFixture ._(
15
17
this .process,
@@ -74,7 +76,7 @@ class CliAppFixture extends AppFixture {
74
76
static Future <CliAppFixture > create (String appScriptPath) async {
75
77
final Process process = await Process .start (
76
78
Platform .resolvedExecutable,
77
- < String > ['--observe=0' , appScriptPath],
79
+ < String > ['--observe=0' , '--pause-isolates-on-start' , appScriptPath],
78
80
);
79
81
80
82
final Stream <String > lines =
@@ -103,6 +105,10 @@ class CliAppFixture extends AppFixture {
103
105
104
106
final VM vm = await serviceConnection.getVM ();
105
107
108
+ final Isolate isolate =
109
+ await _waitForIsolate (serviceConnection, 'PauseStart' );
110
+ await serviceConnection.resume (isolate.id);
111
+
106
112
return CliAppFixture ._(
107
113
appScriptPath,
108
114
process,
@@ -113,6 +119,26 @@ class CliAppFixture extends AppFixture {
113
119
);
114
120
}
115
121
122
+ static Future <Isolate > _waitForIsolate (
123
+ VmServiceWrapper serviceConnection,
124
+ String pauseEventKind,
125
+ ) async {
126
+ Isolate foundIsolate;
127
+ await waitFor (() async {
128
+ final vm = await serviceConnection.getVM ();
129
+ final isolates = await Future .wait (
130
+ vm.isolates.map ((ref) => serviceConnection.getIsolate (ref.id)),
131
+ );
132
+ foundIsolate = isolates.firstWhere (
133
+ (isolate) =>
134
+ isolate is Isolate && isolate.pauseEvent.kind == pauseEventKind,
135
+ orElse: () => null ,
136
+ );
137
+ return foundIsolate != null ;
138
+ });
139
+ return foundIsolate;
140
+ }
141
+
116
142
String get scriptSource {
117
143
return File (appScriptPath).readAsStringSync ();
118
144
}
0 commit comments