Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 8387c23

Browse files
authored
[flutter_tools] Use base DAP detach and ensure correct output (#119076)
1 parent 22bbdf0 commit 8387c23

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

packages/flutter_tools/lib/src/debug_adapters/flutter_adapter.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ class FlutterDebugAdapter extends FlutterBaseDebugAdapter {
354354
@override
355355
Future<void> terminateImpl() async {
356356
if (isAttach) {
357-
await preventBreakingAndResume();
357+
await handleDetach();
358358
}
359359

360360
// Send a request to stop/detach to give Flutter chance to do some cleanup.

packages/flutter_tools/lib/src/debug_adapters/flutter_base_adapter.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ abstract class FlutterBaseDebugAdapter extends DartDebugAdapter<FlutterLaunchReq
122122
@override
123123
Future<void> disconnectImpl() async {
124124
if (isAttach) {
125-
await preventBreakingAndResume();
125+
await handleDetach();
126126
}
127127
terminatePids(ProcessSignal.sigkill);
128128
}

packages/flutter_tools/test/integration.shard/debug_adapter/flutter_adapter_test.dart

+11-4
Original file line numberDiff line numberDiff line change
@@ -561,11 +561,18 @@ void main() {
561561
dap.client.setBreakpoint(breakpointFilePath, breakpointLine),
562562
], eagerError: true);
563563

564-
// Detach.
565-
await dap.client.terminate();
564+
// Detach and expected resume and correct output.
565+
await Future.wait(<Future<void>>[
566+
// We should print "Detached" instead of "Exited".
567+
dap.client.outputEvents.firstWhere((OutputEventBody event) => event.output.contains('\nDetached')),
568+
// We should still get terminatedEvent (this signals the DAP server terminating).
569+
dap.client.event('terminated'),
570+
// We should get output showing the app resumed.
571+
testProcess.output.firstWhere((String output) => output.contains('topLevelFunction')),
572+
// Trigger the detach.
573+
dap.client.terminate(),
574+
]);
566575

567-
// Ensure we get additional output (confirming the process resumed).
568-
await testProcess.output.first;
569576
});
570577
});
571578
}

0 commit comments

Comments
 (0)