Skip to content

Commit

Permalink
chore: incorrect coverage report workaround
Browse files Browse the repository at this point in the history
Sometimes, a coverage report generated by the `aptos move test
--coverage` command will generate a file that contains out of bound
indices. We should ignore such spans.

This should be report in the `aptos-core` repo.
  • Loading branch information
Rqnsom committed Oct 28, 2024
1 parent 3830a21 commit e6eefcb
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions move-mutator/src/coverage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,20 @@ fn merge_spans_after_removing_whitespaces(mut spans: Vec<Span>, source_code: &st
return vec![];
}

let file_len = source_code.len();
let mut new_spans = Vec::with_capacity(spans.len());
let mut curr = spans.remove(0);

'span_loop: for span in spans {
let mut curr_end_index = curr.end().to_usize();

if curr_end_index > file_len {
// TODO: Write an issue in aptos-core for this since this happens in aptos-stdlib.
warn!("coverage report contains out of bound index {curr:?} (file length: {file_len})");
// Ignore such a span and continue.
continue;
}

let src_chars = source_code[curr_end_index..].chars();
for next_char in src_chars {
if next_char != ' ' {
Expand Down

0 comments on commit e6eefcb

Please sign in to comment.