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
c9b28338
Unverified
Commit
c9b28338
authored
Jun 27, 2019
by
Jonah Williams
Committed by
GitHub
Jun 27, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ensure test isolate is paused before collecting coverage (#35188)
parent
919dcf53
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
8 deletions
+37
-8
coverage_collector.dart
packages/flutter_tools/lib/src/test/coverage_collector.dart
+32
-6
coverage_collector_test.dart
packages/flutter_tools/test/coverage_collector_test.dart
+1
-1
tool_coverage.dart
packages/flutter_tools/tool/tool_coverage.dart
+4
-1
No files found.
packages/flutter_tools/lib/src/test/coverage_collector.dart
View file @
c9b28338
...
...
@@ -47,16 +47,16 @@ class CoverageCollector extends TestWatcher {
/// has been run to completion so that all coverage data has been recorded.
///
/// The returned [Future] completes when the coverage is collected.
Future
<
void
>
collectCoverageIsolate
(
Uri
observatoryUri
)
async
{
Future
<
void
>
collectCoverageIsolate
(
Uri
observatoryUri
,
String
debugName
)
async
{
assert
(
observatoryUri
!=
null
);
print
Trace
(
'collecting coverage data from
$observatoryUri
...'
);
print
(
'collecting coverage data from
$observatoryUri
...'
);
final
Map
<
String
,
dynamic
>
data
=
await
collect
(
observatoryUri
,
(
String
libraryName
)
{
// If we have a specified coverage directory or could not find the package name, then
// accept all libraries.
return
(
coverageDirectory
!=
null
)
||
(
flutterProject
==
null
)
||
libraryName
.
contains
(
flutterProject
.
manifest
.
appName
);
});
}
,
waitPaused:
true
,
debugName:
debugName
);
if
(
data
==
null
)
{
throw
Exception
(
'Failed to collect coverage.'
);
}
...
...
@@ -185,13 +185,39 @@ class CoverageCollector extends TestWatcher {
}
Future
<
VMService
>
_defaultConnect
(
Uri
serviceUri
)
{
return
VMService
.
connect
(
serviceUri
,
compression:
CompressionOptions
.
compressionOff
);
return
VMService
.
connect
(
serviceUri
,
compression:
CompressionOptions
.
compressionOff
);
}
Future
<
Map
<
String
,
dynamic
>>
collect
(
Uri
serviceUri
,
bool
Function
(
String
)
libraryPredicate
,
[
Future
<
VMService
>
Function
(
Uri
)
connector
=
_defaultConnect
])
async
{
Future
<
Map
<
String
,
dynamic
>>
collect
(
Uri
serviceUri
,
bool
Function
(
String
)
libraryPredicate
,
{
bool
waitPaused
=
false
,
String
debugName
,
Future
<
VMService
>
Function
(
Uri
)
connector
=
_defaultConnect
,
})
async
{
final
VMService
vmService
=
await
connector
(
serviceUri
);
await
vmService
.
getVM
();
final
Isolate
isolate
=
vmService
.
vm
.
isolates
.
firstWhere
((
Isolate
isolate
)
=>
isolate
.
name
==
debugName
);
if
(!
waitPaused
)
{
return
_getAllCoverage
(
vmService
,
libraryPredicate
);
}
const
int
kPollAttempts
=
20
;
int
i
=
0
;
while
(
i
<
kPollAttempts
)
{
await
isolate
.
load
();
if
(
isolate
.
pauseEvent
?.
kind
==
ServiceEvent
.
kPauseStart
)
{
break
;
}
await
Future
<
void
>.
delayed
(
const
Duration
(
milliseconds:
50
));
i
+=
1
;
}
if
(
i
==
kPollAttempts
)
{
print
(
'Isolate
$debugName
was never paused, refusing to collect coverage'
);
return
const
<
String
,
dynamic
>{
'type'
:
'CodeCoverage'
,
'coverage'
:
<
Object
>[]
};
}
print
(
'isolate is paused, collecting coverage...'
);
return
_getAllCoverage
(
vmService
,
libraryPredicate
);
}
...
...
packages/flutter_tools/test/coverage_collector_test.dart
View file @
c9b28338
...
...
@@ -23,7 +23,7 @@ void main() {
.
thenAnswer
((
Invocation
invocation
)
async
{
return
<
String
,
Object
>{
'type'
:
'Sentinel'
,
'kind'
:
'Collected'
,
'valueAsString'
:
'<collected>'
};
});
final
Map
<
String
,
Object
>
result
=
await
collect
(
null
,
(
String
predicate
)
=>
true
,
(
Uri
uri
)
async
{
final
Map
<
String
,
Object
>
result
=
await
collect
(
null
,
(
String
predicate
)
=>
true
,
connector:
(
Uri
uri
)
async
{
return
mockVMService
;
});
...
...
packages/flutter_tools/tool/tool_coverage.dart
View file @
c9b28338
...
...
@@ -77,8 +77,10 @@ class VMPlatform extends PlatformPlugin {
final
dynamic
channel
=
IsolateChannel
<
Object
>.
connectReceive
(
receivePort
)
.
transformStream
(
StreamTransformer
<
Object
,
Object
>.
fromHandlers
(
handleDone:
(
EventSink
<
Object
>
sink
)
async
{
try
{
// Pause the isolate so it is ready for coverage collection.
isolate
.
pause
();
// this will throw if collection fails.
await
coverageCollector
.
collectCoverageIsolate
(
info
.
serverUri
);
await
coverageCollector
.
collectCoverageIsolate
(
info
.
serverUri
,
path
);
}
finally
{
isolate
.
kill
(
priority:
Isolate
.
immediate
);
isolate
=
null
;
...
...
@@ -115,6 +117,7 @@ class VMPlatform extends PlatformPlugin {
return
await
Isolate
.
spawnUri
(
p
.
toUri
(
testPath
),
<
String
>[],
message
,
packageConfig:
p
.
toUri
(
'.packages'
),
checked:
true
,
debugName:
path
,
);
}
...
...
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