From f148354cb286722ce81d0fec918ffe4e03027a99 Mon Sep 17 00:00:00 2001 From: Pavel Valena Date: Wed, 26 Oct 2016 20:04:45 +0200 Subject: [PATCH] Fix: do not fail in operating_system.rb when X_SCLS is empty Enhance test_dependent_scls.rb Resolves: rhbz#1387139 --- operating_system.rb | 6 ++- ruby.spec | 14 +++++-- test_dependent_scls.rb | 92 +++++++++++++++++++++++++++--------------- 3 files changed, 74 insertions(+), 38 deletions(-) diff --git a/operating_system.rb b/operating_system.rb index 8e742fe..cdbc112 100644 --- a/operating_system.rb +++ b/operating_system.rb @@ -42,7 +42,11 @@ module Gem # Get enabled SCLs in order of (most) dependent SCL to base SCL def x_scls - @x_scls ||= ENV['X_SCLS'].split(' ').reverse! + @x_scls ||= if ENV['X_SCLS'].kind_of?(String) + ENV['X_SCLS'].split(' ').reverse! + else + [] + end end private :x_scls diff --git a/ruby.spec b/ruby.spec index 9dca15c..41d011f 100644 --- a/ruby.spec +++ b/ruby.spec @@ -23,7 +23,7 @@ %global ruby_archive %{ruby_archive}-%{?milestone}%{?!milestone:%{?revision:r%{revision}}} %endif -%global release 63 +%global release 64 %{!?release_string:%global release_string %{?development_release:0.}%{release}%{?development_release:.%{development_release}}%{?dist}} # The RubyGems library has to stay out of Ruby directory three, since the @@ -632,10 +632,12 @@ sed -i 's/^/%lang(ja) /' .ruby-doc.ja %check # Ruby software collection tests %{?scl:scl enable %scl - << \EOF +set -e mkdir -p ./lib/rubygems/defaults cp %{SOURCE1} ./lib/rubygems/defaults -make test-all TESTS="%{SOURCE14}" || exit 1 -rm -rf ./lib/rubygems/defaults +sed 's/@SCL@/%{scl}/' %{SOURCE14} > ./%{basename:%{SOURCE14}} +make test-all TESTS="%{basename:%{SOURCE14}}" +rm -rf ./lib/rubygems/defaults ./%{basename:%{SOURCE14}} EOF} # Check RubyGems version correctness. @@ -963,7 +965,11 @@ make check TESTS="-v $DISABLE_TESTS" %{ruby_libdir}/tkextlib %changelog -* Mon Oct 17 2016 Pavel Valena +* Wed Oct 26 2016 Pavel Valena - 2.3.1-64 +- Fix: do not fail in operating_system.rb when X_SCLS is empty + Resolves: rhbz#1387139 + +* Mon Oct 17 2016 Pavel Valena - 2.3.1-63 - Support in no_proxy for domain names with whitespaces and leading dots Resolves: rhbz#1384810 diff --git a/test_dependent_scls.rb b/test_dependent_scls.rb index 30c49ee..bff74d0 100644 --- a/test_dependent_scls.rb +++ b/test_dependent_scls.rb @@ -6,25 +6,36 @@ require 'rubygems/defaults/operating_system' class TestDependentSCLS < Test::Unit::TestCase def setup - # Avoid caching - Gem.class_eval("@x_scls, @default_locations, @default_dirs = nil, nil, nil") - # TODO: Different bin dir during build ("/builddir/build/BUILD/ruby-2.0.0-p247") @bin_dir = Gem::ConfigMap[:bindir].split(File::SEPARATOR).last - @scl = ENV['X_SCLS'].strip + @scl_root = '/opt/rh/@SCL@/root' + + @env_orig = ['X_SCLS', 'GEM_PATH'].inject({}) do |env_orig, key| + env_orig[key] = ENV[key].dup + env_orig + end + end + + def teardown + # Avoid caching + Gem.class_eval("@x_scls, @default_locations, @default_dirs, @get_default_dirs = nil, nil, nil, nil") + + @env_orig.each { |key, val| ENV[key] = val } end def test_default_paths - default_locations = { :system => "/opt/rh/#{@scl}/root/usr", - :local => "/opt/rh/#{@scl}/root/usr/local" } + ENV['X_SCLS'] = '@SCL@' # enabled scls + + default_locations = { :system => "#{@scl_root}/usr", + :local => "#{@scl_root}/usr/local" } assert_equal default_locations, Gem.default_locations - default_dirs = { :system => { :bin_dir => "/opt/rh/#{@scl}/root/usr/#{@bin_dir}", - :gem_dir => "/opt/rh/#{@scl}/root/usr/share/gems", - :ext_dir => "/opt/rh/#{@scl}/root/usr/lib64/gems" }, - :local => { :bin_dir => "/opt/rh/#{@scl}/root/usr/local/#{@bin_dir}", - :gem_dir => "/opt/rh/#{@scl}/root/usr/local/share/gems", - :ext_dir => "/opt/rh/#{@scl}/root/usr/local/lib64/gems" } } + default_dirs = { :system => { :bin_dir => "#{@scl_root}/usr/#{@bin_dir}", + :gem_dir => "#{@scl_root}/usr/share/gems", + :ext_dir => "#{@scl_root}/usr/lib64/gems" }, + :local => { :bin_dir => "#{@scl_root}/usr/local/#{@bin_dir}", + :gem_dir => "#{@scl_root}/usr/local/share/gems", + :ext_dir => "#{@scl_root}/usr/local/lib64/gems" } } assert_equal default_dirs, Gem.default_dirs end @@ -34,31 +45,46 @@ class TestDependentSCLS < Test::Unit::TestCase # # See rhbz#1034639 def test_paths_with_dependent_scl - prefix = '/some/prefix' - scl_name = 'ruby_x' + test_scl = 'ruby_x' + test_root = "/some/prefix/#{test_scl}/root" - ENV['X_SCLS'] = "#{@scl} #{scl_name}" # enabled scls - ENV['GEM_PATH'] = "#{prefix}/#{scl_name}/root/usr/share/gems" - - default_locations = { :system => "/opt/rh/#{@scl}/root/usr", - :local => "/opt/rh/#{@scl}/root/usr/local", - :"#{scl_name}_system" => "#{prefix}/#{scl_name}/root/usr", - :"#{scl_name}_local" => "#{prefix}/#{scl_name}/root/usr/local" } + ENV['X_SCLS'] = "@SCL@ #{test_scl}" # enabled scls + ENV['GEM_PATH'] = "#{test_root}/usr/share/gems" + default_locations = { :system => "#{@scl_root}/usr", + :local => "#{@scl_root}/usr/local", + :"#{test_scl}_system" => "#{test_root}/usr", + :"#{test_scl}_local" => "#{test_root}/usr/local" } assert_equal default_locations, Gem.default_locations - default_dirs = { :system => { :bin_dir => "/opt/rh/#{@scl}/root/usr/#{@bin_dir}", - :gem_dir => "/opt/rh/#{@scl}/root/usr/share/gems", - :ext_dir => "/opt/rh/#{@scl}/root/usr/lib64/gems" }, - :local => { :bin_dir => "/opt/rh/#{@scl}/root/usr/local/#{@bin_dir}", - :gem_dir => "/opt/rh/#{@scl}/root/usr/local/share/gems", - :ext_dir => "/opt/rh/#{@scl}/root/usr/local/lib64/gems" }, - :"#{scl_name}_system" => { :bin_dir => "#{prefix}/#{scl_name}/root/usr/#{@bin_dir}", - :gem_dir => "#{prefix}/#{scl_name}/root/usr/share/gems", - :ext_dir => "#{prefix}/#{scl_name}/root/usr/lib64/gems" }, - :"#{scl_name}_local" => { :bin_dir => "#{prefix}/#{scl_name}/root/usr/local/#{@bin_dir}", - :gem_dir => "#{prefix}/#{scl_name}/root/usr/local/share/gems", - :ext_dir => "#{prefix}/#{scl_name}/root/usr/local/lib64/gems" } } + default_dirs = { :system => { :bin_dir => "#{@scl_root}/usr/#{@bin_dir}", + :gem_dir => "#{@scl_root}/usr/share/gems", + :ext_dir => "#{@scl_root}/usr/lib64/gems" }, + :local => { :bin_dir => "#{@scl_root}/usr/local/#{@bin_dir}", + :gem_dir => "#{@scl_root}/usr/local/share/gems", + :ext_dir => "#{@scl_root}/usr/local/lib64/gems" }, + :"#{test_scl}_system" => { :bin_dir => "#{test_root}/usr/#{@bin_dir}", + :gem_dir => "#{test_root}/usr/share/gems", + :ext_dir => "#{test_root}/usr/lib64/gems" }, + :"#{test_scl}_local" => { :bin_dir => "#{test_root}/usr/local/#{@bin_dir}", + :gem_dir => "#{test_root}/usr/local/share/gems", + :ext_dir => "#{test_root}/usr/local/lib64/gems" } } + assert_equal default_dirs, Gem.default_dirs + end + + def test_empty_x_scls + ENV['X_SCLS'] = nil # no enabled scls + + default_locations = { :system => "#{@scl_root}/usr", + :local => "#{@scl_root}/usr/local" } + assert_equal default_locations, Gem.default_locations + + default_dirs = { :system => { :bin_dir => "#{@scl_root}/usr/#{@bin_dir}", + :gem_dir => "#{@scl_root}/usr/share/gems", + :ext_dir => "#{@scl_root}/usr/lib64/gems" }, + :local => { :bin_dir => "#{@scl_root}/usr/local/#{@bin_dir}", + :gem_dir => "#{@scl_root}/usr/local/share/gems", + :ext_dir => "#{@scl_root}/usr/local/lib64/gems" } } assert_equal default_dirs, Gem.default_dirs end