Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
eea60f86
Unverified
Commit
eea60f86
authored
Oct 18, 2022
by
Jesús S Guerrero
Committed by
GitHub
Oct 18, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dependency injection Attach command (#113227)
parent
9995e370
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
283 additions
and
48 deletions
+283
-48
executable.dart
packages/flutter_tools/lib/executable.dart
+11
-1
attach.dart
packages/flutter_tools/lib/src/commands/attach.dart
+51
-22
attach_test.dart
...utter_tools/test/commands.shard/hermetic/attach_test.dart
+179
-21
build_test.dart
...flutter_tools/test/general.shard/commands/build_test.dart
+42
-4
No files found.
packages/flutter_tools/lib/executable.dart
View file @
eea60f86
...
...
@@ -154,7 +154,17 @@ List<FlutterCommand> generateCommands({
],
),
AssembleCommand
(
verboseHelp:
verboseHelp
,
buildSystem:
globals
.
buildSystem
),
AttachCommand
(
verboseHelp:
verboseHelp
),
AttachCommand
(
verboseHelp:
verboseHelp
,
artifacts:
globals
.
artifacts
,
stdio:
globals
.
stdio
,
logger:
globals
.
logger
,
terminal:
globals
.
terminal
,
signals:
globals
.
signals
,
platform:
globals
.
platform
,
processInfo:
globals
.
processInfo
,
fileSystem:
globals
.
fs
,
),
BuildCommand
(
verboseHelp:
verboseHelp
),
ChannelCommand
(
verboseHelp:
verboseHelp
),
CleanCommand
(
verbose:
verbose
),
...
...
packages/flutter_tools/lib/src/commands/attach.dart
View file @
eea60f86
...
...
@@ -12,6 +12,10 @@ import '../base/common.dart';
import
'../base/context.dart'
;
import
'../base/file_system.dart'
;
import
'../base/io.dart'
;
import
'../base/logger.dart'
;
import
'../base/platform.dart'
;
import
'../base/signals.dart'
;
import
'../base/terminal.dart'
;
import
'../build_info.dart'
;
import
'../commands/daemon.dart'
;
import
'../compile.dart'
;
...
...
@@ -19,7 +23,6 @@ import '../daemon.dart';
import
'../device.dart'
;
import
'../device_port_forwarder.dart'
;
import
'../fuchsia/fuchsia_device.dart'
;
import
'../globals.dart'
as
globals
;
import
'../ios/devices.dart'
;
import
'../ios/simulators.dart'
;
import
'../macos/macos_ipad_device.dart'
;
...
...
@@ -58,7 +61,26 @@ import '../vmservice.dart';
/// To attach to a flutter mod running on a fuchsia device, `--module` must
/// also be provided.
class
AttachCommand
extends
FlutterCommand
{
AttachCommand
({
bool
verboseHelp
=
false
,
this
.
hotRunnerFactory
})
{
AttachCommand
({
bool
verboseHelp
=
false
,
HotRunnerFactory
?
hotRunnerFactory
,
required
Artifacts
?
artifacts
,
required
Stdio
stdio
,
required
Logger
logger
,
required
Terminal
terminal
,
required
Signals
signals
,
required
Platform
platform
,
required
ProcessInfo
processInfo
,
required
FileSystem
fileSystem
,
}):
_artifacts
=
artifacts
,
_hotRunnerFactory
=
hotRunnerFactory
??
HotRunnerFactory
(),
_stdio
=
stdio
,
_logger
=
logger
,
_terminal
=
terminal
,
_signals
=
signals
,
_platform
=
platform
,
_processInfo
=
processInfo
,
_fileSystem
=
fileSystem
{
addBuildModeFlags
(
verboseHelp:
verboseHelp
,
defaultToRelease:
false
,
excludeRelease:
true
);
usesTargetOption
();
usesPortOptions
(
verboseHelp:
verboseHelp
);
...
...
@@ -117,10 +139,17 @@ class AttachCommand extends FlutterCommand {
addDdsOptions
(
verboseHelp:
verboseHelp
);
addDevToolsOptions
(
verboseHelp:
verboseHelp
);
usesDeviceTimeoutOption
();
hotRunnerFactory
??=
HotRunnerFactory
();
}
HotRunnerFactory
?
hotRunnerFactory
;
final
HotRunnerFactory
_hotRunnerFactory
;
final
Artifacts
?
_artifacts
;
final
Stdio
_stdio
;
final
Logger
_logger
;
final
Terminal
_terminal
;
final
Signals
_signals
;
final
Platform
_platform
;
final
ProcessInfo
_processInfo
;
final
FileSystem
_fileSystem
;
@override
final
String
name
=
'attach'
;
...
...
@@ -221,7 +250,7 @@ known, it can be explicitly provided to attach via the command-line, e.g.
throwToolExit
(
'Did not find any valid target devices.'
);
}
final
Artifacts
?
overrideArtifacts
=
device
.
artifactOverrides
??
globals
.
artifacts
;
final
Artifacts
?
overrideArtifacts
=
device
.
artifactOverrides
??
_
artifacts
;
await
context
.
run
<
void
>(
body:
()
=>
_attachToDevice
(
device
),
overrides:
<
Type
,
Generator
>{
...
...
@@ -238,12 +267,12 @@ known, it can be explicitly provided to attach via the command-line, e.g.
final
Daemon
?
daemon
=
boolArgDeprecated
(
'machine'
)
?
Daemon
(
DaemonConnection
(
daemonStreams:
DaemonStreams
.
fromStdio
(
globals
.
stdio
,
logger:
globals
.
logger
),
logger:
globals
.
logger
,
daemonStreams:
DaemonStreams
.
fromStdio
(
_stdio
,
logger:
_
logger
),
logger:
_
logger
,
),
notifyingLogger:
(
globals
.
logger
is
NotifyingLogger
)
?
globals
.
logger
as
NotifyingLogger
:
NotifyingLogger
(
verbose:
globals
.
logger
.
isVerbose
,
parent:
globals
.
logger
),
notifyingLogger:
(
_
logger
is
NotifyingLogger
)
?
_
logger
as
NotifyingLogger
:
NotifyingLogger
(
verbose:
_logger
.
isVerbose
,
parent:
_
logger
),
logToStdout:
true
,
)
:
null
;
...
...
@@ -296,9 +325,9 @@ known, it can be explicitly provided to attach via the command-line, e.g.
ipv6:
ipv6
!,
devicePort:
deviceVmservicePort
,
hostPort:
hostVmservicePort
,
logger:
globals
.
logger
,
logger:
_
logger
,
);
globals
.
printStatus
(
'Waiting for a connection from Flutter on
${device.name}
...'
);
_logger
.
printStatus
(
'Waiting for a connection from Flutter on
${device.name}
...'
);
observatoryUri
=
observatoryDiscovery
.
uris
;
// Determine ipv6 status from the scanned logs.
usesIpv6
=
observatoryDiscovery
.
ipv6
;
...
...
@@ -316,7 +345,7 @@ known, it can be explicitly provided to attach via the command-line, e.g.
).
asBroadcastStream
();
}
globals
.
terminal
.
usesTerminalUi
=
daemon
==
null
;
_
terminal
.
usesTerminalUi
=
daemon
==
null
;
try
{
int
?
result
;
...
...
@@ -343,9 +372,9 @@ known, it can be explicitly provided to attach via the command-line, e.g.
device
,
null
,
true
,
globals
.
fs
.
currentDirectory
,
_fileSystem
.
currentDirectory
,
LaunchMode
.
attach
,
globals
.
logger
as
AppRunLogger
,
_
logger
as
AppRunLogger
,
);
}
on
Exception
catch
(
error
)
{
throwToolExit
(
error
.
toString
());
...
...
@@ -366,10 +395,10 @@ known, it can be explicitly provided to attach via the command-line, e.g.
unawaited
(
onAppStart
.
future
.
whenComplete
(()
{
terminalHandler
=
TerminalHandler
(
runner
,
logger:
globals
.
logger
,
terminal:
globals
.
terminal
,
signals:
globals
.
signals
,
processInfo:
globals
.
processInfo
,
logger:
_
logger
,
terminal:
_
terminal
,
signals:
_
signals
,
processInfo:
_
processInfo
,
reportReady:
boolArgDeprecated
(
'report-ready'
),
pidFile:
stringArgDeprecated
(
'pid-file'
),
)
...
...
@@ -389,7 +418,7 @@ known, it can be explicitly provided to attach via the command-line, e.g.
if
(
runner
.
exited
||
!
runner
.
isWaitingForObservatory
)
{
break
;
}
globals
.
printStatus
(
'Waiting for a new connection from Flutter on
${device.name}
...'
);
_logger
.
printStatus
(
'Waiting for a new connection from Flutter on
${device.name}
...'
);
}
}
on
RPCError
catch
(
err
)
{
if
(
err
.
code
==
RPCErrorCodes
.
kServiceDisappeared
)
{
...
...
@@ -422,7 +451,7 @@ known, it can be explicitly provided to attach via the command-line, e.g.
targetModel:
TargetModel
(
stringArgDeprecated
(
'target-model'
)!),
buildInfo:
buildInfo
,
userIdentifier:
userIdentifier
,
platform:
globals
.
platform
,
platform:
_
platform
,
);
flutterDevice
.
observatoryUris
=
observatoryUris
;
final
List
<
FlutterDevice
>
flutterDevices
=
<
FlutterDevice
>[
flutterDevice
];
...
...
@@ -434,7 +463,7 @@ known, it can be explicitly provided to attach via the command-line, e.g.
);
return
buildInfo
.
isDebug
?
hotRunnerFactory
!
.
build
(
?
_hotRunnerFactory
.
build
(
flutterDevices
,
target:
targetFile
,
debuggingOptions:
debuggingOptions
,
...
...
packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart
View file @
eea60f86
This diff is collapsed.
Click to expand it.
packages/flutter_tools/test/general.shard/commands/build_test.dart
View file @
eea60f86
...
...
@@ -4,7 +4,16 @@
import
'package:args/args.dart'
;
import
'package:args/command_runner.dart'
;
import
'package:file/memory.dart'
;
import
'package:flutter_tools/src/artifacts.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/io.dart'
;
import
'package:flutter_tools/src/base/logger.dart'
;
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:flutter_tools/src/base/signals.dart'
;
import
'package:flutter_tools/src/base/terminal.dart'
;
import
'package:flutter_tools/src/build_info.dart'
;
import
'package:flutter_tools/src/build_system/build_system.dart'
;
import
'package:flutter_tools/src/commands/attach.dart'
;
import
'package:flutter_tools/src/commands/build.dart'
;
import
'package:flutter_tools/src/commands/build_aar.dart'
;
...
...
@@ -16,17 +25,33 @@ import 'package:flutter_tools/src/commands/build_linux.dart';
import
'package:flutter_tools/src/commands/build_macos.dart'
;
import
'package:flutter_tools/src/commands/build_web.dart'
;
import
'package:flutter_tools/src/commands/build_windows.dart'
;
import
'package:flutter_tools/src/globals.dart'
as
globals
;
import
'package:flutter_tools/src/runner/flutter_command.dart'
;
import
'package:test/fake.dart'
;
import
'../../src/common.dart'
;
import
'../../src/context.dart'
;
import
'../../src/fakes.dart'
;
class
FakeTerminal
extends
Fake
implements
AnsiTerminal
{
FakeTerminal
({
this
.
stdinHasTerminal
=
true
});
@override
final
bool
stdinHasTerminal
;
}
class
FakeProcessInfo
extends
Fake
implements
ProcessInfo
{
@override
int
maxRss
=
0
;
}
void
main
(
)
{
testUsingContext
(
'All build commands support null safety options'
,
()
{
final
FileSystem
fileSystem
=
MemoryFileSystem
.
test
();
final
Platform
platform
=
FakePlatform
();
final
BufferLogger
logger
=
BufferLogger
.
test
();
final
List
<
FlutterCommand
>
commands
=
<
FlutterCommand
>[
BuildWindowsCommand
(),
BuildLinuxCommand
(
operatingSystemUtils:
globals
.
os
),
BuildLinuxCommand
(
operatingSystemUtils:
FakeOperatingSystemUtils
()
),
BuildMacosCommand
(
verboseHelp:
false
),
BuildWebCommand
(
verboseHelp:
false
),
BuildApkCommand
(),
...
...
@@ -36,9 +61,22 @@ void main() {
BuildAarCommand
(
verboseHelp:
false
),
BuildIOSFrameworkCommand
(
verboseHelp:
false
,
buildSystem:
globals
.
buildSystem
,
buildSystem:
FlutterBuildSystem
(
fileSystem:
fileSystem
,
platform:
platform
,
logger:
logger
,
),
),
AttachCommand
(
artifacts:
Artifacts
.
test
(),
stdio:
FakeStdio
(),
logger:
logger
,
terminal:
FakeTerminal
(),
signals:
Signals
.
test
(),
platform:
platform
,
processInfo:
FakeProcessInfo
(),
fileSystem:
MemoryFileSystem
.
test
(),
),
AttachCommand
(),
];
for
(
final
FlutterCommand
command
in
commands
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment