Skip to content

Commit

Permalink
Fix BRDA syntax in lcov files #517
Browse files Browse the repository at this point in the history
  • Loading branch information
Victowolf committed Mar 7, 2025
1 parent d126883 commit da955fd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
5 changes: 5 additions & 0 deletions pkgs/coverage/dart_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.

timeout: 2m
15 changes: 11 additions & 4 deletions pkgs/coverage/lib/src/formatter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,17 @@ extension FileHitMapsFormatter on Map<String, HitMap> {
buf.write('LF:${lineHits.length}\n');
buf.write('LH:${lineHits.values.where((v) => v > 0).length}\n');
if (branchHits != null) {
for (final k in branchHits.keys.toList()..sort()) {
buf.write('BRDA:$k,0,0,${branchHits[k]}\n');
}
}
for (final line in branchHits.keys.toList()..sort()) {
final taken = branchHits[line] ?? 0; // The execution count for this branch

// If we don't have block & branch IDs, default them to 0
const blockId = 0;
const branchId = 0;

buf.write('BRDA:$line,$blockId,$branchId,$taken\n');
}
}

buf.write('end_of_record\n');
}

Expand Down

0 comments on commit da955fd

Please sign in to comment.