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
a0b2878e
Unverified
Commit
a0b2878e
authored
Jun 27, 2019
by
Jonah Williams
Committed by
GitHub
Jun 27, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make tool coverage collection resilient to sentinel coverage data (#35186)
parent
24eabe1f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
3 deletions
+65
-3
coverage_collector.dart
packages/flutter_tools/lib/src/test/coverage_collector.dart
+14
-3
coverage_collector_test.dart
packages/flutter_tools/test/coverage_collector_test.dart
+51
-0
No files found.
packages/flutter_tools/lib/src/test/coverage_collector.dart
View file @
a0b2878e
...
...
@@ -184,13 +184,17 @@ class CoverageCollector extends TestWatcher {
}
}
Future
<
Map
<
String
,
dynamic
>>
collect
(
Uri
serviceUri
,
bool
Function
(
String
)
libraryPredicate
)
async
{
final
VMService
vmService
=
await
VMService
.
connect
(
serviceUri
,
compression:
CompressionOptions
.
compressionOff
);
Future
<
VMService
>
_defaultConnect
(
Uri
serviceUri
)
{
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
{
final
VMService
vmService
=
await
connector
(
serviceUri
);
await
vmService
.
getVM
();
return
_getAllCoverage
(
vmService
,
libraryPredicate
);
}
Future
<
Map
<
String
,
dynamic
>>
_getAllCoverage
(
VMService
service
,
bool
Function
(
String
)
libraryPredicate
)
async
{
await
service
.
getVM
();
final
List
<
Map
<
String
,
dynamic
>>
coverage
=
<
Map
<
String
,
dynamic
>>[];
...
...
@@ -203,6 +207,13 @@ Future<Map<String, dynamic>> _getAllCoverage(VMService service, bool Function(St
final
Map
<
String
,
Map
<
String
,
dynamic
>>
sourceReports
=
<
String
,
Map
<
String
,
dynamic
>>{};
// For each ScriptRef loaded into the VM, load the corresponding Script and
// SourceReport object.
// We may receive such objects as
// {type: Sentinel, kind: Collected, valueAsString: <collected>}
// that need to be skipped.
if
(
scriptList
[
'scripts'
]
==
null
)
{
continue
;
}
for
(
Map
<
String
,
dynamic
>
script
in
scriptList
[
'scripts'
])
{
if
(!
libraryPredicate
(
script
[
'uri'
]))
{
continue
;
...
...
packages/flutter_tools/test/coverage_collector_test.dart
0 → 100644
View file @
a0b2878e
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:async'
;
import
'package:flutter_tools/src/base/io.dart'
;
import
'package:flutter_tools/src/test/coverage_collector.dart'
;
import
'package:flutter_tools/src/vmservice.dart'
;
import
'package:mockito/mockito.dart'
;
import
'src/common.dart'
;
void
main
(
)
{
MockVMService
mockVMService
;
setUp
(()
{
mockVMService
=
MockVMService
();
});
test
(
'Coverage collector Can handle coverage sentinenl data'
,
()
async
{
when
(
mockVMService
.
vm
.
isolates
.
first
.
invokeRpcRaw
(
'getScripts'
,
params:
anyNamed
(
'params'
)))
.
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
{
return
mockVMService
;
});
expect
(
result
,
<
String
,
Object
>{
'type'
:
'CodeCoverage'
,
'coverage'
:
<
Object
>[]});
});
}
class
MockVMService
extends
Mock
implements
VMService
{
@override
final
MockVM
vm
=
MockVM
();
}
class
MockVM
extends
Mock
implements
VM
{
@override
final
List
<
MockIsolate
>
isolates
=
<
MockIsolate
>[
MockIsolate
()
];
}
class
MockIsolate
extends
Mock
implements
Isolate
{}
class
MockProcess
extends
Mock
implements
Process
{
final
Completer
<
int
>
completer
=
Completer
<
int
>();
@override
Future
<
int
>
get
exitCode
=>
completer
.
future
;
}
\ No newline at end of file
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