Skip to content

Commit

Permalink
Clean up: unused imports and commented out code
Browse files Browse the repository at this point in the history
  • Loading branch information
adpaco-aws committed Sep 20, 2024
1 parent 781ba58 commit 7d7ef6c
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 84 deletions.
5 changes: 1 addition & 4 deletions tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,10 +469,7 @@ impl<'test> TestCx<'test> {
let output_lines = proc_res.stdout.split('\n').collect::<Vec<&str>>();
let coverage_info = output_lines.iter().find(|l| l.contains("Coverage results saved to"));
if coverage_info.is_none() {
self.fatal_proc_rec(
"failed to find the path to the coverage results",
proc_res,
);
self.fatal_proc_rec("failed to find the path to the coverage results", proc_res);
}
let coverage_path = coverage_info.unwrap().split(' ').last().unwrap();
PathBuf::from(coverage_path)
Expand Down
31 changes: 1 addition & 30 deletions tools/kani-cov/src/coverage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,33 +31,6 @@ pub struct CombinedCoverageResults {
pub data: BTreeMap<String, Vec<(String, Vec<CovResult>)>>,
}

// pub fn fmt_coverage_results(coverage_results: &CoverageResults) -> Result<String> {
// let mut fmt_string = String::new();
// for (file, checks) in coverage_results.data.iter() {
// let mut checks_by_function: BTreeMap<String, Vec<CoverageCheck>> = BTreeMap::new();

// // // Group checks by function
// for check in checks {
// // Insert the check into the vector corresponding to its function
// checks_by_function
// .entry(check.function.clone())
// .or_insert_with(Vec::new)
// .push(check.clone());
// }

// for (function, checks) in checks_by_function {
// writeln!(fmt_string, "{file} ({function})")?;
// let mut sorted_checks: Vec<CoverageCheck> = checks.to_vec();
// sorted_checks.sort_by(|a, b| a.region.start.cmp(&b.region.start));
// for check in sorted_checks.iter() {
// writeln!(fmt_string, " * {} {}", check.region, check.status)?;
// }
// writeln!(fmt_string, "")?;
// }
// }
// Ok(fmt_string)
// }

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CoverageCheck {
pub function: String,
Expand Down Expand Up @@ -178,16 +151,14 @@ fn function_info_from_node<'a>(node: Node, source: &'a [u8]) -> FunctionInfo {
.to_string();
let start = (node.start_position().row + 1, node.start_position().column + 1);
let end = (node.end_position().row + 1, node.end_position().column + 1);
let num_lines = end.0 - start.0 + 1;
FunctionInfo { name, start, end, num_lines }
FunctionInfo { name, start, end }
}

#[derive(Debug)]
pub struct FunctionInfo {
pub name: String,
pub start: (usize, usize),
pub end: (usize, usize),
pub num_lines: usize,
}

pub fn function_coverage_results(
Expand Down
4 changes: 1 addition & 3 deletions tools/kani-cov/src/merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use std::{
collections::BTreeMap,
fs::{File, OpenOptions},
io::{BufReader, BufWriter, Write},
io::{BufReader, BufWriter},
path::PathBuf,
};

Expand Down Expand Up @@ -91,14 +91,12 @@ fn combine_raw_results(results: &Vec<CoverageResults>) -> CombinedCoverageResult
new_results.push(new_result);
}

// let pair_string = format!("{file_name}+{fun_name}");
let filename_copy = file_name.clone();
if new_data.contains_key(&file_name) {
new_data.get_mut(&filename_copy).unwrap().push((fun_name, new_results));
} else {
new_data.insert(file_name.clone(), vec![(fun_name, new_results)]);
}
// new_data.insert(file_name, (fun_name, new_results));
}
CombinedCoverageResults { data: new_data }
}
Expand Down
49 changes: 2 additions & 47 deletions tools/kani-cov/src/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ use std::{fs::File, io::BufReader, path::PathBuf};

use anyhow::Result;

use crate::coverage::{
function_coverage_results, function_info_from_file, CovResult, FileCoverageInfo, FunctionInfo,
MarkerInfo,
};
use crate::summary::{line_coverage_info, line_coverage_results};
use crate::coverage::{function_coverage_results, function_info_from_file, CovResult, MarkerInfo};
use crate::summary::line_coverage_results;
use crate::{args::ReportArgs, coverage::CombinedCoverageResults};
// use crate::coverage::CoverageResults;
// use args::Args;
Expand Down Expand Up @@ -64,48 +61,6 @@ pub fn print_coverage_results(
let idx = i + 1;
let line = line?;

// let line_checks: Vec<&CoverageCheck> = checks
// .iter()
// .filter(|c| {
// c.is_covered()
// && (cur_idx == c.region.start.0 as usize
// || cur_idx == c.region.end.0 as usize)
// })
// .collect();
// let new_line = if line_checks.is_empty() {
// if must_highlight {
// insert_escapes(&line, vec![(0, true), (line.len() - 1, false)])
// } else {
// line
// }
// } else {
// let mut markers = vec![];
// if must_highlight {
// markers.push((0, true))
// };

// for check in line_checks {
// let start_line = check.region.start.0 as usize;
// let start_column = (check.region.start.1 - 1u32) as usize;
// let end_line = check.region.end.0 as usize;
// let end_column = (check.region.end.1 - 1u32) as usize;
// if start_line == cur_idx {
// markers.push((start_column, true))
// }
// if end_line == cur_idx {
// markers.push((end_column, false))
// }
// }

// if markers.last().unwrap().1 {
// must_highlight = true;
// markers.push((line.len() - 1, false))
// } else {
// must_highlight = false;
// }
// println!("{:?}", markers);
// insert_escapes(&line, markers)
// };
let cur_line_result = flattened_results.iter().find(|(num, _)| *num == idx);

let (max_times, line_fmt) = if let Some((_, span_data)) = cur_line_result {
Expand Down

0 comments on commit 7d7ef6c

Please sign in to comment.