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

ignore nil branches during parallel combine #1081

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
5 changes: 4 additions & 1 deletion lib/simplecov/combine/files_combiner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ module FilesCombiner
#
def combine(coverage_a, coverage_b)
combination = {"lines" => Combine.combine(LinesCombiner, coverage_a["lines"], coverage_b["lines"])}
combination["branches"] = Combine.combine(BranchesCombiner, coverage_a["branches"], coverage_b["branches"]) if SimpleCov.branch_coverage?
if SimpleCov.branch_coverage?
branches = Combine.combine(BranchesCombiner, coverage_a["branches"], coverage_b["branches"])
combination["branches"] = branches unless branches.nil?
end
combination
end
end
Expand Down
14 changes: 7 additions & 7 deletions spec/combine/results_combiner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,31 +75,31 @@
end

it "has proper results for sample_controller.rb" do
expect(subject[source_fixture("app/controllers/sample_controller.rb")]["lines"]).to eq([nil, 4, 2, 1, nil, nil, 2, 0, nil, nil])
expect(subject[source_fixture("app/controllers/sample_controller.rb")]).to eq({"lines" => [nil, 4, 2, 1, nil, nil, 2, 0, nil, nil]})
end

it "has proper results for resultset1.rb" do
expect(subject[source_fixture("resultset1.rb")]["lines"]).to eq([1, 1, 1, 1])
expect(subject[source_fixture("resultset1.rb")]).to eq({"lines" => [1, 1, 1, 1]})
end

it "has proper results for resultset2.rb" do
expect(subject[source_fixture("resultset2.rb")]["lines"]).to eq([nil, 1, 1, nil])
expect(subject[source_fixture("resultset2.rb")]).to eq({"lines" => [nil, 1, 1, nil]})
end

it "has proper results for parallel_tests.rb" do
expect(subject[source_fixture("parallel_tests.rb")]["lines"]).to eq([nil, nil, nil, 0])
expect(subject[source_fixture("parallel_tests.rb")]).to eq({"lines" => [nil, nil, nil, 0]})
end

it "has proper results for conditionally_loaded_1.rb" do
expect(subject[source_fixture("conditionally_loaded_1.rb")]["lines"]).to eq([nil, 0, 1])
expect(subject[source_fixture("conditionally_loaded_1.rb")]).to eq({"lines" => [nil, 0, 1]})
end

it "has proper results for conditionally_loaded_2.rb" do
expect(subject[source_fixture("conditionally_loaded_2.rb")]["lines"]).to eq([nil, 0, 1])
expect(subject[source_fixture("conditionally_loaded_2.rb")]).to eq({"lines" => [nil, 0, 1]})
end

it "has proper results for three.rb" do
expect(subject[source_fixture("three.rb")]["lines"]).to eq([nil, 3, 7])
expect(subject[source_fixture("three.rb")]).to eq({"lines" => [nil, 3, 7]})
end
end
end
Expand Down
Loading