Skip to content

Commit

Permalink
Merge pull request #202 from mihaiparv/issues/196
Browse files Browse the repository at this point in the history
Fix for Corrupted cobertura file format #196
  • Loading branch information
neonichu committed May 5, 2016
2 parents 2f5a267 + af77211 commit 749cfdb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## master

* Fix for correct line number for lines that are hit thousands or millions of time in llvm-cov.
[Mihai Parv](https://github.com/mihaiparv)
[#202](https://github.com/SlatherOrg/slather/pull/202), [#196](https://github.com/SlatherOrg/slather/issues/196)

* Generate coverate for multiple binaries by passing multiple `--binary-basename` or `--binary-file` arguments, or by using an array in `.slather.yml`
[Kent Sutherland](https://github.com/ksuther)
[#188](https://github.com/SlatherOrg/slather/pull/188)
Expand Down
11 changes: 11 additions & 0 deletions lib/slather/profdata_coverage_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,17 @@ def line_number_in_line(line)
when /[0-9]+/
return match.to_i
end
else
# llvm-cov outputs hit counts as 25.3k or 3.8M, so check this pattern as well
did_match = line =~ /^(\s*)(\d+\.\d+)(k|M)\|(\s*)(\d+)\|/

if did_match
match = $5.strip
case match
when /[0-9]+/
return match.to_i
end
end
end
0
end
Expand Down
10 changes: 9 additions & 1 deletion spec/slather/profdata_coverage_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,17 @@
end

describe "#line_number_in_line" do
it "should return the correct line number" do
it "should return the correct line number for coverage represented as decimals" do
expect(profdata_coverage_file.line_number_in_line(" 0| 40| func applicationWillTerminate(application: UIApplication) {")).to eq(40)
end

it "should return the correct line number for coverage represented as thousands" do
expect(profdata_coverage_file.line_number_in_line(" 11.8k| 41| func applicationWillTerminate(application: UIApplication) {")).to eq(41)
end

it "should return the correct line number for coverage represented as milions" do
expect(profdata_coverage_file.line_number_in_line(" 2.58M| 42| func applicationWillTerminate(application: UIApplication) {")).to eq(42)
end
end

describe "#coverage_for_line" do
Expand Down

0 comments on commit 749cfdb

Please sign in to comment.