Skip to content

Commit e3bf6f6

Browse files
authored
Handle file URIs during coverage collection (#1210)
Closes #1214
1 parent 5203b23 commit e3bf6f6

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

pkgs/test/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
## 1.14.3-dev
22

33
* Fix an issue where coverage tests could not run in Chrome headless.
4+
* Fix an issue where coverage collection would not work with source
5+
maps that contained absolute file URIs.
46

57
## 1.14.2
68

pkgs/test/lib/src/runner/browser/chrome.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,16 @@ class Chrome extends Browser {
119119
Future<Uri> _sourceUriProvider(String sourceUrl, String scriptId) async {
120120
var script = _idToUrl[scriptId];
121121
if (script == null) return null;
122+
var sourceUri = Uri.parse(sourceUrl);
123+
if (sourceUri.scheme == 'file') return sourceUri;
124+
// If the provided sourceUrl is relative, determine the package path.
122125
var uri = Uri.parse(script);
123126
var path = p.join(
124127
p.joinAll(uri.pathSegments.sublist(1, uri.pathSegments.length - 1)),
125128
sourceUrl);
126129
return path.contains('/packages/')
127130
? Uri(scheme: 'package', path: path.split('/packages/').last)
128-
: Uri.file(p.absolute(path));
131+
: null;
129132
}
130133

131134
Future<String> _sourceMapProvider(String scriptId) async {

0 commit comments

Comments
 (0)