Skip to content

Commit

Permalink
No branch coverage on JRuby
Browse files Browse the repository at this point in the history
  • Loading branch information
bquorning committed Feb 14, 2025
1 parent 9ab332f commit 0dd053c
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions test/test_simple_cov-html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,12 @@ def test_output # rubocop:disable Metrics

assert_equal("74.11%", subheader_line_coverage)

# 58 total branches, 28 branches covered and 30 branches missed. ( 48.27% )
subheader_branch_coverage = html_doc.at_css("div#AllFiles div.t-branch-summary span:last-child").content.strip
unless RUBY_ENGINE != "jruby"
# 58 total branches, 28 branches covered and 30 branches missed. ( 48.27% )
subheader_branch_coverage = html_doc.at_css("div#AllFiles div.t-branch-summary span:last-child").content.strip

assert_equal("48.27%", subheader_branch_coverage)
assert_equal("48.27%", subheader_branch_coverage)
end

sorted_line_coverages = [
"57.14%",
Expand Down Expand Up @@ -220,20 +222,24 @@ def test_output # rubocop:disable Metrics

assert_equal(sorted_line_coverages, all_files_table_line_coverages.sort_by(&:to_f))

# Branch Coverage
all_files_table_branch_coverages = html_doc.css("div#AllFiles table.file_list tr.t-file td.t-file__branch-coverage").map { |m| m.content.strip }
unless RUBY_ENGINE != "jruby"
# Branch Coverage
all_files_table_branch_coverages = html_doc.css("div#AllFiles table.file_list tr.t-file td.t-file__branch-coverage").map { |m| m.content.strip }

assert_equal sorted_branch_coverages, all_files_table_branch_coverages.sort_by(&:to_f)
assert_equal sorted_branch_coverages, all_files_table_branch_coverages.sort_by(&:to_f)
end

# 66.66 lines covered
single_file_page_line_coverages = html_doc.css("div.source_files div.header h4:nth-child(2) span").map { |m| m.content.strip }

assert_equal(sorted_line_coverages, single_file_page_line_coverages.sort_by(&:to_f))

# 25.0% branches covered
single_file_page_branch_coverages = html_doc.css("div.source_files div.header h4:nth-child(3) span").map { |m| m.content.strip }
unless RUBY_ENGINE != "jruby" # rubocop:disable Style/GuardClause
# 25.0% branches covered
single_file_page_branch_coverages = html_doc.css("div.source_files div.header h4:nth-child(3) span").map { |m| m.content.strip }

assert_equal sorted_branch_coverages, single_file_page_branch_coverages.sort_by(&:to_f)
assert_equal sorted_branch_coverages, single_file_page_branch_coverages.sort_by(&:to_f)
end
end

private
Expand All @@ -246,7 +252,6 @@ def format_results(coverage_results)
capture_io { SimpleCov::Formatter::HTMLFormatter.new.format(result) }

# Return an HTML doc instance
puts output_path.join("index.html").read.lines.map(&:rstrip).join("\n").gsub(/\n\n+/, "\n")
output_path.join("index.html").open { |f| Nokogiri::HTML(f) }
end

Expand Down

0 comments on commit 0dd053c

Please sign in to comment.