Skip to content

Commit

Permalink
raise rust-version to 1.73 like cargo-llvm-cov, fix expected test value
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-kfed committed Jun 8, 2024
1 parent 20cef71 commit d21053d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ description = "convert LCOV info file to cobertura XML format"
repository = "https://github.com/mike-kfed/lcov2cobertura"
keywords = ["coverage", "gitlab", "cobertura", "lcov"]
categories = ["command-line-utilities"]
rust-version = "1.59"
rust-version = "1.73"

[workspace]

Expand Down
2 changes: 1 addition & 1 deletion lcov2cobertura/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ license = "Apache-2.0"
description = "convert LCOV info file to cobertura XML format"
repository = "https://github.com/mike-kfed/lcov2cobertura"
keywords = ["coverage", "gitlab", "cobertura", "lcov"]
rust-version = "1.59"
rust-version = "1.73"

[dependencies]
anyhow = "1.0.86"
Expand Down
6 changes: 2 additions & 4 deletions lcov2cobertura/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,23 +326,21 @@ pub fn parse_lines<P: AsRef<Path>, B: BufRead>(
let mut split = line.splitn(2, ':');
let (input_type, line) = (split.next(), split.last());

// proposed improvement only works in rustc 1.63 and above
#[allow(clippy::assigning_clones)]
match input_type {
Some("SF") => {
let file_name = line.ok_or_else(|| anyhow::anyhow!("SF entry has no filename"))?;
let file_path = Path::new(file_name);
// TODO: was `relative_file_name = os.path.relpath(file_name, self.base_dir)`
// does not do the same as strip_prefix, but I am fairly certain it was the idea
// TODO: proper unwrap error handling
relative_file_name = file_path
file_path
.strip_prefix(base_dir)
.unwrap_or(file_path)
.to_str()
.ok_or_else(|| {
anyhow::anyhow!("relative_file_name cannot be converted to string")
})?
.to_owned();
.clone_into(&mut relative_file_name);
let elems = relative_file_name
.split(std::path::MAIN_SEPARATOR)
.collect::<Vec<&str>>();
Expand Down
4 changes: 2 additions & 2 deletions lcov2cobertura/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ fn test_demangle_rust() {
<classes>
<class branch-rate="0" complexity="0" filename="foo/foo.cpp" line-rate="1" name="foo.foo.cpp">
<methods>
<method name="foo[0]" signature="" complexity="0" line-rate="1" branch-rate="1">
<method name="foo" signature="" complexity="0" line-rate="1" branch-rate="1">
<lines>
<line hits="1" number="8" branch="false"/>
</lines>
Expand All @@ -212,7 +212,7 @@ fn test_demangle_rust() {
<line hits="1" number="0" branch="false"/>
</lines>
</method>
<method name="123foo[0]::bar" signature="" complexity="0" line-rate="0" branch-rate="0">
<method name="123foo::bar" signature="" complexity="0" line-rate="0" branch-rate="0">
<lines>
<line hits="0" number="3" branch="false"/>
</lines>
Expand Down

0 comments on commit d21053d

Please sign in to comment.