[flutter_tools] Use base DAP detach and ensure correct output (#119076)

This commit is contained in:
Danny Tuppeny 2023-02-02 21:28:12 +00:00 committed by GitHub
parent 22bbdf03e0
commit 8387c2388b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 6 deletions

View File

@ -354,7 +354,7 @@ class FlutterDebugAdapter extends FlutterBaseDebugAdapter {
@override @override
Future<void> terminateImpl() async { Future<void> terminateImpl() async {
if (isAttach) { if (isAttach) {
await preventBreakingAndResume(); await handleDetach();
} }
// Send a request to stop/detach to give Flutter chance to do some cleanup. // Send a request to stop/detach to give Flutter chance to do some cleanup.

View File

@ -122,7 +122,7 @@ abstract class FlutterBaseDebugAdapter extends DartDebugAdapter<FlutterLaunchReq
@override @override
Future<void> disconnectImpl() async { Future<void> disconnectImpl() async {
if (isAttach) { if (isAttach) {
await preventBreakingAndResume(); await handleDetach();
} }
terminatePids(ProcessSignal.sigkill); terminatePids(ProcessSignal.sigkill);
} }

View File

@ -561,11 +561,18 @@ void main() {
dap.client.setBreakpoint(breakpointFilePath, breakpointLine), dap.client.setBreakpoint(breakpointFilePath, breakpointLine),
], eagerError: true); ], eagerError: true);
// Detach. // Detach and expected resume and correct output.
await dap.client.terminate(); await Future.wait(<Future<void>>[
// We should print "Detached" instead of "Exited".
dap.client.outputEvents.firstWhere((OutputEventBody event) => event.output.contains('\nDetached')),
// We should still get terminatedEvent (this signals the DAP server terminating).
dap.client.event('terminated'),
// We should get output showing the app resumed.
testProcess.output.firstWhere((String output) => output.contains('topLevelFunction')),
// Trigger the detach.
dap.client.terminate(),
]);
// Ensure we get additional output (confirming the process resumed).
await testProcess.output.first;
}); });
}); });
} }