diff options
author | Valentin Anger <syrupthinker@gryphno.de> | 2020-11-24 22:26:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-24 22:26:38 +0100 |
commit | 605874ee98b52f5de7d1d1284507d5a9cb9eea9d (patch) | |
tree | ab470ecd4e2664d040a70365a640c124c5702c53 /cli/tools/coverage.rs | |
parent | 355d5d3bba1ddcd6a11c786f8aee2b349538e048 (diff) |
feat(test): horizontal separator between disjoint runs of lines (#8484)
Places a newline between non-consecutive line block in coverage
report to improve readability.
Diffstat (limited to 'cli/tools/coverage.rs')
-rw-r--r-- | cli/tools/coverage.rs | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/cli/tools/coverage.rs b/cli/tools/coverage.rs index 85ba3f559..726ce9749 100644 --- a/cli/tools/coverage.rs +++ b/cli/tools/coverage.rs @@ -185,14 +185,28 @@ impl PrettyCoverageReporter { println!("{}", colors::red(&line_coverage)); } + let mut last_line = None; for line_index in uncovered_lines { + const WIDTH: usize = 4; + const SEPERATOR: &str = "|"; + + // Put a horizontal separator between disjoint runs of lines + if let Some(last_line) = last_line { + if last_line + 1 != line_index { + let dash = colors::gray(&"-".repeat(WIDTH + 1)); + println!("{}{}{}", dash, colors::gray(SEPERATOR), dash); + } + } + println!( - "{:width$}{} {}", + "{:width$} {} {}", line_index + 1, - colors::gray(" |"), + colors::gray(SEPERATOR), colors::red(&lines[line_index]), - width = 4 + width = WIDTH ); + + last_line = Some(line_index); } } } |