You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Couldn't find an issue that was directly related to this, please forgive me if I've overlooked something.
Love enable_coverage_for_eval since that allows getting coverage metrics for rails views, which was something that until Ruby 3.2, you had to do without. However, turning it on results in a lot of warnings, relative to this method in lib/simplecov/source_file.rb:
# lib/simplecov/source_file.rb:250-253# Warning to identify condition from Issue #56defcoverage_exceeding_source_warnwarn"Warning: coverage data provided by Coverage [#{coverage_data['lines'].size}] exceeds number of lines in #{filename} [#{src.size}]"end
Reviewing Issue#56, it wasn't clear why this warning occurs, other than we know that we're getting more lines reported for a source file than the code in the file actually has. I have not been able to determine why this is, but suspect it might be due to erb inserting lines in the file.
Below is a copy of the patch I created to allow turning these warnings off with an ENV var. Granted this is a crude fix, but it helps to clean up our test output.
My request is getting the below patch or something like it included in simplecov. Ultimately, these warnings are not helpful in their current form for view specs, since it's not clear why this is an issue or what can be done to resolve it.
tests are run with bin/rspec spec manually or via guard.
# spec/spec_helper.rb# frozen_string_literal: trueunlessRSpec.configuration.files_to_run.one?require'simplecov'require_relative'support/simplecov_warnings_patch'SimpleCov.start'rails'doenable_coverage:branchenable_coverage_for_eval# minimum_coverage line: 85, branch: 70# maximum_coverage_drop 5endend
...
<morespec_helper>
# spec/support/simplecov_warnings_patch.rb# frozen_string_literal: truemoduleSimpleCovclassSourceFile# this is needed for SimpleCov Issue#56# it also shows up for views when we `enable_coverage_for_eval`# patching here so that we can turn this off via ENV VARdefcoverage_exceeding_source_warnreturnunlessENV['SHOW_EXCESS_LINE_WARNING']message="Warning: coverage data provided by Coverage [#{coverage_data['lines'].size}] "message += "exceeds number of lines in #{filename} [#{src.size}]"warnmessageendendend
This is an example view spec for devise (v4.8.1) that reproduces the issue (remove the unless wrapper on SimpleCov config to get results from specs for a single file):
Again, main focus here is to have an env var or config option added to simplecov that allows silencing the warnings from the coverage_exceeding_source_warn method.
The text was updated successfully, but these errors were encountered:
this will then be executed from eval, src is 2 lines, coverage 1
I suppose that if you have nested renders in the same view you will have one line per nested template added to the total count of lines that will be evalueted, but i'm not sure.
Couldn't find an issue that was directly related to this, please forgive me if I've overlooked something.
Love
enable_coverage_for_eval
since that allows getting coverage metrics for rails views, which was something that until Ruby 3.2, you had to do without. However, turning it on results in a lot of warnings, relative to this method in lib/simplecov/source_file.rb:Reviewing Issue#56, it wasn't clear why this warning occurs, other than we know that we're getting more lines reported for a source file than the code in the file actually has. I have not been able to determine why this is, but suspect it might be due to erb inserting lines in the file.
Below is a copy of the patch I created to allow turning these warnings off with an ENV var. Granted this is a crude fix, but it helps to clean up our test output.
My request is getting the below patch or something like it included in simplecov. Ultimately, these warnings are not helpful in their current form for view specs, since it's not clear why this is an issue or what can be done to resolve it.
$ ruby -e "puts RUBY_DESCRIPTION" ruby 3.2.0 (2022-12-25 revision a528908271) [x86_64-linux]
Rails 7.0.4.3
RSpec 3.12.0
SimpleCov 0.22.0
tests are run with
bin/rspec spec
manually or via guard.This is an example view spec for devise (v4.8.1) that reproduces the issue (remove the
unless
wrapper on SimpleCov config to get results from specs for a single file):Again, main focus here is to have an env var or config option added to simplecov that allows silencing the warnings from the
coverage_exceeding_source_warn
method.The text was updated successfully, but these errors were encountered: