From 26b3a60b492978b6214a16c8abccb83689ef4ff6 Mon Sep 17 00:00:00 2001 From: Tess Strickland Date: Fri, 24 Oct 2025 07:43:29 -0700 Subject: [PATCH] [pkg/vm_service] Standardize stop printing in checkRecordedStops. If debugPrintFile and debugPrintLine are provided, provide the stop lines to the failure expect in the same format as the recorded stops are printed when debugPrint is true. Add additional debug output that lists which stops were matched and which recorded stops were skipped, and add a reason to the failure expect that includes the expected and recorded stop indices. TEST=ci Change-Id: If6974a23de72a1922d64937303816c96f646199c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/457380 Commit-Queue: Tess Strickland Reviewed-by: Ben Konyi --- .../test/common/service_test_common.dart | 51 ++++++++++++------- 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/pkg/vm_service/test/common/service_test_common.dart b/pkg/vm_service/test/common/service_test_common.dart index c16f7d564ef..dca7487cd65 100644 --- a/pkg/vm_service/test/common/service_test_common.dart +++ b/pkg/vm_service/test/common/service_test_common.dart @@ -550,26 +550,30 @@ IsolateTest checkRecordedStops( String? debugPrintFile, int? debugPrintLine, }) { + String formatLine(String line) { + String output = line; + if (debugPrintFile != null && debugPrintLine != null) { + final int firstColon = line.indexOf(':'); + final int lastColon = line.lastIndexOf(':'); + if (firstColon > 0 && lastColon > 0) { + final int lineNumber = + int.parse(line.substring(firstColon + 1, lastColon)); + final int relativeLineNumber = lineNumber - debugPrintLine; + final columnNumber = line.substring(lastColon + 1); + final file = line.substring(0, firstColon); + if (file == debugPrintFile) { + output = '\$file:\${LINE+$relativeLineNumber}:$columnNumber'; + } + } + } + return output; + } + return (VmService service, IsolateRef isolate) async { if (debugPrint) { for (int i = 0; i < recordStops.length; i++) { - final String line = recordStops[i]; - String output = line; - final int firstColon = line.indexOf(':'); - final int lastColon = line.lastIndexOf(':'); - if (debugPrintFile != null && - debugPrintLine != null && - firstColon > 0 && - lastColon > 0) { - final int lineNumber = - int.parse(line.substring(firstColon + 1, lastColon)); - final int relativeLineNumber = lineNumber - debugPrintLine; - final columnNumber = line.substring(lastColon + 1); - final file = line.substring(0, firstColon); - if (file == debugPrintFile) { - output = '\$file:\${LINE+$relativeLineNumber}:$columnNumber'; - } - } + final line = recordStops[i]; + final output = formatLine(line); final String comma = i == recordStops.length - 1 ? '' : ','; print("'$output'$comma"); } @@ -592,12 +596,23 @@ IsolateTest checkRecordedStops( } if (k < recordStops.length) { // Allow and ignore extra recorded stops from i to k-1. + if (debugPrint) { + print('Skipping recorded stops [$i, $k)'); + } i = k; } else { // This will report an error. - expect(recordStops[i], expectedStops[j]); + expect( + formatLine(recordStops[i]), + formatLine(expectedStops[j]), + reason: 'Recorded stop $i does not match expected stop $j.', + ); } } + if (debugPrint) { + print('Recorded stop $i matches expected stop $j: ' + '${formatLine(recordStops[i])}'); + } i++; j++; }