Skip to content

Commit

Permalink
Use program during attach if provided (#118130)
Browse files Browse the repository at this point in the history
  • Loading branch information
helin24 committed Jan 9, 2023
1 parent 5bf6357 commit 46e48ba
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ class FlutterDebugAdapter extends FlutterBaseDebugAdapter {
customTool: args.customTool,
customToolReplacesArgs: args.customToolReplacesArgs,
userToolArgs: args.toolArgs,
targetProgram: args.program,
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class FlutterAttachRequestArguments
this.customTool,
this.customToolReplacesArgs,
this.vmServiceUri,
this.program,
super.restart,
super.name,
super.cwd,
Expand All @@ -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) =>
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 46e48ba

Please sign in to comment.