diff options
author | Hans de Graaff <graaff@gentoo.org> | 2023-04-07 11:27:19 +0200 |
---|---|---|
committer | Hans de Graaff <graaff@gentoo.org> | 2023-04-08 09:03:55 +0200 |
commit | 4b9c551af5f3181b0b903377134b388319bac05e (patch) | |
tree | e9d773acb16dbae5a6fe1fc215beb7f1b3dc5da7 /dev-ruby/sassc-rails | |
parent | media-libs/kvazaar: Keyword 2.2.0 ia64, #902217 (diff) | |
download | gentoo-4b9c551af5f3181b0b903377134b388319bac05e.tar.gz gentoo-4b9c551af5f3181b0b903377134b388319bac05e.tar.bz2 gentoo-4b9c551af5f3181b0b903377134b388319bac05e.zip |
dev-ruby/sassc-rails: add ruby31, fix tests
Signed-off-by: Hans de Graaff <graaff@gentoo.org>
Diffstat (limited to 'dev-ruby/sassc-rails')
3 files changed, 212 insertions, 0 deletions
diff --git a/dev-ruby/sassc-rails/files/sassc-rails-2.1.2-test-directories.patch b/dev-ruby/sassc-rails/files/sassc-rails-2.1.2-test-directories.patch new file mode 100644 index 000000000000..dd4ae709084c --- /dev/null +++ b/dev-ruby/sassc-rails/files/sassc-rails-2.1.2-test-directories.patch @@ -0,0 +1,73 @@ +From 9b653021e7a5a192758968a81b0dc81c68f298d0 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com> +Date: Mon, 27 Feb 2023 16:38:38 +0100 +Subject: [PATCH] Run test cases in separate test directories + +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!`. +--- + test/sassc_rails_test.rb | 15 +++++++++------ + 1 file changed, 9 insertions(+), 6 deletions(-) + +diff --git a/test/sassc_rails_test.rb b/test/sassc_rails_test.rb +index a15110d..f8c36e4 100644 +--- a/test/sassc_rails_test.rb ++++ b/test/sassc_rails_test.rb +@@ -4,14 +4,18 @@ + + class SassRailsTest < MiniTest::Test + attr_reader :app ++ attr_reader :test_dir + + def setup + Rails.application = nil + ++ @test_dir = Dir.mktmpdir("sassc-rails") ++ FileUtils.cp_r File.join(File.dirname(__FILE__), "dummy"), test_dir ++ + @app = Class.new(Rails::Application) + @app.config.active_support.deprecation = :log + @app.config.eager_load = false +- @app.config.root = File.join(File.dirname(__FILE__), "dummy") ++ @app.config.root = File.join(test_dir, "dummy") + @app.config.log_level = :debug + + # reset config back to default +@@ -30,8 +34,7 @@ def setup + end + + def teardown +- directory = "#{Rails.root}/tmp" +- FileUtils.remove_dir(directory) if File.directory?(directory) ++ FileUtils.remove_dir(test_dir) if File.directory?(test_dir) + end + + def render_asset(asset) +@@ -169,7 +172,7 @@ def test_line_comments_active_in_dev + + css_output = render_asset("css_scss_handler.css") + assert_match %r{/* line 1}, css_output +- assert_match %r{.+test/dummy/app/assets/stylesheets/css_scss_handler.css.scss}, css_output ++ assert_match %r{.+#{test_dir}/dummy/app/assets/stylesheets/css_scss_handler.css.scss}, css_output + end + + def test_context_is_being_passed_to_erb_render +@@ -287,7 +290,7 @@ def test_globbed_imports_work_when_globbed_file_is_changed + begin + initialize! + +- new_file = File.join(File.dirname(__FILE__), 'dummy', 'app', 'assets', 'stylesheets', 'globbed', 'new_glob.scss') ++ new_file = File.join(test_dir, 'dummy', 'app', 'assets', 'stylesheets', 'globbed', 'new_glob.scss') + + File.open(new_file, 'w') do |file| + file.puts '.new-file-test { color: #000; }' +@@ -314,7 +317,7 @@ def test_globbed_imports_work_when_globbed_file_is_added + + css_output = render_asset("glob_test.css") + refute_match /changed-file-test/, css_output +- new_file = File.join(File.dirname(__FILE__), 'dummy', 'app', 'assets', 'stylesheets', 'globbed', 'new_glob.scss') ++ new_file = File.join(test_dir, 'dummy', 'app', 'assets', 'stylesheets', 'globbed', 'new_glob.scss') + + File.open(new_file, 'w') do |file| + file.puts '.changed-file-test { color: #000; }' diff --git a/dev-ruby/sassc-rails/files/sassc-rails-2.1.2-test-isolation.patch b/dev-ruby/sassc-rails/files/sassc-rails-2.1.2-test-isolation.patch new file mode 100644 index 000000000000..afd2274fe0a0 --- /dev/null +++ b/dev-ruby/sassc-rails/files/sassc-rails-2.1.2-test-isolation.patch @@ -0,0 +1,90 @@ +From d2f47f3f7d6ea382a45b87042dfebde7dfe57b9a Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com> +Date: Mon, 27 Feb 2023 16:43:07 +0100 +Subject: [PATCH] Run the test cases in isolation + +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: + +https://github.com/rails/rails/commit/fe4377098b3800c3998f0583549a414b99b72b19 +--- + test/sassc_rails_test.rb | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/test/sassc_rails_test.rb b/test/sassc_rails_test.rb +index f8c36e4..36686cb 100644 +--- a/test/sassc_rails_test.rb ++++ b/test/sassc_rails_test.rb +@@ -1,8 +1,11 @@ + # frozen_string_literal: true + + require "test_helper" ++require 'active_support/testing/isolation' + + class SassRailsTest < MiniTest::Test ++ include ActiveSupport::Testing::Isolation ++ + attr_reader :app + attr_reader :test_dir + diff --git a/dev-ruby/sassc-rails/sassc-rails-2.1.2-r3.ebuild b/dev-ruby/sassc-rails/sassc-rails-2.1.2-r3.ebuild new file mode 100644 index 000000000000..ace5a004939f --- /dev/null +++ b/dev-ruby/sassc-rails/sassc-rails-2.1.2-r3.ebuild @@ -0,0 +1,49 @@ +# Copyright 1999-2023 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 +USE_RUBY="ruby27 ruby30 ruby31" + +RUBY_FAKEGEM_TASK_DOC="" +RUBY_FAKEGEM_EXTRADOC="README.md" + +RUBY_FAKEGEM_GEMSPEC="${PN}.gemspec" + +inherit ruby-fakegem + +DESCRIPTION="Integrate SassC-Ruby with Rails" +HOMEPAGE="https://github.com/sass/sassc-rails" + +LICENSE="MIT" +SLOT="$(ver_cut 1)" +KEYWORDS="~amd64" + +IUSE="" + +PATCHES=( "${FILESDIR}/${P}-test-directories.patch" "${FILESDIR}/${P}-test-isolation.patch" ) + +ruby_add_rdepend " + >=dev-ruby/sassc-2.0 + dev-ruby/tilt:* + || ( dev-ruby/railties:7.0 dev-ruby/railties:6.0 dev-ruby/railties:6.1 ) + >=dev-ruby/sprockets-3.0:* + dev-ruby/sprockets-rails:* +" + +ruby_add_bdepend " + test? ( dev-ruby/bundler dev-ruby/mocha )" + +all_ruby_prepare() { + sed -e '/rake/ s/,.*$//' \ + -e '/pry/ s:^:#:' \ + -e 's/git ls-files -z/find * -print0/' \ + -i ${RUBY_FAKEGEM_GEMSPEC} || die + sed -i -e '/pry/ s:^:#:' test/test_helper.rb || die + sed -e '/test_line_comments_active_in_dev/askip "Fails for unknown reason"' \ + -e '/test_globbed_imports_work_when_globbed_file_is_added/askip "Fails intermittently, similar to test above"' \ + -i test/sassc_rails_test.rb || die +} + +each_ruby_test() { + ${RUBY} -S bundle exec rake test || die +} |