@@ -212,6 +212,9 @@ void main() {
212212 await resume ();
213213 }
214214
215+ Future <Event > waitForBreakpoint () =>
216+ stream.firstWhere ((event) => event.kind == EventKind .kPauseBreakpoint);
217+
215218 test ('after edit and hot restart, breakpoint is in new file' , () async {
216219 final oldLog = 'main gen0' ;
217220 final newLog = 'main gen1' ;
@@ -220,14 +223,14 @@ void main() {
220223
221224 await makeEditAndRecompile (mainFile, oldLog, newLog);
222225
226+ final breakpointFuture = waitForBreakpoint ();
227+
223228 await hotRestartAndHandlePausePost ([
224229 (file: mainFile, breakpointMarker: callLogMarker),
225230 ]);
226231
227232 // Should break at `callLog`.
228- await stream.firstWhere (
229- (event) => event.kind == EventKind .kPauseBreakpoint,
230- );
233+ await breakpointFuture;
231234 expect (consoleLogs.contains (newLog), false );
232235 await resumeAndExpectLog (newLog);
233236 });
@@ -244,14 +247,14 @@ void main() {
244247 final newString = "log('$extraLog ');\n $oldString " ;
245248 await makeEditAndRecompile (mainFile, oldString, newString);
246249
250+ var breakpointFuture = waitForBreakpoint ();
251+
247252 await hotRestartAndHandlePausePost ([
248253 (file: mainFile, breakpointMarker: callLogMarker),
249254 ]);
250255
251256 // Should break at `callLog`.
252- await stream.firstWhere (
253- (event) => event.kind == EventKind .kPauseBreakpoint,
254- );
257+ await breakpointFuture;
255258 expect (consoleLogs.contains (extraLog), true );
256259 expect (consoleLogs.contains (genLog), false );
257260 await resumeAndExpectLog (genLog);
@@ -261,14 +264,14 @@ void main() {
261264 // Remove the line we just added.
262265 await makeEditAndRecompile (mainFile, newString, oldString);
263266
267+ breakpointFuture = waitForBreakpoint ();
268+
264269 await hotRestartAndHandlePausePost ([
265270 (file: mainFile, breakpointMarker: callLogMarker),
266271 ]);
267272
268273 // Should break at `callLog`.
269- await stream.firstWhere (
270- (event) => event.kind == EventKind .kPauseBreakpoint,
271- );
274+ await breakpointFuture;
272275 expect (consoleLogs.contains (extraLog), false );
273276 expect (consoleLogs.contains (genLog), false );
274277 await resumeAndExpectLog (genLog);
@@ -301,21 +304,22 @@ void main() {
301304 final newLog = "log('\$ libraryValue');" ;
302305 await makeEditAndRecompile (mainFile, oldLog, newLog);
303306
307+ var breakpointFuture = waitForBreakpoint ();
308+
304309 await hotRestartAndHandlePausePost ([
305310 (file: mainFile, breakpointMarker: callLogMarker),
306311 (file: libFile, breakpointMarker: libValueMarker),
307312 ]);
308313
309314 // Should break at `callLog`.
310- await stream.firstWhere (
311- (event) => event.kind == EventKind .kPauseBreakpoint,
312- );
315+ await breakpointFuture;
313316 expect (consoleLogs.contains (libGenLog), false );
317+
318+ breakpointFuture = waitForBreakpoint ();
319+
314320 await resume ();
315321 // Should break at `libValue`.
316- await stream.firstWhere (
317- (event) => event.kind == EventKind .kPauseBreakpoint,
318- );
322+ await breakpointFuture;
319323 expect (consoleLogs.contains (libGenLog), false );
320324 await resumeAndExpectLog (libGenLog);
321325
0 commit comments