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

Fix test suite for Rails 7 #178

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

voxik
Copy link

@voxik voxik commented Feb 27, 2023

Running the test suite against Rails 7, I observe errors such as:

SassRailsTest#test_setup_works:
FrozenError: can't modify frozen Array: []
    railties (7.0.4.2) lib/rails/engine.rb:574:in `unshift'
    railties (7.0.4.2) lib/rails/engine.rb:574:in `block in <class:Engine>'
    railties (7.0.4.2) lib/rails/initializable.rb:32:in `instance_exec'
    railties (7.0.4.2) lib/rails/initializable.rb:32:in `run'
    railties (7.0.4.2) lib/rails/initializable.rb:61:in `block in run_initializers'
    usr/share/ruby/tsort.rb:228:in `block in tsort_each'
    usr/share/ruby/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
    usr/share/ruby/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
    usr/share/ruby/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
    usr/share/ruby/tsort.rb:431:in `each_strongly_connected_component_from'
    usr/share/ruby/tsort.rb:421:in `block in each_strongly_connected_component_from'
    railties (7.0.4.2) lib/rails/initializable.rb:50:in `each'
    railties (7.0.4.2) lib/rails/initializable.rb:50:in `tsort_each_child'
    usr/share/ruby/tsort.rb:415:in `call'
    usr/share/ruby/tsort.rb:415:in `each_strongly_connected_component_from'
    usr/share/ruby/tsort.rb:421:in `block in each_strongly_connected_component_from'
    railties (7.0.4.2) lib/rails/initializable.rb:50:in `each'
    railties (7.0.4.2) lib/rails/initializable.rb:50:in `tsort_each_child'
    usr/share/ruby/tsort.rb:415:in `call'
    usr/share/ruby/tsort.rb:415:in `each_strongly_connected_component_from'
    usr/share/ruby/tsort.rb:349:in `block in each_strongly_connected_component'
    usr/share/ruby/tsort.rb:347:in `each'
    usr/share/ruby/tsort.rb:347:in `call'
    usr/share/ruby/tsort.rb:347:in `each_strongly_connected_component'
    usr/share/ruby/tsort.rb:226:in `tsort_each'
    usr/share/ruby/tsort.rb:205:in `tsort_each'
    railties (7.0.4.2) lib/rails/initializable.rb:60:in `run_initializers'
    railties (7.0.4.2) lib/rails/application.rb:372:in `initialize!'
    railties (7.0.4.2) lib/rails/railtie.rb:226:in `public_send'
    railties (7.0.4.2) lib/rails/railtie.rb:226:in `method_missing'
    builddir/build/BUILD/sassc-rails-2.1.2/usr/share/gems/gems/sassc-rails-2.1.2/test/sassc_rails_test.rb:48:in `initialize_dev!'
    builddir/build/BUILD/sassc-rails-2.1.2/usr/share/gems/gems/sassc-rails-2.1.2/test/sassc_rails_test.rb:57:in `test_setup_works'
    minitest (5.17.0) lib/minitest/test.rb:102:in `block (3 levels) in run'
    minitest (5.17.0) lib/minitest/test.rb:199:in `capture_exceptions'
    minitest (5.17.0) lib/minitest/test.rb:97:in `block (2 levels) in run'
    minitest (5.17.0) lib/minitest.rb:296:in `time_it'
    minitest (5.17.0) lib/minitest/test.rb:96:in `block in run'
    minitest (5.17.0) lib/minitest.rb:391:in `on_signal'
    minitest (5.17.0) lib/minitest/test.rb:247:in `with_info_handler'
    minitest (5.17.0) lib/minitest/test.rb:95:in `run'
    minitest (5.17.0) lib/minitest.rb:1051:in `run_one_method'
    minitest (5.17.0) lib/minitest.rb:365:in `run_one_method'
    minitest (5.17.0) lib/minitest.rb:352:in `block (2 levels) in run'
    minitest (5.17.0) lib/minitest.rb:351:in `each'
    minitest (5.17.0) lib/minitest.rb:351:in `block in run'
    minitest (5.17.0) lib/minitest.rb:391:in `on_signal'
    minitest (5.17.0) lib/minitest.rb:378:in `with_info_handler'
    minitest (5.17.0) lib/minitest.rb:350:in `run'
    minitest (5.17.0) lib/minitest.rb:182:in `block in __run'
    minitest (5.17.0) lib/minitest.rb:182:in `map'
    minitest (5.17.0) lib/minitest.rb:182:in `__run'
    minitest (5.17.0) lib/minitest.rb:159:in `run'
    minitest (5.17.0) lib/minitest.rb:83:in `block in autorun'
rails test /builddir/build/BUILD/sassc-rails-2.1.2/usr/share/gems/gems/sassc-rails-2.1.2/test/sassc_rails_test.rb:56

This seems to be due to initialize! called multiple times and specifically caused by rails/rails@fe43770

The proposed fix is to run the test cases in isolation using ActiveSupport::Testing::Isolation

This is in preparation to be able to run the tests in isolation, because
recent versions of Rails does not allow multiple to calls to
`initialize!`.
This is to prevent test errors in recent versions of Rails such as:

~~~
SassRailsTest#test_setup_works:
FrozenError: can't modify frozen Array: []
    railties (7.0.4.2) lib/rails/engine.rb:574:in `unshift'
    railties (7.0.4.2) lib/rails/engine.rb:574:in `block in <class:Engine>'
    railties (7.0.4.2) lib/rails/initializable.rb:32:in `instance_exec'
    railties (7.0.4.2) lib/rails/initializable.rb:32:in `run'
    railties (7.0.4.2) lib/rails/initializable.rb:61:in `block in run_initializers'
    usr/share/ruby/tsort.rb:228:in `block in tsort_each'
    usr/share/ruby/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
    usr/share/ruby/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
    usr/share/ruby/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
    usr/share/ruby/tsort.rb:431:in `each_strongly_connected_component_from'
    usr/share/ruby/tsort.rb:421:in `block in each_strongly_connected_component_from'
    railties (7.0.4.2) lib/rails/initializable.rb:50:in `each'
    railties (7.0.4.2) lib/rails/initializable.rb:50:in `tsort_each_child'
    usr/share/ruby/tsort.rb:415:in `call'
    usr/share/ruby/tsort.rb:415:in `each_strongly_connected_component_from'
    usr/share/ruby/tsort.rb:421:in `block in each_strongly_connected_component_from'
    railties (7.0.4.2) lib/rails/initializable.rb:50:in `each'
    railties (7.0.4.2) lib/rails/initializable.rb:50:in `tsort_each_child'
    usr/share/ruby/tsort.rb:415:in `call'
    usr/share/ruby/tsort.rb:415:in `each_strongly_connected_component_from'
    usr/share/ruby/tsort.rb:349:in `block in each_strongly_connected_component'
    usr/share/ruby/tsort.rb:347:in `each'
    usr/share/ruby/tsort.rb:347:in `call'
    usr/share/ruby/tsort.rb:347:in `each_strongly_connected_component'
    usr/share/ruby/tsort.rb:226:in `tsort_each'
    usr/share/ruby/tsort.rb:205:in `tsort_each'
    railties (7.0.4.2) lib/rails/initializable.rb:60:in `run_initializers'
    railties (7.0.4.2) lib/rails/application.rb:372:in `initialize!'
    railties (7.0.4.2) lib/rails/railtie.rb:226:in `public_send'
    railties (7.0.4.2) lib/rails/railtie.rb:226:in `method_missing'
    builddir/build/BUILD/sassc-rails-2.1.2/usr/share/gems/gems/sassc-rails-2.1.2/test/sassc_rails_test.rb:48:in `initialize_dev!'
    builddir/build/BUILD/sassc-rails-2.1.2/usr/share/gems/gems/sassc-rails-2.1.2/test/sassc_rails_test.rb:57:in `test_setup_works'
    minitest (5.17.0) lib/minitest/test.rb:102:in `block (3 levels) in run'
    minitest (5.17.0) lib/minitest/test.rb:199:in `capture_exceptions'
    minitest (5.17.0) lib/minitest/test.rb:97:in `block (2 levels) in run'
    minitest (5.17.0) lib/minitest.rb:296:in `time_it'
    minitest (5.17.0) lib/minitest/test.rb:96:in `block in run'
    minitest (5.17.0) lib/minitest.rb:391:in `on_signal'
    minitest (5.17.0) lib/minitest/test.rb:247:in `with_info_handler'
    minitest (5.17.0) lib/minitest/test.rb:95:in `run'
    minitest (5.17.0) lib/minitest.rb:1051:in `run_one_method'
    minitest (5.17.0) lib/minitest.rb:365:in `run_one_method'
    minitest (5.17.0) lib/minitest.rb:352:in `block (2 levels) in run'
    minitest (5.17.0) lib/minitest.rb:351:in `each'
    minitest (5.17.0) lib/minitest.rb:351:in `block in run'
    minitest (5.17.0) lib/minitest.rb:391:in `on_signal'
    minitest (5.17.0) lib/minitest.rb:378:in `with_info_handler'
    minitest (5.17.0) lib/minitest.rb:350:in `run'
    minitest (5.17.0) lib/minitest.rb:182:in `block in __run'
    minitest (5.17.0) lib/minitest.rb:182:in `map'
    minitest (5.17.0) lib/minitest.rb:182:in `__run'
    minitest (5.17.0) lib/minitest.rb:159:in `run'
    minitest (5.17.0) lib/minitest.rb:83:in `block in autorun'
rails test /builddir/build/BUILD/sassc-rails-2.1.2/usr/share/gems/gems/sassc-rails-2.1.2/test/sassc_rails_test.rb:56
~~~

This is caused by multiple calls to `initialize!` method and very likely
due to this commit in Rails:

rails/rails@fe43770
@pvalena
Copy link

pvalena commented Feb 27, 2023

LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants