@@ -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