Skip to content

Commit b414e4e

Browse files
committed
Add and fix up many files tests
1 parent 9c58396 commit b414e4e

File tree

2 files changed

+54
-4
lines changed

2 files changed

+54
-4
lines changed

dwds/test/hot_reload_breakpoints_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ void main() {
351351

352352
// Add a library file, import it, and then refer to it in the log.
353353
final libFile = 'library.dart';
354-
final libGenLog = 'lib gen0';
354+
final libGenLog = 'library gen0';
355355
final libValueMarker = 'libValue';
356356
context.addLibraryFile(
357357
libFileName: libFile,
@@ -415,7 +415,7 @@ void main() {
415415
context.addLibraryFile(
416416
libFileName: libFile,
417417
contents: '''String get libraryValue$i {
418-
return 'lib gen$i'; // Breakpoint: libValue$i
418+
return 'library$i gen1'; // Breakpoint: libValue$i
419419
}''',
420420
);
421421
final oldImports = "import 'dart:js_interop';";
@@ -449,7 +449,7 @@ void main() {
449449
await resume();
450450
// Should break at the breakpoint in the last file.
451451
await breakpointFuture;
452-
await resumeAndExpectLog('lib gen$numFiles');
452+
await resumeAndExpectLog('library$numFiles gen1');
453453
});
454454

455455
test('breakpoint in captured code is deleted', () async {

dwds/test/hot_restart_breakpoints_test.dart

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ void main() {
281281

282282
// Add a library file, import it, and then refer to it in the log.
283283
final libFile = 'library.dart';
284-
final libGenLog = 'lib gen0';
284+
final libGenLog = 'library gen0';
285285
final libValueMarker = 'libValue';
286286
context.addLibraryFile(
287287
libFileName: libFile,
@@ -318,6 +318,56 @@ void main() {
318318
await resumeAndExpectLog(libGenLog);
319319
},
320320
);
321+
322+
// Test that we wait for all scripts to be parsed first before computing
323+
// location metadata.
324+
test('after adding many files and putting breakpoint in the last one,'
325+
'breakpoint is correctly registered', () async {
326+
final genLog = 'main gen0';
327+
328+
await addBreakpoint(file: mainFile, breakpointMarker: callLogMarker);
329+
330+
// Add library files, import them, but only refer to the last one in main.
331+
final numFiles = 50;
332+
for (var i = 1; i <= numFiles; i++) {
333+
final libFile = 'library$i.dart';
334+
context.addLibraryFile(
335+
libFileName: libFile,
336+
contents: '''String get libraryValue$i {
337+
return 'library$i gen1'; // Breakpoint: libValue$i
338+
}''',
339+
);
340+
final oldImports = "import 'dart:js_interop';";
341+
final newImports =
342+
'$oldImports\n'
343+
"import 'package:_test_hot_restart_breakpoints/$libFile';";
344+
makeEdit(mainFile, oldImports, newImports);
345+
}
346+
final oldLog = "log('$genLog');";
347+
final newLog = "log('\$libraryValue$numFiles');";
348+
await makeEditAndRecompile(mainFile, oldLog, newLog);
349+
350+
var breakpointFuture = waitForBreakpoint();
351+
352+
await hotRestartAndHandlePausePost([
353+
(file: mainFile, breakpointMarker: callLogMarker),
354+
(file: 'library$numFiles.dart', breakpointMarker: 'libValue$numFiles'),
355+
]);
356+
357+
final newGenLog = 'library$numFiles gen1';
358+
359+
// Should break at `callLog`.
360+
await breakpointFuture;
361+
expect(consoleLogs.contains(newGenLog), false);
362+
363+
breakpointFuture = waitForBreakpoint();
364+
365+
await resume();
366+
// Should break at the breakpoint in the last file.
367+
await breakpointFuture;
368+
expect(consoleLogs.contains(newGenLog), false);
369+
await resumeAndExpectLog(newGenLog);
370+
});
321371
});
322372
}
323373

0 commit comments

Comments
 (0)