Skip to content

Commit 473eb87

Browse files
committed
Address review comments about removed breakpoints and move expectations of console logs after resume to use a future instead
1 parent 6759806 commit 473eb87

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

dwds/test/hot_restart_breakpoints_test.dart

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,23 @@ void main() {
150150
await client.resume(isolate.id!);
151151
}
152152

153+
// When the program is executing, we want to check that at some point it
154+
// will execute code that will emit [expectedString].
155+
Future<void> resumeAndExpectLog(String expectedString) async {
156+
final completer = Completer<void>();
157+
final newSubscription = context.webkitDebugger.onConsoleAPICalled.listen((
158+
e,
159+
) {
160+
if (e.args.first.value == expectedString) {
161+
completer.complete();
162+
}
163+
});
164+
await resume();
165+
await completer.future.then((_) {
166+
newSubscription.cancel();
167+
});
168+
}
169+
153170
Future<void> hotRestartAndHandlePausePost(
154171
List<({String file, String breakpointMarker})> breakpoints,
155172
) async {
@@ -182,6 +199,10 @@ void main() {
182199
// reregister breakpoints (which will be registered in the new files), and
183200
// resume.
184201
await waitForPausePost;
202+
// Verify DWDS has already removed the breakpoints at this point.
203+
final vm = await client.getVM();
204+
final isolate = await service.getIsolate(vm.isolates!.first.id!);
205+
expect(isolate.breakpoints, isEmpty);
185206
for (final breakpoint in breakpoints) {
186207
await addBreakpoint(
187208
file: breakpoint.file,
@@ -208,8 +229,7 @@ void main() {
208229
(event) => event.kind == EventKind.kPauseBreakpoint,
209230
);
210231
expect(consoleLogs.contains(newLog), false);
211-
await resume();
212-
expect(consoleLogs.contains(newLog), true);
232+
await resumeAndExpectLog(newLog);
213233
});
214234

215235
test('after adding line, hot restart, removing line, and hot restart, '
@@ -234,8 +254,7 @@ void main() {
234254
);
235255
expect(consoleLogs.contains(extraLog), true);
236256
expect(consoleLogs.contains(genLog), false);
237-
await resume();
238-
expect(consoleLogs.contains(genLog), true);
257+
await resumeAndExpectLog(genLog);
239258

240259
consoleLogs.clear();
241260

@@ -252,8 +271,7 @@ void main() {
252271
);
253272
expect(consoleLogs.contains(extraLog), false);
254273
expect(consoleLogs.contains(genLog), false);
255-
await resume();
256-
expect(consoleLogs.contains(genLog), true);
274+
await resumeAndExpectLog(genLog);
257275
});
258276

259277
test(
@@ -299,8 +317,7 @@ void main() {
299317
(event) => event.kind == EventKind.kPauseBreakpoint,
300318
);
301319
expect(consoleLogs.contains(libGenLog), false);
302-
await resume();
303-
expect(consoleLogs.contains(libGenLog), true);
320+
await resumeAndExpectLog(libGenLog);
304321

305322
context.removeLibraryFile(libFileName: libFile);
306323
},

0 commit comments

Comments
 (0)