Skip to content

Commit

Permalink
Merge branch 'master' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
marco-c authored Sep 24, 2024
2 parents cb34c96 + a2e7740 commit f55e345
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 36 deletions.
37 changes: 31 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ you do not need to run as Administrator to use `grcov`.
1. Click Start, then select "Local Group Policy Editor". Or just run
`gpedit.msc` to open it directly.
1. In the navigation tree, select "Computer Configuration", "Windows Settings",
"Security Settings", "Local Policies".
"Security Settings", "Local Policies", "User Rights Assignment".
1. In the pane on the right, select "Create symbolic links" and double-click it.
1. Click "Add User or Group", and add your account.
1. Log out and then log back in.
Expand Down
15 changes: 9 additions & 6 deletions src/cobertura.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ use quick_xml::{
Writer,
};
use rustc_hash::FxHashMap;
use std::io::{BufWriter, Cursor, Write};
use std::path::Path;
use std::time::{SystemTime, UNIX_EPOCH};
use std::{
fmt::Display,
io::{BufWriter, Cursor, Write},
};
use std::{fmt::Formatter, path::Path};
use symbolic_common::Name;
use symbolic_demangle::{Demangle, DemangleOptions};

Expand Down Expand Up @@ -220,10 +223,10 @@ enum ConditionType {
Jump,
}

impl ToString for ConditionType {
fn to_string(&self) -> String {
match *self {
Self::Jump => String::from("jump"),
impl Display for ConditionType {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
Self::Jump => write!(f, "jump"),
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub fn merge_results(result: &mut CovResult, result2: CovResult) -> bool {
btree_map::Entry::Occupied(c) => {
let v = c.get().checked_add(execution_count).unwrap_or_else(|| {
warn_overflow = true;
std::u64::MAX
u64::MAX
});

*c.into_mut() = v;
Expand Down Expand Up @@ -140,7 +140,7 @@ fn rename_single_files(results: &mut [(String, CovResult)], stem: &str) {
if let Some(parent) = Path::new(stem).parent() {
for (file, _) in results.iter_mut() {
if has_no_parent(file) {
*file = parent.join(&file).to_str().unwrap().to_string();
*file = parent.join(file.as_str()).to_str().unwrap().to_string();
}
}
}
Expand Down
34 changes: 22 additions & 12 deletions src/llvm_tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,33 +245,43 @@ mod tests {
assert!(output_lcov
.lines()
.any(|line| line.contains("SF") && line.contains("src") && line.contains("main.rs")));
assert!(output_lcov.lines().any(|line| line.contains("FN:3")
&& line.contains("rust_code_coverage_sample")
&& line.contains("Ciao")));
if rustc_version::version_meta().unwrap().channel != rustc_version::Channel::Nightly {
assert!(output_lcov.lines().any(|line| line.contains("FN:3")
&& line.contains("rust_code_coverage_sample")
&& line.contains("Ciao")));
}
assert!(output_lcov.lines().any(|line| line.contains("FN:8")
&& line.contains("rust_code_coverage_sample")
&& line.contains("main")));
assert!(output_lcov.lines().any(|line| line.contains("FNDA:0")
&& line.contains("rust_code_coverage_sample")
&& line.contains("Ciao")));
if rustc_version::version_meta().unwrap().channel != rustc_version::Channel::Nightly {
assert!(output_lcov.lines().any(|line| line.contains("FNDA:0")
&& line.contains("rust_code_coverage_sample")
&& line.contains("Ciao")));
} else {
assert!(output_lcov.lines().any(|line| line.contains("FNDA:1")
&& line.contains("rust_code_coverage_sample")
&& line.contains("main")));
}
assert!(output_lcov.lines().any(|line| line.contains("FNDA:1")
&& line.contains("rust_code_coverage_sample")
&& line.contains("main")));
assert!(output_lcov.lines().any(|line| line == "FNF:2"));
if rustc_version::version_meta().unwrap().channel != rustc_version::Channel::Nightly {
assert!(output_lcov.lines().any(|line| line == "FNF:2"));
}
assert!(output_lcov.lines().any(|line| line == "FNH:1"));
assert!(output_lcov.lines().any(|line| line == "DA:3,0"));
assert!(output_lcov.lines().any(|line| line == "DA:8,1"));
assert!(output_lcov.lines().any(|line| line == "DA:9,1"));
if rustc_version::version_meta().unwrap().channel != rustc_version::Channel::Nightly {
assert!(output_lcov.lines().any(|line| line == "DA:10,1"));
assert!(output_lcov.lines().any(|line| line == "DA:3,0"));
}
assert!(output_lcov.lines().any(|line| line == "DA:8,1"));
assert!(output_lcov.lines().any(|line| line == "DA:9,1"));
assert!(output_lcov.lines().any(|line| line == "DA:10,1"));
assert!(output_lcov.lines().any(|line| line == "DA:11,1"));
assert!(output_lcov.lines().any(|line| line == "DA:12,1"));
assert!(output_lcov.lines().any(|line| line == "BRF:0"));
assert!(output_lcov.lines().any(|line| line == "BRH:0"));
if rustc_version::version_meta().unwrap().channel == rustc_version::Channel::Nightly {
assert!(output_lcov.lines().any(|line| line == "LF:5"));
assert!(output_lcov.lines().any(|line| line == "LH:4"));
assert!(output_lcov.lines().any(|line| line == "LH:5"));
} else {
assert!(output_lcov.lines().any(|line| line == "LF:6"));
assert!(output_lcov.lines().any(|line| line == "LH:5"));
Expand Down
2 changes: 1 addition & 1 deletion src/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,7 @@ impl Gcno {

impl GcovFunction {
fn get_cycle_count(edges: &mut [GcovEdge], path: &[usize]) -> u64 {
let mut count = std::u64::MAX;
let mut count = u64::MAX;
for e in path.iter() {
count = cmp::min(count, edges[*e].cycles);
}
Expand Down
9 changes: 1 addition & 8 deletions tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,7 @@ fn read_expected(
"linux"
};

let base_name = format!(
"expected{}",
if let Some(additional) = additional {
additional
} else {
""
}
);
let base_name = format!("expected{}", additional.unwrap_or_default());

let name_with_ver_and_os = format!(
"{}_{}_{}_{}.{}",
Expand Down

0 comments on commit f55e345

Please sign in to comment.