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

Run tests with prism parser #53

Merged
merged 6 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
16 changes: 16 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,19 @@ jobs:
bundler: 2.3.26
- name: Run tests
run: bundle exec rspec

test-prism:
runs-on: ubuntu-latest
env:
BUNDLE_GEMFILE: "gemfiles/rubocop_1.66.gemfile"
PARSER_ENGINE: parser_prism
steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true # 'bundle install' and cache gems
ruby-version: 3.3
bundler: 2.3.26
- name: Run tests
run: bundle exec rspec
1 change: 1 addition & 0 deletions rubocop-thread_safety.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Gem::Specification.new do |spec|

spec.add_development_dependency 'appraisal'
spec.add_development_dependency 'bundler', '>= 1.10', '< 3'
spec.add_development_dependency 'prism'
spec.add_development_dependency 'pry' unless ENV['CI']
spec.add_development_dependency 'rake', '>= 10.0'
spec.add_development_dependency 'rspec', '~> 3.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def some_method
it_behaves_like 'mutable objects', %("\#{a}")
end

context 'when the frozen_string_literal comment is true' do
context 'when the frozen_string_literal comment is true', unsupported_on: :prism do
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will make RSpec skip it on prism and let us know when it starts working because RSpec enforces pending specs must fail.

https://rspec.info/features/3-12/rspec-core/pending-and-skipped-examples/

Suggested change
context 'when the frozen_string_literal comment is true', unsupported_on: :prism do
context 'when the frozen_string_literal comment is true' do
pending 'Unsupported on prism' if ENV['PARSER_ENGINE'] == 'parser_prism'

We could consider extracting a helper:

def prism?
  ENV['PARSER_ENGINE'] == 'parser_prism'
end

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I didn't know about this feature. However, is this case it's not a prism-related issue, this spec only passes with Ruby 2.7 parser (dynamic strings are not frozen by default since 3.0), and while all the specs run with 2.7 parser, setting PARSER_ENGINE to parser_prism automatically promotes the parser to 3.3. So this spec will never pass on prism.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added specs for default parser that run at Ruby 3.0 (it now covers this line).

let(:prefix) { "# frozen_string_literal: true\n#{super()}" }

it_behaves_like 'immutable objects', %("\#{a}")
Expand Down Expand Up @@ -605,7 +605,7 @@ def assignment?
it_behaves_like 'mutable objects', %("\#{a}")
end

context 'when the frozen_string_literal comment is true' do
context 'when the frozen_string_literal comment is true', unsupported_on: :prism do
let(:prefix) { "# frozen_string_literal: true\n#{super()}" }

it_behaves_like 'immutable objects', %("\#{a}")
Expand Down
2 changes: 2 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
config.fail_fast = ENV.key? 'RSPEC_FAIL_FAST'
end

config.filter_run_excluding unsupported_on: :prism if ENV['PARSER_ENGINE'] == 'parser_prism'

config.disable_monkey_patching!

config.order = :random
Expand Down