-
Notifications
You must be signed in to change notification settings - Fork 553
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
Fix Ruby 3.4.0 branch coverage #1113
Comments
This seems to be a ruby bug, I openend https://bugs.ruby-lang.org/issues/20866 |
Ah, thanks. 🙇 Will track on Ruby Issues as well. |
eightbitraptor
added a commit
to Shopify/ruby
that referenced
this issue
Nov 20, 2024
This fixes a failed assertion reported to SimpleCov simplecov-ruby/simplecov#1113 The smallest repro I can make consists of 2 files test.rb containing the following code: ``` require 'coverage' Coverage.start(branches: true) require_relative 'broken.rb' ``` and `broken.rb` containing this ``` @foo&.bar(@baz) ```
eightbitraptor
added a commit
to Shopify/ruby
that referenced
this issue
Nov 20, 2024
This fixes a failed assertion reported to SimpleCov simplecov-ruby/simplecov#1113 This can be repro'd as follows: 1. Create a file `test.rb` containing the following code ``` @foo&.(@bar) ``` 2. require it with branch coverage enabled ``` ruby -rcoverage -e "Coverage.start(branches: true); require_relative 'test.rb'" ``` The assertion is failing because the Prism compiler is incorrectly detecting the start and end cursor position of the call site for the implicit call .() This patch replicates the parse.y behaviour of setting the default end_cursor to be the final closing location of the call node. This behaviour can be verified against `parse.y` by modifying the test command as follows: [Bug #20866] ``` ruby --parser=parse.y -rcoverage -e "Coverage.start(branches: true); require_relative 'test.rb'" ```
eightbitraptor
added a commit
to Shopify/ruby
that referenced
this issue
Nov 20, 2024
This fixes a failed assertion reported to SimpleCov simplecov-ruby/simplecov#1113 This can be repro'd as follows: 1. Create a file `test.rb` containing the following code ``` @foo&.(@bar) ``` 2. require it with branch coverage enabled ``` ruby -rcoverage -e "Coverage.start(branches: true); require_relative 'test.rb'" ``` The assertion is failing because the Prism compiler is incorrectly detecting the start and end cursor position of the call site for the implicit call .() This patch replicates the parse.y behaviour of setting the default end_cursor to be the final closing location of the call node. This behaviour can be verified against `parse.y` by modifying the test command as follows: ``` ruby --parser=parse.y -rcoverage -e "Coverage.start(branches: true); require_relative 'test.rb'" ``` [Bug #20866]
eightbitraptor
added a commit
to Shopify/ruby
that referenced
this issue
Nov 21, 2024
This fixes a failed assertion reported to SimpleCov simplecov-ruby/simplecov#1113 This can be repro'd as follows: 1. Create a file `test.rb` containing the following code ``` @foo&.(@bar) ``` 2. require it with branch coverage enabled ``` ruby -rcoverage -e "Coverage.start(branches: true); require_relative 'test.rb'" ``` The assertion is failing because the Prism compiler is incorrectly detecting the start and end cursor position of the call site for the implicit call .() This patch replicates the parse.y behaviour of setting the default end_cursor to be the final closing location of the call node. This behaviour can be verified against `parse.y` by modifying the test command as follows: ``` ruby --parser=parse.y -rcoverage -e "Coverage.start(branches: true); require_relative 'test.rb'" ``` [Bug #20866]
eightbitraptor
added a commit
to ruby/ruby
that referenced
this issue
Nov 21, 2024
This fixes a failed assertion reported to SimpleCov simplecov-ruby/simplecov#1113 This can be repro'd as follows: 1. Create a file `test.rb` containing the following code ``` @foo&.(@bar) ``` 2. require it with branch coverage enabled ``` ruby -rcoverage -e "Coverage.start(branches: true); require_relative 'test.rb'" ``` The assertion is failing because the Prism compiler is incorrectly detecting the start and end cursor position of the call site for the implicit call .() This patch replicates the parse.y behaviour of setting the default end_cursor to be the final closing location of the call node. This behaviour can be verified against `parse.y` by modifying the test command as follows: ``` ruby --parser=parse.y -rcoverage -e "Coverage.start(branches: true); require_relative 'test.rb'" ``` [Bug #20866]
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why
Hello. 👋 With Ruby 3.4.0, Preview 2, I'm experiencing the following issue when running my RSpec test suite:
How
To reproduce, run the following:
As a workaround, you can make SimpleCov work by doing the following:
core
project directory, openspec/spec_helper.rb
in your editor.enable_coverage :branch
.minimum_coverage_by_file line: 95, branch: 95
rspec
Notice the entire test suite runs as expected and there are no errors reported.
The issue seems to be with enabling branch coverage in Ruby 3.4.0. All of this works fine in Ruby 3.3.0, though.
Notes
Here's what I'm running:
The text was updated successfully, but these errors were encountered: