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
ea0ddc94
Unverified
Commit
ea0ddc94
authored
Oct 28, 2022
by
Liam Appelbe
Committed by
GitHub
Oct 28, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix NPE in coverage collector (#114177)
parent
9b59a4e1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
1 deletion
+35
-1
coverage_collector.dart
packages/flutter_tools/lib/src/test/coverage_collector.dart
+1
-1
coverage_collector_test.dart
...ter_tools/test/general.shard/coverage_collector_test.dart
+34
-0
No files found.
packages/flutter_tools/lib/src/test/coverage_collector.dart
View file @
ea0ddc94
...
...
@@ -36,7 +36,7 @@ class CoverageCollector extends TestWatcher {
Set
<
String
>?
libraryNames
;
final
coverage
.
Resolver
?
resolver
;
final
Map
<
String
,
List
<
List
<
int
>>
>
_ignoredLinesInFilesCache
=
<
String
,
List
<
List
<
int
>>
>{};
final
Map
<
String
,
List
<
List
<
int
>>
?>
_ignoredLinesInFilesCache
=
<
String
,
List
<
List
<
int
>>?
>{};
final
TestTimeRecorder
?
testTimeRecorder
;
...
...
packages/flutter_tools/test/general.shard/coverage_collector_test.dart
View file @
ea0ddc94
...
...
@@ -481,6 +481,40 @@ void main() {
}
});
testWithoutContext
(
'Coverage collector respects ignore whole file'
,
()
async
{
Directory
?
tempDir
;
try
{
tempDir
=
Directory
.
systemTemp
.
createTempSync
(
'flutter_coverage_collector_test.'
);
final
File
packagesFile
=
writeFooBarPackagesJson
(
tempDir
);
final
Directory
fooDir
=
Directory
(
'
${tempDir.path}
/foo/'
);
fooDir
.
createSync
();
final
File
fooFile
=
File
(
'
${fooDir.path}
/foo.dart'
);
fooFile
.
writeAsStringSync
(
'hit
\n
nohit but ignored // coverage:ignore-file
\n
hit
\n
'
);
final
String
packagesPath
=
packagesFile
.
path
;
final
CoverageCollector
collector
=
CoverageCollector
(
libraryNames:
<
String
>{
'foo'
,
'bar'
},
verbose:
false
,
packagesPath:
packagesPath
,
resolver:
await
CoverageCollector
.
getResolver
(
packagesPath
)
);
await
collector
.
collectCoverage
(
TestTestDevice
(),
serviceOverride:
createFakeVmServiceHostWithFooAndBar
(
libraryFilters:
<
String
>[
'package:foo/'
,
'package:bar/'
]).
vmService
,
);
final
Map
<
String
,
HitMap
>
gottenHitmap
=
<
String
,
HitMap
>{};
await
collector
.
finalizeCoverage
(
formatter:
(
Map
<
String
,
HitMap
>
hitmap
)
{
gottenHitmap
.
addAll
(
hitmap
);
return
''
;
});
expect
(
gottenHitmap
.
keys
.
toList
()..
sort
(),
<
String
>[
'package:bar/bar.dart'
]);
expect
(
gottenHitmap
[
'package:bar/bar.dart'
]!.
lineHits
,
<
int
,
int
>{
21
:
1
,
32
:
0
,
47
:
1
,
86
:
0
});
}
finally
{
tempDir
?.
deleteSync
(
recursive:
true
);
}
});
testWithoutContext
(
'Coverage collector records test timings when provided TestTimeRecorder'
,
()
async
{
Directory
?
tempDir
;
try
{
...
...
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