Skip to content

Commit

Permalink
Merge af5a4ac into 842ea7a
Browse files Browse the repository at this point in the history
  • Loading branch information
kevmoo committed Feb 4, 2020
2 parents 842ea7a + af5a4ac commit 057bd25
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,7 @@
## 0.13.6-dev

* `format_coverage`: read all `.json` files when a directory is given as input.

## 0.13.5 - 2020-01-30

* Update `parseChromeCoverage` to merge coverage information for a given line.
Expand Down
2 changes: 0 additions & 2 deletions analysis_options.yaml
Expand Up @@ -13,8 +13,6 @@ analyzer:
errors:
# treat missing required parameters as a warning (not a hint)
missing_required_param: warning
# allow type narrowing
strong_mode_down_cast_composite: ignore
# allow having TODOs in the code
todo: ignore

Expand Down
3 changes: 2 additions & 1 deletion bin/format_coverage.dart
Expand Up @@ -220,7 +220,8 @@ Environment parseArgs(List<String> arguments) {
/// are contained by it if it is a directory, or a [List] containing the file if
/// it is a file.
List<File> filesToProcess(String absPath) {
final filePattern = RegExp(r'^dart-cov-\d+-\d+.json$');
print(absPath);
final filePattern = RegExp(r'^.*\.json$');
if (FileSystemEntity.isDirectorySync(absPath)) {
return Directory(absPath)
.listSync(recursive: true)
Expand Down
4 changes: 3 additions & 1 deletion lib/src/resolver.dart
Expand Up @@ -157,7 +157,9 @@ class Loader {
/// Returns `null` if the resource could not be loaded.
Future<List<String>> load(String path) async {
try {
return File(path).readAsLines();
final lines = await File(path).readAsLines();
// ensure we await `readAsLines` within the try block so errors are caught
return lines;
} catch (_) {
failed.add(path);
return null;
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
@@ -1,5 +1,5 @@
name: coverage
version: 0.13.5
version: 0.13.6-dev
description: Coverage data manipulation and formatting
homepage: https://github.com/dart-lang/coverage

Expand Down
7 changes: 3 additions & 4 deletions test/chrome_test.dart
Expand Up @@ -28,18 +28,17 @@ Future<Uri> sourceUriProvider(String sourceUrl, String scriptId) async =>

void main() {
test('reports correctly', () async {
final preciseCoverage = json.decode(
final List preciseCoverage = json.decode(
await File('test/test_files/chrome_precise_report.txt').readAsString());

final report = await parseChromeCoverage(
// ignore: avoid_as
(preciseCoverage as List).cast(),
preciseCoverage.cast(),
sourceProvider,
sourceMapProvider,
sourceUriProvider,
);

final sourceReport = report['coverage'].firstWhere(
final Map sourceReport = report['coverage'].firstWhere(
(Map<String, dynamic> report) =>
report['source'].toString().contains('main_test.dart'));

Expand Down

0 comments on commit 057bd25

Please sign in to comment.