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
f9c58bea
Unverified
Commit
f9c58bea
authored
Apr 05, 2020
by
Jonah Williams
Committed by
GitHub
Apr 05, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] also listen to web stderr stream (#53949)
parent
f5fe1e3e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
9 deletions
+27
-9
resident_web_runner.dart
...utter_tools/lib/src/build_runner/resident_web_runner.dart
+9
-5
resident_web_runner_test.dart
...er_tools/test/general.shard/resident_web_runner_test.dart
+18
-4
No files found.
packages/flutter_tools/lib/src/build_runner/resident_web_runner.dart
View file @
f9c58bea
...
...
@@ -107,6 +107,7 @@ abstract class ResidentWebRunner extends ResidentRunner {
ConnectionResult
_connectionResult
;
StreamSubscription
<
vmservice
.
Event
>
_stdOutSub
;
StreamSubscription
<
vmservice
.
Event
>
_stdErrSub
;
bool
_exited
=
false
;
WipConnection
_wipConnection
;
...
...
@@ -143,6 +144,7 @@ abstract class ResidentWebRunner extends ResidentRunner {
return
;
}
await
_stdOutSub
?.
cancel
();
await
_stdErrSub
?.
cancel
();
await
device
.
device
.
stopApp
(
null
);
try
{
_generatedEntrypointDirectory
?.
deleteSync
(
recursive:
true
);
...
...
@@ -652,16 +654,14 @@ class _ResidentWebRunner extends ResidentWebRunner {
_connectionResult
=
await
webDevFS
.
connect
(
useDebugExtension
);
unawaited
(
_connectionResult
.
debugConnection
.
onDone
.
whenComplete
(
_cleanupAndExit
));
// Cleanup old subscriptions. These will throw if there isn't anything
// listening, which is fine because that is what we want to ensure.
try
{
await
_vmService
.
stream
Cancel
(
vmservice
.
EventStreams
.
kStdout
);
await
_vmService
.
stream
Listen
(
vmservice
.
EventStreams
.
kStdout
);
}
on
vmservice
.
RPCError
{
// It is safe to ignore this error because we expect an error to be
// thrown if we're not already subscribed.
}
try
{
await
_vmService
.
streamListen
(
vmservice
.
EventStreams
.
kStd
out
);
await
_vmService
.
streamListen
(
vmservice
.
EventStreams
.
kStd
err
);
}
on
vmservice
.
RPCError
{
// It is safe to ignore this error because we expect an error to be
// thrown if we're not already subscribed.
...
...
@@ -674,7 +674,11 @@ class _ResidentWebRunner extends ResidentWebRunner {
}
_stdOutSub
=
_vmService
.
onStdoutEvent
.
listen
((
vmservice
.
Event
log
)
{
final
String
message
=
utf8
.
decode
(
base64
.
decode
(
log
.
bytes
));
globals
.
printStatus
(
message
);
globals
.
printStatus
(
message
,
newline:
false
);
});
_stdErrSub
=
_vmService
.
onStderrEvent
.
listen
((
vmservice
.
Event
log
)
{
final
String
message
=
utf8
.
decode
(
base64
.
decode
(
log
.
bytes
));
globals
.
printStatus
(
message
,
newline:
false
);
});
unawaited
(
_vmService
.
registerService
(
'reloadSources'
,
'FlutterTools'
));
_vmService
.
registerServiceCallback
(
'reloadSources'
,
(
Map
<
String
,
Object
>
params
)
async
{
...
...
packages/flutter_tools/test/general.shard/resident_web_runner_test.dart
View file @
f9c58bea
...
...
@@ -116,6 +116,9 @@ void main() {
when
(
mockVmService
.
onStdoutEvent
).
thenAnswer
((
Invocation
_
)
{
return
const
Stream
<
Event
>.
empty
();
});
when
(
mockVmService
.
onStderrEvent
).
thenAnswer
((
Invocation
_
)
{
return
const
Stream
<
Event
>.
empty
();
});
when
(
mockVmService
.
onDebugEvent
).
thenAnswer
((
Invocation
_
)
{
return
const
Stream
<
Event
>.
empty
();
});
...
...
@@ -249,20 +252,30 @@ void main() {
expect
(
await
residentWebRunner
.
run
(),
0
);
}));
test
(
'Listens to stdout streams before running main'
,
()
=>
testbed
.
run
(()
async
{
test
(
'Listens to stdout
and stderr
streams before running main'
,
()
=>
testbed
.
run
(()
async
{
_setupMocks
();
final
Completer
<
DebugConnectionInfo
>
connectionInfoCompleter
=
Completer
<
DebugConnectionInfo
>();
final
StreamController
<
Event
>
controller
=
StreamController
<
Event
>.
broadcast
();
final
StreamController
<
Event
>
stdoutController
=
StreamController
<
Event
>.
broadcast
();
final
StreamController
<
Event
>
stderrController
=
StreamController
<
Event
>.
broadcast
();
when
(
mockVmService
.
onStdoutEvent
).
thenAnswer
((
Invocation
_
)
{
return
controller
.
stream
;
return
stdoutController
.
stream
;
});
when
(
mockVmService
.
onStderrEvent
).
thenAnswer
((
Invocation
_
)
{
return
stderrController
.
stream
;
});
when
(
mockAppConnection
.
runMain
()).
thenAnswer
((
Invocation
invocation
)
{
c
ontroller
.
add
(
Event
.
parse
(<
String
,
Object
>{
stdoutC
ontroller
.
add
(
Event
.
parse
(<
String
,
Object
>{
'type'
:
'Event'
,
'kind'
:
'WriteEvent'
,
'timestamp'
:
1569473488296
,
'bytes'
:
base64
.
encode
(
'THIS MESSAGE IS IMPORTANT'
.
codeUnits
),
}));
stderrController
.
add
(
Event
.
parse
(<
String
,
Object
>{
'type'
:
'Event'
,
'kind'
:
'WriteEvent'
,
'timestamp'
:
1569473488296
,
'bytes'
:
base64
.
encode
(
'SO IS THIS'
.
codeUnits
),
}));
});
unawaited
(
residentWebRunner
.
run
(
connectionInfoCompleter:
connectionInfoCompleter
,
...
...
@@ -270,6 +283,7 @@ void main() {
await
connectionInfoCompleter
.
future
;
expect
(
testLogger
.
statusText
,
contains
(
'THIS MESSAGE IS IMPORTANT'
));
expect
(
testLogger
.
statusText
,
contains
(
'SO IS THIS'
));
}));
test
(
'Does not run main with --start-paused'
,
()
=>
testbed
.
run
(()
async
{
...
...
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