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
53d8cba3
Unverified
Commit
53d8cba3
authored
Jul 12, 2021
by
Jonah Williams
Committed by
GitHub
Jul 12, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] let the logger know about machine mode (#86116)
parent
b1e1dd68
Changes
12
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
155 additions
and
22 deletions
+155
-22
executable.dart
packages/flutter_tools/lib/executable.dart
+11
-6
runner.dart
packages/flutter_tools/lib/runner.dart
+1
-0
logger.dart
packages/flutter_tools/lib/src/base/logger.dart
+19
-0
context_runner.dart
packages/flutter_tools/lib/src/context_runner.dart
+2
-0
analyze_continuously_test.dart
...st/commands.shard/hermetic/analyze_continuously_test.dart
+1
-1
attach_test.dart
...utter_tools/test/commands.shard/hermetic/attach_test.dart
+3
-0
artifact_updater_test.dart
...utter_tools/test/general.shard/artifact_updater_test.dart
+1
-0
logger_test.dart
...es/flutter_tools/test/general.shard/base/logger_test.dart
+110
-15
terminal_test.dart
.../flutter_tools/test/general.shard/base/terminal_test.dart
+4
-0
cmake_project_migration_test.dart
...eneral.shard/migrations/cmake_project_migration_test.dart
+1
-0
downgrade_upgrade_integration_test.dart
...integration.shard/downgrade_upgrade_integration_test.dart
+1
-0
testbed.dart
packages/flutter_tools/test/src/testbed.dart
+1
-0
No files found.
packages/flutter_tools/lib/executable.dart
View file @
53d8cba3
...
...
@@ -77,8 +77,9 @@ Future<void> main(List<String> args) async {
final
bool
muteCommandLogging
=
(
help
||
doctor
)
&&
!
veryVerbose
;
final
bool
verboseHelp
=
help
&&
verbose
;
final
bool
daemon
=
args
.
contains
(
'daemon'
);
final
bool
runMachine
=
(
args
.
contains
(
'--machine'
)
&&
args
.
contains
(
'run'
))
||
(
args
.
contains
(
'--machine'
)
&&
args
.
contains
(
'attach'
));
final
bool
machine
=
args
.
contains
(
'--machine'
);
final
bool
runMachine
=
(
machine
&&
args
.
contains
(
'run'
))
||
(
machine
&&
args
.
contains
(
'attach'
));
// Cache.flutterRoot must be set early because other features use it (e.g.
// enginePath's initializer uses it). This can only work with the real
...
...
@@ -121,10 +122,11 @@ Future<void> main(List<String> args) async {
);
return
loggerFactory
.
createLogger
(
daemon:
daemon
,
m
achine:
runMachine
,
runM
achine:
runMachine
,
verbose:
verbose
&&
!
muteCommandLogging
,
prefixedErrors:
prefixedErrors
,
windows:
globals
.
platform
.
isWindows
,
machine:
machine
,
);
},
},
...
...
@@ -225,9 +227,10 @@ class LoggerFactory {
Logger
createLogger
({
@required
bool
verbose
,
@required
bool
prefixedErrors
,
@required
bool
m
achine
,
@required
bool
runM
achine
,
@required
bool
daemon
,
@required
bool
windows
,
@required
bool
machine
,
})
{
Logger
logger
;
if
(
windows
)
{
...
...
@@ -236,13 +239,15 @@ class LoggerFactory {
stdio:
_stdio
,
outputPreferences:
_outputPreferences
,
stopwatchFactory:
_stopwatchFactory
,
machine:
machine
,
);
}
else
{
logger
=
StdoutLogger
(
terminal:
_terminal
,
stdio:
_stdio
,
outputPreferences:
_outputPreferences
,
stopwatchFactory:
_stopwatchFactory
stopwatchFactory:
_stopwatchFactory
,
machine:
machine
,
);
}
if
(
verbose
)
{
...
...
@@ -254,7 +259,7 @@ class LoggerFactory {
if
(
daemon
)
{
return
NotifyingLogger
(
verbose:
verbose
,
parent:
logger
);
}
if
(
m
achine
)
{
if
(
runM
achine
)
{
return
AppRunLogger
(
parent:
logger
);
}
return
logger
;
...
...
packages/flutter_tools/lib/runner.dart
View file @
53d8cba3
...
...
@@ -226,6 +226,7 @@ Future<String> _doctorText() async {
final
BufferLogger
logger
=
BufferLogger
(
terminal:
globals
.
terminal
,
outputPreferences:
globals
.
outputPreferences
,
machine:
false
,
);
final
Doctor
doctor
=
Doctor
(
logger:
logger
);
...
...
packages/flutter_tools/lib/src/base/logger.dart
View file @
53d8cba3
...
...
@@ -36,6 +36,12 @@ abstract class Logger {
bool
get
hasTerminal
;
/// Whether the current flutter command invocation also contains a `--machine` flag.
///
/// This should be used to elide output to stdout that is not formatted in newline
/// delimited JSON.
bool
get
machine
;
Terminal
get
terminal
;
OutputPreferences
get
_outputPreferences
;
...
...
@@ -159,6 +165,9 @@ class DelegatingLogger implements Logger {
@override
bool
get
quiet
=>
_delegate
.
quiet
;
@override
bool
get
machine
=>
_delegate
.
machine
;
@override
set
quiet
(
bool
value
)
=>
_delegate
.
quiet
=
value
;
...
...
@@ -269,6 +278,7 @@ class StdoutLogger extends Logger {
required
this
.
terminal
,
required
Stdio
stdio
,
required
OutputPreferences
outputPreferences
,
required
this
.
machine
,
StopwatchFactory
stopwatchFactory
=
const
StopwatchFactory
(),
})
:
_stdio
=
stdio
,
...
...
@@ -279,6 +289,8 @@ class StdoutLogger extends Logger {
final
Terminal
terminal
;
@override
final
OutputPreferences
_outputPreferences
;
@override
final
bool
machine
;
final
Stdio
_stdio
;
final
StopwatchFactory
_stopwatchFactory
;
...
...
@@ -443,12 +455,14 @@ class WindowsStdoutLogger extends StdoutLogger {
required
Terminal
terminal
,
required
Stdio
stdio
,
required
OutputPreferences
outputPreferences
,
required
bool
machine
,
StopwatchFactory
stopwatchFactory
=
const
StopwatchFactory
(),
})
:
super
(
terminal:
terminal
,
stdio:
stdio
,
outputPreferences:
outputPreferences
,
stopwatchFactory:
stopwatchFactory
,
machine:
machine
,
);
@override
...
...
@@ -470,6 +484,7 @@ class BufferLogger extends Logger {
BufferLogger
({
required
this
.
terminal
,
required
OutputPreferences
outputPreferences
,
this
.
machine
=
false
,
StopwatchFactory
stopwatchFactory
=
const
StopwatchFactory
(),
})
:
_outputPreferences
=
outputPreferences
,
_stopwatchFactory
=
stopwatchFactory
;
...
...
@@ -478,6 +493,7 @@ class BufferLogger extends Logger {
BufferLogger
.
test
({
Terminal
?
terminal
,
OutputPreferences
?
outputPreferences
,
this
.
machine
=
false
,
})
:
terminal
=
terminal
??
Terminal
.
test
(),
_outputPreferences
=
outputPreferences
??
OutputPreferences
.
test
(),
_stopwatchFactory
=
const
StopwatchFactory
();
...
...
@@ -489,6 +505,9 @@ class BufferLogger extends Logger {
@override
final
Terminal
terminal
;
@override
final
bool
machine
;
final
StopwatchFactory
_stopwatchFactory
;
@override
...
...
packages/flutter_tools/lib/src/context_runner.dart
View file @
53d8cba3
...
...
@@ -273,11 +273,13 @@ Future<T> runInContext<T>(
terminal:
globals
.
terminal
,
stdio:
globals
.
stdio
,
outputPreferences:
globals
.
outputPreferences
,
machine:
false
,
)
:
StdoutLogger
(
terminal:
globals
.
terminal
,
stdio:
globals
.
stdio
,
outputPreferences:
globals
.
outputPreferences
,
machine:
false
,
),
MacOSWorkflow:
()
=>
MacOSWorkflow
(
featureFlags:
featureFlags
,
...
...
packages/flutter_tools/test/commands.shard/hermetic/analyze_continuously_test.dart
View file @
53d8cba3
...
...
@@ -44,7 +44,7 @@ void main() {
platform
=
const
LocalPlatform
();
processManager
=
const
LocalProcessManager
();
terminal
=
AnsiTerminal
(
platform:
platform
,
stdio:
Stdio
());
logger
=
BufferLogger
(
outputPreferences:
OutputPreferences
.
test
(),
terminal:
terminal
);
logger
=
BufferLogger
(
outputPreferences:
OutputPreferences
.
test
(),
terminal:
terminal
,
machine:
false
);
tempDir
=
fileSystem
.
systemTempDirectory
.
createTempSync
(
'flutter_analysis_test.'
);
});
...
...
packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart
View file @
53d8cba3
...
...
@@ -558,6 +558,9 @@ class StreamLogger extends Logger {
@override
bool
get
isVerbose
=>
true
;
@override
bool
get
machine
=>
true
;
@override
void
printError
(
String
message
,
{
...
...
packages/flutter_tools/test/general.shard/artifact_updater_test.dart
View file @
53d8cba3
...
...
@@ -186,6 +186,7 @@ void main() {
terminal:
Terminal
.
test
(
supportsColor:
true
),
stdio:
FakeStdio
(),
outputPreferences:
OutputPreferences
.
test
(),
machine:
false
,
);
final
ArtifactUpdater
artifactUpdater
=
ArtifactUpdater
(
fileSystem:
fileSystem
,
...
...
packages/flutter_tools/test/general.shard/base/logger_test.dart
View file @
53d8cba3
This diff is collapsed.
Click to expand it.
packages/flutter_tools/test/general.shard/base/terminal_test.dart
View file @
53d8cba3
...
...
@@ -16,6 +16,7 @@ void main() {
final
BufferLogger
bufferLogger
=
BufferLogger
(
outputPreferences:
OutputPreferences
.
test
(
wrapText:
true
,
wrapColumn:
40
),
terminal:
TestTerminal
(
platform:
FakePlatform
()..
stdoutSupportsAnsi
=
true
),
machine:
false
,
);
bufferLogger
.
printStatus
(
'0123456789'
*
8
);
...
...
@@ -26,6 +27,7 @@ void main() {
final
BufferLogger
bufferLogger
=
BufferLogger
(
outputPreferences:
OutputPreferences
.
test
(
wrapText:
false
),
terminal:
TestTerminal
(
platform:
FakePlatform
()..
stdoutSupportsAnsi
=
true
),
machine:
false
,
);
final
String
testString
=
'0123456789'
*
20
;
bufferLogger
.
printStatus
(
testString
);
...
...
@@ -124,6 +126,7 @@ void main() {
final
BufferLogger
bufferLogger
=
BufferLogger
(
terminal:
terminalUnderTest
,
outputPreferences:
OutputPreferences
.
test
(),
machine:
false
,
);
terminalUnderTest
.
usesTerminalUi
=
true
;
mockStdInStream
=
Stream
<
String
>.
fromFutures
(<
Future
<
String
>>[
...
...
@@ -148,6 +151,7 @@ void main() {
final
BufferLogger
bufferLogger
=
BufferLogger
(
terminal:
terminalUnderTest
,
outputPreferences:
OutputPreferences
.
test
(),
machine:
false
,
);
terminalUnderTest
.
usesTerminalUi
=
true
;
mockStdInStream
=
Stream
<
String
>.
fromFutures
(<
Future
<
String
>>[
...
...
packages/flutter_tools/test/general.shard/migrations/cmake_project_migration_test.dart
View file @
53d8cba3
...
...
@@ -40,6 +40,7 @@ void main () {
testLogger
=
BufferLogger
(
terminal:
Terminal
.
test
(),
outputPreferences:
OutputPreferences
.
test
(),
machine:
false
,
);
mockCmakeProject
=
FakeCmakeProject
(
managedCmakeFile
);
...
...
packages/flutter_tools/test/integration.shard/downgrade_upgrade_integration_test.dart
View file @
53d8cba3
...
...
@@ -24,6 +24,7 @@ final ProcessUtils processUtils = ProcessUtils(processManager: processManager, l
),
stdio:
stdio
,
outputPreferences:
OutputPreferences
.
test
(
wrapText:
true
),
machine:
false
,
));
final
String
flutterBin
=
fileSystem
.
path
.
join
(
getFlutterRoot
(),
'bin'
,
platform
.
isWindows
?
'flutter.bat'
:
'flutter'
);
...
...
packages/flutter_tools/test/src/testbed.dart
View file @
53d8cba3
...
...
@@ -38,6 +38,7 @@ final Map<Type, Generator> _testbedDefaults = <Type, Generator>{
Logger:
()
=>
BufferLogger
(
terminal:
AnsiTerminal
(
stdio:
globals
.
stdio
,
platform:
globals
.
platform
),
// Danger, using real stdio.
outputPreferences:
OutputPreferences
.
test
(),
machine:
false
,
),
// Allows reading logs and prevents stdout.
OperatingSystemUtils:
()
=>
FakeOperatingSystemUtils
(),
OutputPreferences:
()
=>
OutputPreferences
.
test
(),
// configures BufferLogger to avoid color codes.
...
...
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