Unverified Commit 46e48ba3 authored by Helin Shiah's avatar Helin Shiah Committed by GitHub

Use program during attach if provided (#118130)

parent 5bf6357d
......@@ -148,6 +148,7 @@ class FlutterDebugAdapter extends FlutterBaseDebugAdapter {
customTool: args.customTool,
customToolReplacesArgs: args.customToolReplacesArgs,
userToolArgs: args.toolArgs,
targetProgram: args.program,
);
}
......
......@@ -17,6 +17,7 @@ class FlutterAttachRequestArguments
this.customTool,
this.customToolReplacesArgs,
this.vmServiceUri,
this.program,
super.restart,
super.name,
super.cwd,
......@@ -35,6 +36,7 @@ class FlutterAttachRequestArguments
customTool = obj['customTool'] as String?,
customToolReplacesArgs = obj['customToolReplacesArgs'] as int?,
vmServiceUri = obj['vmServiceUri'] as String?,
program = obj['program'] as String?,
super.fromMap();
static FlutterAttachRequestArguments fromJson(Map<String, Object?> obj) =>
......@@ -64,6 +66,9 @@ class FlutterAttachRequestArguments
/// The VM Service URI of the running Flutter app to connect to.
final String? vmServiceUri;
/// The program/Flutter app to be run.
final String? program;
@override
Map<String, Object?> toJson() => <String, Object?>{
...super.toJson(),
......@@ -151,7 +156,8 @@ class FlutterLaunchRequestArguments
if (args != null) 'args': args,
if (toolArgs != null) 'toolArgs': toolArgs,
if (customTool != null) 'customTool': customTool,
if (customToolReplacesArgs != null) 'customToolReplacesArgs': customToolReplacesArgs,
if (customToolReplacesArgs != null)
'customToolReplacesArgs': customToolReplacesArgs,
};
static FlutterLaunchRequestArguments fromJson(Map<String, Object?> obj) =>
......
......@@ -209,6 +209,34 @@ void main() {
expect(adapter.processArgs, containsAllInOrder(<String>['attach', '--machine']));
});
test('runs "flutter attach" with program if passed in', () async {
final MockFlutterDebugAdapter adapter = MockFlutterDebugAdapter(
fileSystem: MemoryFileSystem.test(style: fsStyle),
platform: platform,
);
final Completer<void> responseCompleter = Completer<void>();
final FlutterAttachRequestArguments args =
FlutterAttachRequestArguments(
cwd: '/project',
program: 'program/main.dart',
);
await adapter.configurationDoneRequest(MockRequest(), null, () {});
await adapter.attachRequest(
MockRequest(), args, responseCompleter.complete);
await responseCompleter.future;
expect(
adapter.processArgs,
containsAllInOrder(<String>[
'attach',
'--machine',
'--target',
'program/main.dart'
]));
});
test('does not record the VMs PID for terminating', () async {
final MockFlutterDebugAdapter adapter = MockFlutterDebugAdapter(
fileSystem: MemoryFileSystem.test(style: fsStyle),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment