Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: add measure option and optimise LCOV parsing #91

Merged
merged 5 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ jobs:
COVERALLS_REPO_TOKEN: ${{ github.token }}
run: |
cd coverage
../bin/coveralls --base-path src/coverage_reporter/
../bin/coveralls report --measure --base-path src/coverage_reporter/
2 changes: 2 additions & 0 deletions spec/coverage_reporter/cli/cmd_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ Spectator.describe CoverageReporter::Cli do
--build-number=build-number
--compare-ref=develop
--attempt=4
--measure
--dry-run
)
end
Expand Down Expand Up @@ -159,6 +160,7 @@ Spectator.describe CoverageReporter::Cli do
let(options) do
%w(
done
-m
--build-number 3
--carryforward 1,2,3
--dry-run
Expand Down
12 changes: 6 additions & 6 deletions spec/coverage_reporter/parser_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Spectator.describe CoverageReporter::Parser do
it "returns reports for one file" do
reports = subject.parse

expect(reports.size).to eq 1
expect(reports.size).to eq 2
end

context "for non-existing file" do
Expand All @@ -27,9 +27,9 @@ Spectator.describe CoverageReporter::Parser do
end

context "for an unknown file format" do
let(coverage_files) { ["spec/fixtures/lcov/test.js"] }
let(coverage_files) { ["spec/fixtures/lcov/index.js"] }

it "returns reports for one file" do
it "returns an empty report" do
reports = subject.parse

expect(reports.size).to eq 0
Expand All @@ -42,7 +42,7 @@ Spectator.describe CoverageReporter::Parser do
it "returns report only for specified format" do
reports = subject.parse

expect(reports.size).to eq 1
expect(reports.size).to eq 2
end

context "when a file is specified" do
Expand All @@ -52,7 +52,7 @@ Spectator.describe CoverageReporter::Parser do
it "returns report only for specified file" do
reports = subject.parse

expect(reports.size).to eq 1
expect(reports.size).to eq 2
end
end

Expand Down Expand Up @@ -81,7 +81,7 @@ Spectator.describe CoverageReporter::Parser do
it "returns reports for all files" do
reports = subject.parse

expect(reports.size).to be > 1
expect(reports.size).to be > 2
end
end
end
Expand Down
58 changes: 34 additions & 24 deletions spec/coverage_reporter/parsers/lcov_parser_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,33 @@ Spectator.describe CoverageReporter::LcovParser do

describe "#parse" do
let(filename) { "spec/fixtures/lcov/test.lcov" }
let(digest) { "bbc3522fe6728f6e24bfe930a87ecc54" }
let(coverage) do
[1, 1, 1, nil, 1, 66, 66, nil, nil, 1, 323, 18446744073709551615u64, 63, 63, 60,
nil, 3, nil, 63, 32, nil, 63, 63, 63, 3, nil, 63, 60, nil, 3, nil, 63, 27, 27, 27,
nil, nil, 323, nil, nil, 1, 5, 5, nil, 2, nil, nil, 3, 3, 1, 1, 1, 1, nil, 0, nil,
nil, 2, 2, 2, 0, nil, 2, nil, nil, 2, 2, nil, nil, nil, nil, 1, 1, 1, 1, 1, 1, nil,
1, 1, nil, 1, 87, 87, 6, 6, 6, 6, 9, 6, 6, nil, 81, nil, nil, nil, 1, 1, nil, nil,
1, 1, nil, nil, 1, nil, 2, 2, 2, 1, nil, 2, nil, nil, 1, 3, 1, 1, nil, nil, 2, 2,
2, nil, 1, 1, nil, 2, nil, nil, nil, 1, 1, nil, nil, 1, 50, 50, 50, 50, 20, nil,
50, 50, 2, nil, 50, 50, 50, 31, nil, 50, 24, nil, 50, nil, nil, nil, nil, nil,
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil] of UInt64?
[1, nil, nil, 1, nil, nil, nil, nil, nil, 2, 2, nil, 18446744073709551615u64,
nil, nil, nil, 2, 2, nil, 2, nil, 2, nil, nil, nil, 1, 1, nil, nil, nil,
1, nil, nil, nil, 0, nil, nil, nil, 1] of UInt64?
end
let(branches) do
[10, 0, 0, 1, 10, 0, 1, 1,
10, 1, 0, 0, 10, 1, 1, 1,
11, 2, 0, 1, 11, 2, 1, 1,
20, 3, 0, 1, 20, 3, 1, 1] of UInt64
end

it "parses correctly" do
reports = subject.parse(filename)

expect(reports.size).to eq 1
expect(reports.size).to eq 2
expect(reports[0].to_h).to eq({
:name => "spec/fixtures/lcov/test.js",
:name => "spec/fixtures/lcov/index.js",
:coverage => [1, 1],
:source_digest => "97afaf84480a9f3fbb13393085b1d49d",
})
expect(reports[1].to_h).to eq({
:name => "spec/fixtures/lcov/lib/run.js",
:coverage => coverage,
:source_digest => "6e7aea5aa7198489561a44359dc7e1a4",
:branches => branches,
:source_digest => digest,
})
end

Expand All @@ -60,11 +67,12 @@ Spectator.describe CoverageReporter::LcovParser do
it "parses correctly" do
reports = subject.parse(filename)

expect(reports.size).to eq 1
expect(reports[0].to_h).to eq({
:name => "spec/fixtures/lcov/test.js",
expect(reports.size).to eq 2
expect(reports[1].to_h).to eq({
:name => "spec/fixtures/lcov/lib/run.js",
:coverage => coverage,
:source_digest => "6e7aea5aa7198489561a44359dc7e1a4",
:branches => branches,
:source_digest => digest,
})
end
end
Expand All @@ -75,11 +83,12 @@ Spectator.describe CoverageReporter::LcovParser do
it "parses correctly" do
reports = subject.parse(filename)

expect(reports.size).to eq 1
expect(reports[0].to_h).to eq({
:name => "spec/fixtures/lcov/test.js",
expect(reports.size).to eq 2
expect(reports[1].to_h).to eq({
:name => "spec/fixtures/lcov/lib/run.js",
:coverage => coverage,
:source_digest => "6e7aea5aa7198489561a44359dc7e1a4",
:branches => branches,
:source_digest => digest,
})
end
end
Expand All @@ -90,11 +99,12 @@ Spectator.describe CoverageReporter::LcovParser do
it "parses correctly" do
reports = subject.parse(filename)

expect(reports.size).to eq 1
expect(reports[0].to_h).to eq({
:name => "spec/fixtures/lcov/test.js",
expect(reports.size).to eq 2
expect(reports[1].to_h).to eq({
:name => "spec/fixtures/lcov/lib/run.js",
:coverage => coverage,
:source_digest => "6e7aea5aa7198489561a44359dc7e1a4",
:branches => branches,
:source_digest => digest,
})
end
end
Expand Down
162 changes: 51 additions & 111 deletions spec/fixtures/lcov/coverage/test.lcov
Original file line number Diff line number Diff line change
Expand Up @@ -7,117 +7,57 @@ LH:1
BRF:0
BRH:0
end_of_record
SF:spec/fixtures/lcov/test.js
TN:
SF:spec/fixtures/lcov/index.js
FNF:0
FNH:0
DA:1,1
DA:2,1
DA:3,1
DA:5,1
DA:6,66
DA:7,66
DA:10,1
DA:11,323
DA:12,18446744073709551615
DA:13,63
DA:14,63
DA:15,60
DA:17,3
DA:19,63
DA:20,32
DA:22,63
DA:23,63
DA:24,63
DA:25,3
DA:27,63
DA:28,60
DA:30,3
DA:32,63
DA:33,27
DA:34,27
DA:35,27
DA:38,323
DA:41,1
DA:42,5
DA:43,5
DA:45,2
DA:48,3
DA:49,3
DA:50,1
DA:51,1
DA:52,1
DA:53,1
DA:55,0
DA:58,2
DA:59,2
DA:60,2
DA:61,0
DA:63,2
DA:66,2
DA:67,2
DA:72,1
DA:73,1
DA:74,1
DA:75,1
DA:76,1
DA:77,1
DA:79,1
DA:80,1
DA:82,1
DA:83,87
DA:84,87
DA:85,6
DA:86,6
DA:87,6
DA:88,6
DA:89,9
DA:90,6
DA:91,6
DA:93,81
DA:97,1
DA:98,1
DA:101,1
DA:102,1
DA:105,1
DA:107,2
DA:108,2
DA:109,2
DA:110,1
DA:112,2
DA:115,1
DA:116,3
DA:117,1
DA:118,1
DA:121,2
DA:122,2
DA:123,2
DA:125,1
DA:126,1
DA:128,2
DA:132,1
DA:133,1
DA:136,1
DA:137,50
DA:138,50
DA:139,50
DA:140,50
DA:141,20
DA:143,50
DA:144,50
DA:145,2
DA:147,50
DA:148,50
DA:149,50
DA:150,31
DA:152,50
DA:153,24
DA:155,50
DA:210,40
DA:212,1
DA:213,8
DA:214,6
DA:216,8
DA:217,186
DA:218,21
DA:219,21
DA:220,21
DA:222,165
LF:2
LH:2
BRF:0
BRH:0
end_of_record
TN:
SF:spec/fixtures/lcov/lib/run.js
FN:2,(anonymous_0)
FN:7,(anonymous_1)
FN:16,(anonymous_2)
FN:25,(anonymous_3)
FN:30,(anonymous_4)
FN:34,(anonymous_5)
FNF:6
FNH:5
FNDA:1,(anonymous_0)
FNDA:2,(anonymous_1)
FNDA:2,(anonymous_2)
FNDA:1,(anonymous_3)
FNDA:1,(anonymous_4)
FNDA:0,(anonymous_5)
DA:1,1
DA:4,1
DA:10,2
DA:11,2
DA:13,18446744073709551615
DA:17,2
DA:18,2
DA:20,2
DA:22,2
DA:26,1
DA:27,1
DA:31,1
DA:35,0
DA:39,1
LF:14
LH:13
BRDA:10,0,0,1
BRDA:10,0,1,1
BRDA:10,1,0,0
BRDA:10,1,1,1
BRDA:11,2,0,1
BRDA:11,2,1,1
BRDA:20,3,0,1
BRDA:20,3,1,1
BRF:8
BRH:7
end_of_record
Loading